epochs is a Python package to handle configuration files specifying values which change over time.

For example, consider a configuration file epochs.cfg containing the following:

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

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

Then value can be retrieved for various times:

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

If you provide a specification for the values in a configuration file, epochs can also validate a config file and provide values as the correct type and default value. For example, for a specification file containing:

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

Then an example configuration file following this specification:

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

Then to parse the configuration file with a 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

epochs is in PyPI. It can be installed with pip:

pip install epochs

The epochs source code is available on GitHub.