opentraveldata


Nameopentraveldata JSON
Version 0.0.9.post3 PyPI version JSON
download
home_pageNone
SummarySimple Python wrapper for OpenTravelata (OPTD)
upload_time2024-04-04 21:21:51
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords packaging package dependency pyproject.toml api python optd opentraveldata
VCS
bugtrack_url
requirements datetime pytz setuptools zope.interface
Travis-CI
coveralls test coverage No coveralls.
            OpenTravelData (OPTD) Data Wrapper - Python Bindings
====================================================

[![Docker Repository on Quay](https://quay.io/repository/opentraveldata/quality-assurance/status "Docker Repository on Quay")](https://quay.io/repository/opentraveldata/quality-assurance)

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

# References
* PyPi artifacts: https://pypi.org/project/opentraveldata/
* OpenTravelData (OPTD):
  + Source code on GitHub: https://github.com/opentraveldata/opentraveldata
  + Docker Cloud repository: https://cloud.docker.com/u/opentraveldata/repository/docker/opentraveldata/quality-assurance
  + This Python-wrapper Git repository: https://github.com/opentraveldata/python-opentraveldata
* OPTD data archive:
  + POR (Points of Reference)): https://www2.transport-search.org/data/optd/por/
  + CI/CD deliveries: https://www2.transport-search.org/data/optd/cicd/
* OPTD Quality Assurance (QA):
  + Sourcce code on GitHub: https://github.com/opentraveldata/quality-assurance
  + Quality Assurance (QA) reports: https://www2.transport-search.org/data/optd/qa/

## Python
* [How-to install Python virtual environment with `pyenv` and `pipenv`](https://github.com/machine-learning-helpers/induction-python/tree/master/installation/virtual-env)
* [How to package modules for Python](https://packaging.python.org/tutorials/packaging-projects/)
* PyPi - Deployment with Travis CI
  + [PyPi Travis CI provider](https://github.com/travis-ci/dpl#pypi)
  + [dpl v2](https://blog.travis-ci.com/2019-08-27-deployment-tooling-dpl-v2-preview-release)
  + [dpl v1](https://docs.travis-ci.com/user/deployment/pypi/)

# Usage

* Launch a Python interpreter:
```bash
$ python
```
```python
>>> 
```

* Import the `opentraveldata` library:
```python
>>> import opentraveldata
```

* Specify a variable, say `myOPTD`, as a handle on the OPTD library
  + With the default local directory for the data files,
    that is `/tmp/opentraveldata`
```python
>>> myOPTD = opentraveldata.OpenTravelData()
```
  +  If you do not have access rights for writing into that directory,
     initialize the `OpenTravelData` object with a directory on which
	 you have writing access rights:
```python
>>> myOPTD = opentraveldata.OpenTravelData(local_dir='/directory-on-which-you-have-writing-access-rights')
```

* Display some information about the `OpenTravelData` object:
```python
>>> myOPTD
OpenTravelData:
  Local IATA/ICAO POR file: /tmp/opentraveldata/optd_por_public_all.csv
  Local UN/LOCODE POR file: /tmp/opentraveldata/optd_por_unlc.csv
```

* Display the expected location of the data files
  + For the main (IATA/ICAO) POR (points of reference) data file:
```python
>>> myOPTD.localIATAPORFilepath()
'/tmp/opentraveldata/optd_por_public_all.csv'
```
  + For the UN/LOCODE POR (points of reference) data file:
```python
>>> myOPTD.localUNLCPORFilepath()
'/tmp/opentraveldata/optd_por_unlc.csv'
```

* Display the source URL of the data files
  + For the main (IATA/ICAO) POR (points of reference) data file:
```python
>>> myOPTD.iataPORFileURL()
'https://github.com/opentraveldata/opentraveldata/blob/master/opentraveldata/optd_por_public_all.csv?raw=true'
```
  + For the UN/LOCODE POR (points of reference) data file:
```python
>>> myOPTD.unlcPORFileURL()
'https://github.com/opentraveldata/opentraveldata/blob/master/opentraveldata/optd_por_unlc.csv?raw=true'
```

* Download the latest data files (to be done once in a while; it takes
  a few seconds, depending on the network bandwidth):
```python
>>> myOPTD.downloadFilesIfNeeded()
```

* Trigger an exception if the data files have not been properly downloaded:
```python
>>> myOPTD.assumeFilesExist()
```

* Check that the data files have been properly downloaded, and that their
  sizes are as expected (40 to 50 MB for the IATA/ICAO data file and 4 to 5 MB
  for the UN/LOCODE data file):
```python
>>> myOPTD.validateFileSizes()
True
```

* Display the sizes of the data files
  + In Bytes:
```python
>>> myOPTD.fileSizes()
(44432069, 4956451)
```
  + In MB:
```python
>>> myOPTD.humanFileSizes()
('42.37 MB', '4.73 MB')
```

* Display the headers of the data files
  + IATA/ICAO data file:
```python
>>> myOPTD.extractIATAPORFileHeader()
'iata_code^icao_code^faa_code^is_geonames^geoname_id^envelope_id^name^asciiname^latitude^longitude^fclass^fcode^page_rank^date_from^date_until^comment^country_code^cc2^country_name^continent_name^adm1_code^adm1_name_utf^adm1_name_ascii^adm2_code^adm2_name_utf^adm2_name_ascii^adm3_code^adm4_code^population^elevation^gtopo30^timezone^gmt_offset^dst_offset^raw_offset^moddate^city_code_list^city_name_list^city_detail_list^tvl_por_list^iso31662^location_type^wiki_link^alt_name_section^wac^wac_name^ccy_code^unlc_list^uic_list^geoname_lat^geoname_lon'
```
  + UN/LOCODE data file:
```python
>>> myOPTD.extractUNLCPORFileHeader()
'unlocode^latitude^longitude^geonames_id^iso31662_code^iso31662_name^feat_class^feat_code'
```

* Display the first few lines (here, 3 lines) of the data files:
```python
>>> myOPTD.displayFilesHead (3)
Header of the '/tmp/opentraveldata/optd_por_public_all.csv' file
iata_code,icao_code,faa_code,is_geonames,geoname_id,envelope_id,name,asciiname,latitude,longitude,fclass,fcode,page_rank,date_from,date_until,comment,country_code,cc2,country_name,continent_name,adm1_code,adm1_name_utf,adm1_name_ascii,adm2_code,adm2_name_utf,adm2_name_ascii,adm3_code,adm4_code,population,elevation,gtopo30,timezone,gmt_offset,dst_offset,raw_offset,moddate,city_code_list,city_name_list,city_detail_list,tvl_por_list,iso31662,location_type,wiki_link,alt_name_section,wac,wac_name,ccy_code,unlc_list,uic_list,geoname_lat,geoname_lon
,,,Y,11085,,Bīsheh Kolā,Bisheh Kola,36.18604,53.16789,P,PPL,,,,,IR,,Iran,Asia,35,Māzandarān,Mazandaran,,,,,,0,,1168,Asia/Tehran,3.5,4.5,3.5,2012-01-16,,,,,,C,,fa|بيشه كلا|=fa|Bīsheh Kolā|,632,Iran,IRR,IRBSM|,,,
,,,Y,14645,,Kūch Be Masjed-e Soleymān,Kuch Be Masjed-e Soleyman,31.56667,49.53333,P,PPL,,,,,IR,,Iran,Asia,15,Khuzestan,Khuzestan,,,,,,0,,424,Asia/Tehran,3.5,4.5,3.5,2012-01-16,,,,,,C,,fa|Kūch Be Masjed-e Soleymān|,632,Iran,IRR,IRQMJ|,,,
Header of the '/tmp/opentraveldata/optd_por_unlc.csv' file
unlocode,latitude,longitude,geonames_id,iso31662_code,iso31662_name,feat_class,feat_code
ADALV,42.50779,1.52109,3041563,,,P,PPLC
ADALV,42.51124,1.53358,7730819,,,S,AIRH
```

* Parse the data files and load their content into internal Python
  dictionaries:
```python
>>> myOPTD.extractPORSubsetFromOPTD()
```

* Retrieve the details for the `IEV` code:
```python
>>> import pprint as pp

>>> 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
* Reference: How-to install Python virtual environment with `pyenv`
  and `pipenv`:
  https://github.com/machine-learning-helpers/induction-python/tree/master/installation/virtual-env

* Install Pyenv, Python 3.9.6, `pip` and `pipenv`:
```bash
user@laptop$ if [ ! -d ${HOME}/.pyenv ]; then git clone https://github.com/pyenv/pyenv.git ${HOME}/.pyenv; else pushd ${HOME}/.pyenv && git pull && popd; fi
user@laptop$ cat >> ~/.bashrc << _EOF
# Python
# git clone https://github.com/pyenv/pyenv.git \${HOME}/.pyenv
export PATH="\${HOME}/.pyenv/shims:\${PATH}"
eval "\$(pyenv init -)"
eval "\$(pipenv --completion)"
 
_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
* Encrypt the PyPi API token with the Travis command-line utility,
  which stores the encrypted `secret` token. As the project is managed
  by `travis-ci.com`, the `--com` option has to be added in the command-line:
```bash
user@laptop$ travis encrypt pypi-NotARealKey_Xo -add deploy.password --com
user@laptop$ git add .travis.yml
```

# Package and release the Python module
* Launch the `setup.py` script:
```bash
user@laptop$ rm -rf dist && mkdir dist
user@laptop$ pipenv run python setup.py sdist bdist_wheel
running sdist
running egg_info
creating opentraveldata.egg-info
...
running check
creating opentraveldata-0.0.9
...
creating dist
Creating tar archive
removing 'opentraveldata-0.0.9' (and everything under it)
running bdist_wheel
...
creating build
...
installing to build/bdist.macosx-10.15-x86_64/wheel
running install
running install_lib
...
running install_egg_info
adding 'opentraveldata/__init__.py'
adding 'opentraveldata/csvwriter.py'
adding 'opentraveldata/opentraveldata.py'
adding 'opentraveldata-0.0.9.dist-info/METADATA'
adding 'opentraveldata-0.0.9.dist-info/WHEEL'
adding 'opentraveldata-0.0.9.dist-info/top_level.txt'
adding 'opentraveldata-0.0.9.dist-info/RECORD'
removing build/bdist.macosx-11.1-x86_64/wheel

user@laptop$ ls -lFh dist/
total 136
-rw-r--r--  1 user  staff 14K Aug  5 18:52 opentraveldata-0.0.9-py3-none-any.whl
-rw-r--r--  1 user  staff 52K Aug  5 18:52 opentraveldata-0.0.9.tar.gz
```

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

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
* Launch the test:
```bash
$ pipenv run pytest test_optd-csvwriter.py
======================= test session starts =============================
platform darwin -- Python 3.9.5, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
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 _____________________________
```

## 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 :)

```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "opentraveldata",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "packaging, package, dependency, pyproject.toml, api, python, optd, opentraveldata",
    "author": null,
    "author_email": "Denis Arnaud <denis.arnaud_fedora@m4x.org>",
    "download_url": "https://files.pythonhosted.org/packages/fc/d6/968527c1b07f70850aea8c3fe90326bcc967d629357be03de2af2f4e9962/opentraveldata-0.0.9.post3.tar.gz",
    "platform": null,
    "description": "OpenTravelData (OPTD) Data Wrapper - Python Bindings\n====================================================\n\n[![Docker Repository on Quay](https://quay.io/repository/opentraveldata/quality-assurance/status \"Docker Repository on Quay\")](https://quay.io/repository/opentraveldata/quality-assurance)\n\nPython wrapper around OpenTravelData (OPTD) data sets, for instance\nto be used by Python software needing to access OPTD data.\n\n# References\n* PyPi artifacts: https://pypi.org/project/opentraveldata/\n* OpenTravelData (OPTD):\n  + Source code on GitHub: https://github.com/opentraveldata/opentraveldata\n  + Docker Cloud repository: https://cloud.docker.com/u/opentraveldata/repository/docker/opentraveldata/quality-assurance\n  + This Python-wrapper Git repository: https://github.com/opentraveldata/python-opentraveldata\n* OPTD data archive:\n  + POR (Points of Reference)): https://www2.transport-search.org/data/optd/por/\n  + CI/CD deliveries: https://www2.transport-search.org/data/optd/cicd/\n* OPTD Quality Assurance (QA):\n  + Sourcce code on GitHub: https://github.com/opentraveldata/quality-assurance\n  + Quality Assurance (QA) reports: https://www2.transport-search.org/data/optd/qa/\n\n## Python\n* [How-to install Python virtual environment with `pyenv` and `pipenv`](https://github.com/machine-learning-helpers/induction-python/tree/master/installation/virtual-env)\n* [How to package modules for Python](https://packaging.python.org/tutorials/packaging-projects/)\n* PyPi - Deployment with Travis CI\n  + [PyPi Travis CI provider](https://github.com/travis-ci/dpl#pypi)\n  + [dpl v2](https://blog.travis-ci.com/2019-08-27-deployment-tooling-dpl-v2-preview-release)\n  + [dpl v1](https://docs.travis-ci.com/user/deployment/pypi/)\n\n# Usage\n\n* Launch a Python interpreter:\n```bash\n$ python\n```\n```python\n>>> \n```\n\n* Import the `opentraveldata` library:\n```python\n>>> import opentraveldata\n```\n\n* Specify a variable, say `myOPTD`, as a handle on the OPTD library\n  + With the default local directory for the data files,\n    that is `/tmp/opentraveldata`\n```python\n>>> myOPTD = opentraveldata.OpenTravelData()\n```\n  +  If you do not have access rights for writing into that directory,\n     initialize the `OpenTravelData` object with a directory on which\n\t you have writing access rights:\n```python\n>>> myOPTD = opentraveldata.OpenTravelData(local_dir='/directory-on-which-you-have-writing-access-rights')\n```\n\n* Display some information about the `OpenTravelData` object:\n```python\n>>> myOPTD\nOpenTravelData:\n  Local IATA/ICAO POR file: /tmp/opentraveldata/optd_por_public_all.csv\n  Local UN/LOCODE POR file: /tmp/opentraveldata/optd_por_unlc.csv\n```\n\n* Display the expected location of the data files\n  + For the main (IATA/ICAO) POR (points of reference) data file:\n```python\n>>> myOPTD.localIATAPORFilepath()\n'/tmp/opentraveldata/optd_por_public_all.csv'\n```\n  + For the UN/LOCODE POR (points of reference) data file:\n```python\n>>> myOPTD.localUNLCPORFilepath()\n'/tmp/opentraveldata/optd_por_unlc.csv'\n```\n\n* Display the source URL of the data files\n  + For the main (IATA/ICAO) POR (points of reference) data file:\n```python\n>>> myOPTD.iataPORFileURL()\n'https://github.com/opentraveldata/opentraveldata/blob/master/opentraveldata/optd_por_public_all.csv?raw=true'\n```\n  + For the UN/LOCODE POR (points of reference) data file:\n```python\n>>> myOPTD.unlcPORFileURL()\n'https://github.com/opentraveldata/opentraveldata/blob/master/opentraveldata/optd_por_unlc.csv?raw=true'\n```\n\n* Download the latest data files (to be done once in a while; it takes\n  a few seconds, depending on the network bandwidth):\n```python\n>>> myOPTD.downloadFilesIfNeeded()\n```\n\n* Trigger an exception if the data files have not been properly downloaded:\n```python\n>>> myOPTD.assumeFilesExist()\n```\n\n* Check that the data files have been properly downloaded, and that their\n  sizes are as expected (40 to 50 MB for the IATA/ICAO data file and 4 to 5 MB\n  for the UN/LOCODE data file):\n```python\n>>> myOPTD.validateFileSizes()\nTrue\n```\n\n* Display the sizes of the data files\n  + In Bytes:\n```python\n>>> myOPTD.fileSizes()\n(44432069, 4956451)\n```\n  + In MB:\n```python\n>>> myOPTD.humanFileSizes()\n('42.37 MB', '4.73 MB')\n```\n\n* Display the headers of the data files\n  + IATA/ICAO data file:\n```python\n>>> myOPTD.extractIATAPORFileHeader()\n'iata_code^icao_code^faa_code^is_geonames^geoname_id^envelope_id^name^asciiname^latitude^longitude^fclass^fcode^page_rank^date_from^date_until^comment^country_code^cc2^country_name^continent_name^adm1_code^adm1_name_utf^adm1_name_ascii^adm2_code^adm2_name_utf^adm2_name_ascii^adm3_code^adm4_code^population^elevation^gtopo30^timezone^gmt_offset^dst_offset^raw_offset^moddate^city_code_list^city_name_list^city_detail_list^tvl_por_list^iso31662^location_type^wiki_link^alt_name_section^wac^wac_name^ccy_code^unlc_list^uic_list^geoname_lat^geoname_lon'\n```\n  + UN/LOCODE data file:\n```python\n>>> myOPTD.extractUNLCPORFileHeader()\n'unlocode^latitude^longitude^geonames_id^iso31662_code^iso31662_name^feat_class^feat_code'\n```\n\n* Display the first few lines (here, 3 lines) of the data files:\n```python\n>>> myOPTD.displayFilesHead (3)\nHeader of the '/tmp/opentraveldata/optd_por_public_all.csv' file\niata_code,icao_code,faa_code,is_geonames,geoname_id,envelope_id,name,asciiname,latitude,longitude,fclass,fcode,page_rank,date_from,date_until,comment,country_code,cc2,country_name,continent_name,adm1_code,adm1_name_utf,adm1_name_ascii,adm2_code,adm2_name_utf,adm2_name_ascii,adm3_code,adm4_code,population,elevation,gtopo30,timezone,gmt_offset,dst_offset,raw_offset,moddate,city_code_list,city_name_list,city_detail_list,tvl_por_list,iso31662,location_type,wiki_link,alt_name_section,wac,wac_name,ccy_code,unlc_list,uic_list,geoname_lat,geoname_lon\n,,,Y,11085,,B\u012bsheh Kol\u0101,Bisheh Kola,36.18604,53.16789,P,PPL,,,,,IR,,Iran,Asia,35,M\u0101zandar\u0101n,Mazandaran,,,,,,0,,1168,Asia/Tehran,3.5,4.5,3.5,2012-01-16,,,,,,C,,fa|\u0628\u064a\u0634\u0647 \u0643\u0644\u0627|=fa|B\u012bsheh Kol\u0101|,632,Iran,IRR,IRBSM|,,,\n,,,Y,14645,,K\u016bch Be Masjed-e Soleym\u0101n,Kuch Be Masjed-e Soleyman,31.56667,49.53333,P,PPL,,,,,IR,,Iran,Asia,15,Khuzestan,Khuzestan,,,,,,0,,424,Asia/Tehran,3.5,4.5,3.5,2012-01-16,,,,,,C,,fa|K\u016bch Be Masjed-e Soleym\u0101n|,632,Iran,IRR,IRQMJ|,,,\nHeader of the '/tmp/opentraveldata/optd_por_unlc.csv' file\nunlocode,latitude,longitude,geonames_id,iso31662_code,iso31662_name,feat_class,feat_code\nADALV,42.50779,1.52109,3041563,,,P,PPLC\nADALV,42.51124,1.53358,7730819,,,S,AIRH\n```\n\n* Parse the data files and load their content into internal Python\n  dictionaries:\n```python\n>>> myOPTD.extractPORSubsetFromOPTD()\n```\n\n* Retrieve the details for the `IEV` code:\n```python\n>>> import pprint as pp\n\n>>> pp.pprint (myOPTD.getServingPORList ('IEV'))\n    {'original': {'adm1_code': '12',\n              'adm1_name_utf': 'Kyiv City',\n              'country_code': 'UA',\n              'country_name': 'Ukraine',\n              'envelope_id': '',\n              'geoname_id': 703448,\n              'iata_code': 'IEV',\n              'location_type': 'C',\n              'name': 'Kyiv'},\n    'tvl_list': [{'adm1_code': '12',\n               'adm1_name_utf': 'Kyiv City',\n               'country_code': 'UA',\n               'country_name': 'Ukraine',\n               'envelope_id': '',\n               'geoname_id': 6300960,\n               'iata_code': 'IEV',\n               'location_type': 'A',\n               'name': 'Kyiv Zhuliany International Airport'},\n              {'adm1_code': '13',\n               'adm1_name_utf': 'Kyiv',\n               'country_code': 'UA',\n               'country_name': 'Ukraine',\n               'envelope_id': '',\n               'geoname_id': 6300952,\n               'iata_code': 'KBP',\n               'location_type': 'A',\n               'name': 'Kyiv Boryspil International Airport'},\n              {'adm1_code': '13',\n               'adm1_name_utf': 'Kyiv',\n               'country_code': 'UA',\n               'country_name': 'Ukraine',\n               'envelope_id': '',\n               'geoname_id': 8260936,\n               'iata_code': 'QOF',\n               'location_type': 'B',\n               'name': 'Darnytsia Bus Station'},\n              {'adm1_code': '',\n               'adm1_name_utf': '',\n               'country_code': 'UA',\n               'country_name': 'Ukraine',\n               'envelope_id': '',\n               'geoname_id': 0,\n               'iata_code': 'QOH',\n               'location_type': 'B',\n               'name': 'Kiev UA Hotel Rus'}]}\n```\n\n# Installation - configuration\n\n## Python\n* Reference: How-to install Python virtual environment with `pyenv`\n  and `pipenv`:\n  https://github.com/machine-learning-helpers/induction-python/tree/master/installation/virtual-env\n\n* Install Pyenv, Python 3.9.6, `pip` and `pipenv`:\n```bash\nuser@laptop$ if [ ! -d ${HOME}/.pyenv ]; then git clone https://github.com/pyenv/pyenv.git ${HOME}/.pyenv; else pushd ${HOME}/.pyenv && git pull && popd; fi\nuser@laptop$ cat >> ~/.bashrc << _EOF\n# Python\n# git clone https://github.com/pyenv/pyenv.git \\${HOME}/.pyenv\nexport PATH=\"\\${HOME}/.pyenv/shims:\\${PATH}\"\neval \"\\$(pyenv init -)\"\neval \"\\$(pipenv --completion)\"\n \n_EOF\nuser@laptop$ . ~/.bashrc\nuser@laptop$ pyenv install 3.9.6 && pyenv global 3.9.6 && pip install -U pip pipenv && pyenv global\n```\n\n* Clone the Git repository and install the Python virtual environment\n  (with `pipenv`):\n```bash\nuser@laptop$ mkdir -p ~/dev/geo && \\\n  git clone https://github.com/opentraveldata/python-opentraveldata.git ~/dev/geo/python-opentraveldata\nuser@laptop$ cd ~/dev/geo/python-opentraveldata\nuser@laptop$ pipenv --rm && pipenv install && pipenv install --dev\nuser@laptop$ pipenv shell\n(python-opentraveldata-BScCAakO)$ python --version\nPython 3.9.6\n(python-opentraveldata-BScCAakO)$ exit\n```\n\n## PyPi credentials for Travis deployment\n* Encrypt the PyPi API token with the Travis command-line utility,\n  which stores the encrypted `secret` token. As the project is managed\n  by `travis-ci.com`, the `--com` option has to be added in the command-line:\n```bash\nuser@laptop$ travis encrypt pypi-NotARealKey_Xo -add deploy.password --com\nuser@laptop$ git add .travis.yml\n```\n\n# Package and release the Python module\n* Launch the `setup.py` script:\n```bash\nuser@laptop$ rm -rf dist && mkdir dist\nuser@laptop$ pipenv run python setup.py sdist bdist_wheel\nrunning sdist\nrunning egg_info\ncreating opentraveldata.egg-info\n...\nrunning check\ncreating opentraveldata-0.0.9\n...\ncreating dist\nCreating tar archive\nremoving 'opentraveldata-0.0.9' (and everything under it)\nrunning bdist_wheel\n...\ncreating build\n...\ninstalling to build/bdist.macosx-10.15-x86_64/wheel\nrunning install\nrunning install_lib\n...\nrunning install_egg_info\nadding 'opentraveldata/__init__.py'\nadding 'opentraveldata/csvwriter.py'\nadding 'opentraveldata/opentraveldata.py'\nadding 'opentraveldata-0.0.9.dist-info/METADATA'\nadding 'opentraveldata-0.0.9.dist-info/WHEEL'\nadding 'opentraveldata-0.0.9.dist-info/top_level.txt'\nadding 'opentraveldata-0.0.9.dist-info/RECORD'\nremoving build/bdist.macosx-11.1-x86_64/wheel\n\nuser@laptop$ ls -lFh dist/\ntotal 136\n-rw-r--r--  1 user  staff 14K Aug  5 18:52 opentraveldata-0.0.9-py3-none-any.whl\n-rw-r--r--  1 user  staff 52K Aug  5 18:52 opentraveldata-0.0.9.tar.gz\n```\n\n* Upload/release the Python packages onto the\n  [PyPi test repository](https://test.pypi.org):\n```bash\nuser@laptop$ PYPIURL=\"https://test.pypi.org\"\nuser@laptop$ pipenv run twine upload -u __token__ --repository-url ${PYPIURL}/legacy/ dist/*\nUploading distributions to https://test.pypi.org/legacy/\nUploading opentraveldata-0.0.9-py3-none-any.whl\n100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 23.7k/23.7k [00:01<00:00, 13.5kB/s]\nUploading opentraveldata-0.0.9.tar.gz\n100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 44.3k/44.3k [00:01<00:00, 41.2kB/s]\n\nView at: https://test.pypi.org/project/opentraveldata/0.0.9/\n```\n\n* Upload/release the Python packages onto the\n  [PyPi repository](https://pypi.org):\n```bash\nuser@laptop$ PYPIURL=\"https://pypi.org\"\nuser@laptop$ pipenv run keyring set ${PYPIURL}/ __token__\nPassword for '__token__' in '${PYPIURL}/':\nuser@laptop$ pipenv run twine upload -u __token__ --non-interactive dist/*\nUploading distributions to https://upload.pypi.org/legacy/\nUploading opentraveldata-0.0.9-py3-none-any.whl\n100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 23.7k/23.7k [00:01<00:00, 15.2kB/s]\nUploading opentraveldata-0.0.9.tar.gz\n100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 44.3k/44.3k [00:01<00:00, 44.7kB/s]\n\nView at:\nhttps://pypi.org/project/opentraveldata/0.0.9/\n```\n\n# Test the Python module\n\n## Pytest\n* Launch the test:\n```bash\n$ pipenv run pytest test_optd-csvwriter.py\n======================= test session starts =============================\nplatform darwin -- Python 3.9.5, pytest-5.3.5, py-1.8.1, pluggy-0.13.1\nrootdir: ~/dev/geo/python-opentraveldata\ncollected 3 items                                                     \n\ntest_optd-csvwriter.py .                                           [ 33%]\ntest_optd-serving-por.py ..                                        [100%]\n\n=============================== 3 passed in 2.58s =======================\n_________________________________ summary _____________________________\n```\n\n## Tox\n\n```bash\n$ pipenv run tox\n.package recreate: ~/dev/geo/python-opentraveldata/.tox/.package\n.package installdeps: setuptools >= 35.0.2, setuptools_scm >= 2.0.0, <3\npy39 create: ~/dev/geo/python-opentraveldata/.tox/py39\npy39 installdeps: pytest\npy39 inst: ~/dev/geo/python-opentraveldata/.tox/.tmp/package/1/opentraveldata-0.0.9.tar.gz\npy39 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\npy39 run-test-pre: PYTHONHASHSEED='3773488260'\npy39 run-test: commands[0] | pytest\n======================= test session starts =============================\nplatform darwin -- Python 3.9.5, pytest-5.3.5, py-1.8.1, pluggy-0.13.1\ncachedir: .tox/py39/.pytest_cache\nrootdir: ~/dev/geo/python-opentraveldata\ncollected 3 items                                                     \n\ntest_optd-csvwriter.py .                                           [ 33%]\ntest_optd-serving-por.py ..                                        [100%]\n\n=============================== 3 passed in 2.58s =======================\n_________________________________ summary _____________________________\n  py39: commands succeeded\n  congratulations :)\n\n```\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simple Python wrapper for OpenTravelata (OPTD)",
    "version": "0.0.9.post3",
    "project_urls": {
        "documentation": "https://github.com/opentraveldata/python-opentraveldata",
        "homepage": "https://github.com/opentraveldata/python-opentraveldata",
        "repository": "https://github.com/opentraveldata/python-opentraveldata"
    },
    "split_keywords": [
        "packaging",
        " package",
        " dependency",
        " pyproject.toml",
        " api",
        " python",
        " optd",
        " opentraveldata"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f507676d3b495d887076c9b450c7bb0322d2eba31e14e1ffd5e2ed511f0e22ab",
                "md5": "397c007ea35abd33246cf4ded2e5b857",
                "sha256": "66dd0f1d227f05bab1300f11a338811659102c0370b8277397436607ab8dfd22"
            },
            "downloads": -1,
            "filename": "opentraveldata-0.0.9.post3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "397c007ea35abd33246cf4ded2e5b857",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14544,
            "upload_time": "2024-04-04T21:21:49",
            "upload_time_iso_8601": "2024-04-04T21:21:49.305069Z",
            "url": "https://files.pythonhosted.org/packages/f5/07/676d3b495d887076c9b450c7bb0322d2eba31e14e1ffd5e2ed511f0e22ab/opentraveldata-0.0.9.post3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fcd6968527c1b07f70850aea8c3fe90326bcc967d629357be03de2af2f4e9962",
                "md5": "8d04803f3afca4e7cacfa2b877c50020",
                "sha256": "96005be4baadaf7d1c35138e53445e2d6234728018c0e58dc679f67ad050610f"
            },
            "downloads": -1,
            "filename": "opentraveldata-0.0.9.post3.tar.gz",
            "has_sig": false,
            "md5_digest": "8d04803f3afca4e7cacfa2b877c50020",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 17526,
            "upload_time": "2024-04-04T21:21:51",
            "upload_time_iso_8601": "2024-04-04T21:21:51.444251Z",
            "url": "https://files.pythonhosted.org/packages/fc/d6/968527c1b07f70850aea8c3fe90326bcc967d629357be03de2af2f4e9962/opentraveldata-0.0.9.post3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-04 21:21:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opentraveldata",
    "github_project": "python-opentraveldata",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "datetime",
            "specs": [
                [
                    "==",
                    "5.2"
                ]
            ]
        },
        {
            "name": "pytz",
            "specs": [
                [
                    "==",
                    "2023.3.post1"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "==",
                    "68.2.2"
                ]
            ]
        },
        {
            "name": "zope.interface",
            "specs": [
                [
                    "==",
                    "6.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "opentraveldata"
}
        
Elapsed time: 0.24464s