Skip to main content

Python package to handle configuration files specifying values changing over time

Project description

epochs Documentation Status Updates

Python package to handle configuration files specifying values changing over time


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)
>>> value = ep.get('value', datetime='2019-04-09 23:15:40')
>>> print(value)

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:

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:

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)
>>> 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'>


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


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

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

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

Uploaded source

Built Distribution

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

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page