Changeset - 348b82e08759
[Not reviewed]
0 3 1
Brett Smith - 7 years ago 2017-05-17 21:22:39
brettcsmith@brettcsmith.org
.gitignore: setup.py: Integrate pytest to run tests.
4 files changed with 13 insertions and 0 deletions:
0 comments (0 inline, 0 general)
.gitignore
Show inline comments
 
*.egg
 
*.egg-info/
 
.cache/
 
__pycache__/
README.rst
Show inline comments
...
 
@@ -11,24 +11,29 @@ It currently only supports OXR's "historical" API.
 
Getting started with the CLI tool
 
---------------------------------
 

	
 
oxrlib includes an `oxrquery` tool to access the OXR API directly from the command line.  By default, it reads your OXR credentials and other common configuration from `~/.config/oxrlib.ini`.  Copy `oxrlib_example.ini` from the source to `~/.config/oxrlib.ini`, then edit that file following the instructions in the comments.
 

	
 
Run `oxrquery --help` for instructions to use the tool.
 

	
 
Getting started with the library
 
--------------------------------
 

	
 
Here's an example of using the Python library, complete with caching results:
 

	
 
  from oxrlib import cache, loaders, rate
 

	
 
  filename_format = '{date}_{base}_rates.json'
 
  cache_writer = cache.CacheWriter(DIR_PATH, historical=filename_format)
 
  loader = loaders.LoaderChain()
 
  loader.add_loader(loaders.FileCache(DIR_PATH, historical=filename_format))
 
  loader.add_loader(loaders.OXRAPIRequest(APP_ID_STRING))
 
  with loader.historical(DATE, BASE_CODE_STRING) as json_response:
 
      hist_rate = rate.Rate.from_json_file(json_response)
 
  if loader.should_cache():
 
      cache_writer.save_rate(hist_rate)
 
  # Rates are available from the hist_rates.rates dict.
 

	
 
Running tests
 
-------------
 

	
 
Run `./setup.py test` from your checkout directory.
setup.cfg
Show inline comments
 
new file 100644
 
[aliases]
 
test=pytest
setup.py
Show inline comments
 
#!/usr/bin/env python3
 

	
 
from setuptools import setup
 

	
 
setup(
 
    name='oxrlib',
 
    description="Library to query the Open Exchange Rates (OXR) API",
 
    version='1.0',
 
    author='Brett Smith',
 
    author_email='brettcsmith@brettcsmith.org',
 
    license='GNU AGPLv3+',
 

	
 
    setup_requires=['pytest-runner'],
 
    tests_require=['pytest'],
 

	
 
    packages=['oxrlib'],
 
    entry_points={
 
        'console_scripts': ['oxrquery = oxrlib.__main__:main'],
 
    },
 
)
0 comments (0 inline, 0 general)