Skip to content

Commit

Permalink
Update documentation and docs (a bit)
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakov512 committed Feb 21, 2020
1 parent e81d096 commit db20fae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Yandex Geocoder
===
Get address coordinates via Yandex geocoder

[![Build Status](https://github.com/sivakov512/yandex-geocoder/workflows/test/badge.svg)](https://github.com/sivakov512/yandex-geocoder)
[![Build Status](https://github.com/sivakov512/yandex-geocoder/workflows/test/badge.svg)](https://github.com/sivakov512/yandex-geocoder/actions?query=workflow%3Atest)
[![Coverage Status](https://coveralls.io/repos/github/sivakov512/yandex-geocoder/badge.svg?branch=master)](https://coveralls.io/github/sivakov512/yandex-geocoder?branch=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![Python versions](https://img.shields.io/pypi/pyversions/yandex-geocoder.svg)](https://pypi.python.org/pypi/yandex-geocoder)
Expand All @@ -18,10 +18,21 @@ pip install yandex-geocoder

Usage example
---
Yandex Geocoder requires an API developer key, you can get it [here](https://developer.tech.yandex.ru/services/) to use this library.

``` python
from decimal import Decimal

from yandex_geocoder import Client
Client.coordinates('Хабаровск 60 октября 150') # ('135.114326', '48.47839')


client = Client("your-api-key")

coordinates = client.coordinates("Москва Льва Толстого 16")
assert coordinates == (Decimal("37.587093"), Decimal("55.733969"))

address = client.address(Decimal("37.587093"), Decimal("55.733969"))
assert address == "Россия, Москва, улица Льва Толстого, 16"
```

Development and contribution
Expand Down Expand Up @@ -49,7 +60,3 @@ black --check ./
```

* feel free to contribute!

Credits
---
- [f213](https://github.com/f213)
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ def read(fname):
setup(
author="Nikita Sivakov",
author_email="[email protected]",
description="Simple library for getting address coordinates via Yandex geocoder",
description="Simple library for getting address or coordinates via Yandex geocoder",
install_requires=["requests~=2.22"],
keywords="yandex geocoder geo coordinates maps api",
keywords="yandex geocoder geo coordinates address maps api",
license="MIT",
long_description=read("README.md"),
long_description_content_type="text/markdown",
name="yandex_geocoder",
packages=["yandex_geocoder"],
python_requires=">=3.6",
url="https://github.com/sivakov512/yandex-geocoder",
version="1.0.1",
version="2.0.0",
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
Expand Down
22 changes: 9 additions & 13 deletions yandex_geocoder/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class Client:
:Example:
>>> from yandex_geocoder import Client
>>> client = Client("api-key")
>>> client.coordinates('Хабаровск 60 октября 150')
('135.114326', '48.47839')
>>> client = Client("your-api-key")
>>> coordinates = client.coordinates("Москва Льва Толстого 16")
>>> assert coordinates == (Decimal("37.587093"), Decimal("55.733969"))
>>> address = client.address(Decimal("37.587093"), Decimal("55.733969"))
>>> assert address == "Россия, Москва, улица Льва Толстого, 16"
"""

Expand All @@ -40,11 +44,7 @@ def _request(self, address: str) -> dict:
)

def coordinates(self, address: str) -> Tuple[Decimal]:
"""Returns a tuple of coordinates (longtitude, latitude) for passed address.
Raises `NothingFound` if nothing found.
"""
"""Fetch coordinates (longitude, latitude) for passed address."""
data = self._request(address)["GeoObjectCollection"]["featureMember"]

if not data:
Expand All @@ -56,11 +56,7 @@ def coordinates(self, address: str) -> Tuple[Decimal]:
return Decimal(longitude), Decimal(latitude)

def address(self, longitude: Decimal, latitude: Decimal) -> str:
"""Returns addres for passed coordinates.
Raises `NothingFound` if nothing found.
"""
"""Fetch address for passed coordinates."""
got = self._request(f"{longitude},{latitude}")
data = got["GeoObjectCollection"]["featureMember"]

Expand Down

0 comments on commit db20fae

Please sign in to comment.