python-opentraveldata

Python wrapper around OpenTravelData (OPTD)

View the Project on GitHub opentraveldata/python-opentraveldata

OpenTravelData (OPTD) Data Wrapper - Python Bindings

Docker Repository on Quay

Python wrapper around OpenTravelData (OPTD) data sets, for instance to be used by Python software needing to access OPTD data.

References

Python

Usage

pp.pprint (myOPTD.getServingPORList (‘IEV’)) {‘original’: {‘adm1_code’: ‘12’, ‘adm1_name_utf’: ‘Kyiv City’, ‘country_code’: ‘UA’, ‘country_name’: ‘Ukraine’, ‘envelope_id’: ‘’, ‘geoname_id’: 703448, ‘iata_code’: ‘IEV’, ‘location_type’: ‘C’, ‘name’: ‘Kyiv’}, ‘tvl_list’: [{‘adm1_code’: ‘12’, ‘adm1_name_utf’: ‘Kyiv City’, ‘country_code’: ‘UA’, ‘country_name’: ‘Ukraine’, ‘envelope_id’: ‘’, ‘geoname_id’: 6300960, ‘iata_code’: ‘IEV’, ‘location_type’: ‘A’, ‘name’: ‘Kyiv Zhuliany International Airport’}, {‘adm1_code’: ‘13’, ‘adm1_name_utf’: ‘Kyiv’, ‘country_code’: ‘UA’, ‘country_name’: ‘Ukraine’, ‘envelope_id’: ‘’, ‘geoname_id’: 6300952, ‘iata_code’: ‘KBP’, ‘location_type’: ‘A’, ‘name’: ‘Kyiv Boryspil International Airport’}, {‘adm1_code’: ‘13’, ‘adm1_name_utf’: ‘Kyiv’, ‘country_code’: ‘UA’, ‘country_name’: ‘Ukraine’, ‘envelope_id’: ‘’, ‘geoname_id’: 8260936, ‘iata_code’: ‘QOF’, ‘location_type’: ‘B’, ‘name’: ‘Darnytsia Bus Station’}, {‘adm1_code’: ‘’, ‘adm1_name_utf’: ‘’, ‘country_code’: ‘UA’, ‘country_name’: ‘Ukraine’, ‘envelope_id’: ‘’, ‘geoname_id’: 0, ‘iata_code’: ‘QOH’, ‘location_type’: ‘B’, ‘name’: ‘Kiev UA Hotel Rus’}]} ```

Installation - configuration

Python

_EOF user@laptop$ . ~/.bashrc user@laptop$ pyenv install 3.9.6 && pyenv global 3.9.6 && pip install -U pip pipenv && pyenv global


* Clone the Git repository and install the Python virtual environment
  (with `pipenv`):
```bash
user@laptop$ mkdir -p ~/dev/geo && \
  git clone https://github.com/opentraveldata/python-opentraveldata.git ~/dev/geo/python-opentraveldata
user@laptop$ cd ~/dev/geo/python-opentraveldata
user@laptop$ pipenv --rm && pipenv install && pipenv install --dev
user@laptop$ pipenv shell
(python-opentraveldata-BScCAakO)$ python --version
Python 3.9.6
(python-opentraveldata-BScCAakO)$ exit

PyPi credentials for Travis deployment

Package and release the Python module

View at: https://test.pypi.org/project/opentraveldata/0.0.9/


* Upload/release the Python packages onto the
  [PyPi repository](https://pypi.org):
```bash
user@laptop$ PYPIURL="https://pypi.org"
user@laptop$ pipenv run keyring set ${PYPIURL}/ __token__
Password for '__token__' in '${PYPIURL}/':
user@laptop$ pipenv run twine upload -u __token__ --non-interactive dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading opentraveldata-0.0.9-py3-none-any.whl
100%|██████████████████████████████████████████████████████████████████████| 23.7k/23.7k [00:01<00:00, 15.2kB/s]
Uploading opentraveldata-0.0.9.tar.gz
100%|██████████████████████████████████████████████████████████████████████| 44.3k/44.3k [00:01<00:00, 44.7kB/s]

View at:
https://pypi.org/project/opentraveldata/0.0.9/

Test the Python module

Pytest

test_optd-csvwriter.py . [ 33%] test_optd-serving-por.py .. [100%]

=============================== 3 passed in 2.58s ======================= ___________ summary ___________


## Tox

```bash
$ pipenv run tox
.package recreate: ~/dev/geo/python-opentraveldata/.tox/.package
.package installdeps: setuptools >= 35.0.2, setuptools_scm >= 2.0.0, <3
py39 create: ~/dev/geo/python-opentraveldata/.tox/py39
py39 installdeps: pytest
py39 inst: ~/dev/geo/python-opentraveldata/.tox/.tmp/package/1/opentraveldata-0.0.9.tar.gz
py39 installed: attrs==19.3.0,certifi==2019.11.28,chardet==3.0.4,idna==2.9,more-itertools==8.2.0,opentraveldata==0.0.9,packaging==20.3,pluggy==0.13.1,py==1.8.1,pyparsing==2.4.6,pytest==5.3.5,python-dateutil==2.8.1,pytz==2019.3,requests==2.23.0,six==1.14.0,urllib3==1.25.8,wcwidth==0.1.8
py39 run-test-pre: PYTHONHASHSEED='3773488260'
py39 run-test: commands[0] | pytest
======================= test session starts =============================
platform darwin -- Python 3.9.5, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
cachedir: .tox/py39/.pytest_cache
rootdir: ~/dev/geo/python-opentraveldata
collected 3 items                                                     

test_optd-csvwriter.py .                                           [ 33%]
test_optd-serving-por.py ..                                        [100%]

=============================== 3 passed in 2.58s =======================
_________________________________ summary _____________________________
  py39: commands succeeded
  congratulations :)