epochs package

Submodules

epochs.cli module

epochs.cli.main()[source]

epochs.configparser module

Module defining parsers. The ConfigParser is an extended configparser that can use a specification file to define types/default values for the config files options, as well as to validate the file against. The EpochParser is a parser which organizes options by date. An option value is found by matching the option in the section with the latest datetime before the given datetime.

class epochs.configparser.ConfigParser(spec_filename: str = None, inherit: str = None, **kwargs)[source]

Bases: ConfigParser

ConfigParser subclass which can verify a config file against a specification and uses types/defaults from the specification.

get(section: str, option: str, raw: bool = False, use_spec: bool = True, **kwargs) OptionValue[source]

Get an option using the type and default from the specification file

Parameters:
  • section (str) – section name

  • option (str) – option name

  • raw (bool) – set to True to not interpolate

  • use_spec (bool) – set to False to not use the specification

is_valid(allow_extra_options: bool = False) bool[source]

Verify that the ConfigParser matches the specification. A ConfigParser without a spec is automatically valid.

read(filenames, encoding=None)[source]

Read and parse a filename or an iterable of filenames.

Files that cannot be opened are silently ignored; this is designed so that you can specify an iterable of potential configuration file locations (e.g. current directory, user’s home directory, systemwide directory), and all existing configuration files in the iterable will be read. A single filename may also be given.

Return list of successfully read files.

write(file: FileType, space_around_delimiters: bool = True) None[source]

Write config file to a file-like object

Parameters:
  • file (FileType) – file-like object to write to

  • space_around_delimiters (bool) – whether to put spaces around the delimiter, i.e., “:” or “=”

class epochs.configparser.EpochConfigParser(spec_filename: str = None, **kwargs)[source]

Bases: object

EpochConfigParser parses config files with dates as section name. Retrieving an option for a given date returns the option value on the date closest, but before, the given date.

property date
property formats
get(option: str, date: DateValue = None, raw: bool = False, **kwargs) OptionValue[source]

Get an option using the type and default from the specification file

Parameters:
  • option (str) – option name

  • date (FileValue) – date as a string or datetime.datetime

  • raw (bool) – set to True is disable interpolation

is_valid(allow_extra_options: bool = False) bool[source]

Verify that the EpochParser matches the specification. A configparser without a spec is automatically valid.

read(files)[source]

Attempt to read and parse an iterable of filenames, returning a list of filenames which were successfully parsed.

write(file: FileType, space_around_delimiters: bool = True) None[source]

Write config file to a file-like object

Parameters:
  • file (FileType) – file-like object to write to

  • space_around_delimiters (bool) – whether to put spaces around the delimiter, i.e., “:” or “=”

class epochs.configparser.OptionSpec(required, type, default, list)

Bases: tuple

Specification for an option

default
list
required
type

epochs.timeline module

Module contents

Top-level package for epochs.