Skip to main content

epochs

https://img.shields.io/pypi/v/epochs.svg https://img.shields.io/travis/mgalloy/epochs.svg Documentation Status Updates

Python package to handle configuration files specifying values changing over time

Features

The main features of epochs are:

  • Parse date-based configuration files and retrieve values based on datetime.

  • Validate configuration files, both normal and epoch date-based ones, against a specification.

For example, for a configuration file, epochs.cfg, such as:

[2019-04-09 20:27:15]
value   : 3

[2019-04-09 22:31:01]
value   : 5

The dates can be anything parsed by dateutil.parser.parse. Then, epochs can retrieve the correct value from the config file corresponding to a given date:

>>> import epochs
>>> ep = epochs.parse('epochs.cfg')
>>> value = ep.get('value', datetime='2019-04-09 21:55:45')
>>> print(value)
3
>>> value = ep.get('value', datetime='2019-04-09 23:15:40')
>>> print(value)
5

The “correct” value is the one specified in the earliest section of the configuration file with a date on or before the given date.

Below is an example specification for a configuration file:

[city]
name    : required=True, type=str
streets : required=True, type=List[str]
temp    : required=False, type=float, default=0.0

And an example configuration file following this specification:

[city]
name    : Boulder
streets : [Broadway, Baseline, Valmont]

Then to parse the configuration file with its specification:

>>> import epochs
>>> cf = epochs.parse('example.cfg', spec='spec.cfg')
>>> name = cf.get('name', section='city')
>>> print(name)
Boulder
>>> streets = cf.get('streets', section='city')
>>> print(steets)
['Broadway', 'Baseline', 'Valmont']
>>> temp = cf.get('temp', section='city')
>>> print(temp, type(temp))
0.0 <class 'float'>

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2019-04-12)

  • initial creation

0.1.1 (2019-04-19)

  • basic config parser with specification file

0.1.2 (2019-04-19)

  • better repr and str representations

0.2.0 (2019-04-22)

  • basic epoch parser

Download files

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

Source Distribution

epochs-0.2.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

epochs-0.2.0-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file epochs-0.2.0.tar.gz.

File metadata

  • Download URL: epochs-0.2.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for epochs-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8a41bc8424014700309cc4e824c7c2c620134b61a9aa032736c4cd49d6d65d83
MD5 6ab7c9a43a17d39ada7f646c2de24880
BLAKE2b-256 504b867078a9f95e58a7d0a873ed25c7bd30fe2f08367b0f114823e4d2df2c0d

See more details on using hashes here.

File details

Details for the file epochs-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: epochs-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for epochs-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4fba2abe7dec700219f79c5438950dad28ec3223d75bc1c587aff2564c07df68
MD5 7d2e2aad838c25d771311b2143d04be2
BLAKE2b-256 7e6bed521178ed38efe996d27e64a1c71c90b0d9a7f2a16afcd69b51882e64b3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Supported by

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