In [1]:
import burin

Config files with specifications


In [ ]:


In [ ]:


In [ ]:

Epoch files

Epoch files are config files which specify a set of options repeatedly on different date/times, represented by sections of the config file. When a value for an option for a given date is requested, the value in the last epoch (section) before the given date is returned.

All options do not need to be set in each epoch. Values are inherited from epoch to epoch in chronological order.

Epoch files have a specification for each option -- a type and default value.


In [6]:
%cat epochs_spec.cfg


[DEFAULT]
nx            : type=int, default=1024
ny            : type=int, default=1024

cal_version   : type=int, default=0

In [5]:
%cat epochs.cfg


[20180101]
cal_version   : 1

[20180101.080000]
cal_version   : 2

[20180102.080000]
cal_version   : 3

Specify an epoch parser with an epoch filename and the specification filename.


In [8]:
ep = burin.config.EpochParser('epochs.cfg', 'epochs_spec.cfg')

In [9]:
ep.is_valid()


Out[9]:
True

In [12]:
ep.get('cal_version', date='20180101')


Out[12]:
1

In [13]:
ep.get('cal_version', date='20180101.120000')


Out[13]:
2

In [ ]: