Skip to main content

Simple Python wrapper for OpenTravelata (OPTD)

Project description

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

Installation - configuration

Python

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.81 && pyenv global 3.8.1 && pip install -U pip pipenv && pyenv global system
  • Clone the Git repository and install the Python virtual environment (with pipenv):
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$ python --version
Python 3.8.1

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:
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:
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.8
...
creating dist
Creating tar archive
removing 'opentraveldata-0.0.8' (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.8.dist-info/METADATA'
adding 'opentraveldata-0.0.8.dist-info/WHEEL'
adding 'opentraveldata-0.0.8.dist-info/top_level.txt'
adding 'opentraveldata-0.0.8.dist-info/RECORD'
removing build/bdist.macosx-10.15-x86_64/wheel

user@laptop$ ls -lFh dist/
total 96
-rw-r--r--  1 user  staff  11K Mar  9 16:02 opentraveldata-0.0.8-py3-none-any.whl
-rw-r--r--  1 user  staff  32K Mar  9 16:02 opentraveldata-0.0.8.tar.gz
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.8-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████████| 23.7k/23.7k [00:01<00:00, 13.5kB/s]
Uploading opentraveldata-0.0.8.tar.gz
100%|█████████████████████████████████████████████████████████████████████| 44.3k/44.3k [00:01<00:00, 41.2kB/s]

View at: https://test.pypi.org/project/opentraveldata/0.0.8/
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.8-py3-none-any.whl
100%|██████████████████████████████████████████████████████████████████████| 23.7k/23.7k [00:01<00:00, 15.2kB/s]
Uploading opentraveldata-0.0.8.tar.gz
100%|██████████████████████████████████████████████████████████████████████| 44.3k/44.3k [00:01<00:00, 44.7kB/s]

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

Test the Python module

Pytest

  • Launch the test:
$ pipenv run pytest test_optd-csvwriter.py
======================= test session starts =============================
platform darwin -- Python 3.8.2, 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

$ pipenv run tox
.package recreate: ~/dev/geo/python-opentraveldata/.tox/.package
.package installdeps: setuptools >= 35.0.2, setuptools_scm >= 2.0.0, <3
py38 create: ~/dev/geo/python-opentraveldata/.tox/py38
py38 installdeps: pytest
py38 inst: ~/dev/geo/python-opentraveldata/.tox/.tmp/package/1/opentraveldata-0.0.8.tar.gz
py38 installed: attrs==19.3.0,certifi==2019.11.28,chardet==3.0.4,idna==2.9,more-itertools==8.2.0,opentraveldata==0.0.8,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
py38 run-test-pre: PYTHONHASHSEED='3773488260'
py38 run-test: commands[0] | pytest
======================= test session starts =============================
platform darwin -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
cachedir: .tox/py38/.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 _____________________________
  py38: commands succeeded
  congratulations :)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentraveldata-0.0.8.post1.tar.gz (40.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opentraveldata-0.0.8.post1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file opentraveldata-0.0.8.post1.tar.gz.

File metadata

  • Download URL: opentraveldata-0.0.8.post1.tar.gz
  • Upload date:
  • Size: 40.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for opentraveldata-0.0.8.post1.tar.gz
Algorithm Hash digest
SHA256 1ced4fe10e3852f6af1317510be27554dcaf8cd2b3883442c32c6248146c5a80
MD5 3a75286ee8a73b84eedfb7cd695563a8
BLAKE2b-256 f23f738f4bef110c04ad3d3090ffe6497ab6f6beaef19bcec971a272cbd75b1a

See more details on using hashes here.

File details

Details for the file opentraveldata-0.0.8.post1-py3-none-any.whl.

File metadata

  • Download URL: opentraveldata-0.0.8.post1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for opentraveldata-0.0.8.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 696b7bd2fc0139c4aa1037d4c4f912fddcfd5bf12875e6263a430a8fcd51b1ee
MD5 794d537402588b457ce45d2fecde0f56
BLAKE2b-256 b8a2f17dafd2b732608e72e8aae399ccdffcfd51697438cd4ee6229243933b60

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page