PyBNF configuration parsing (pybnf.parse)

Grammar and methods for parsing the configuration file

pybnf.parse.parse_normalization_chain(s)[source]

Parse a normalization value string into a canonical chain of transforms (ADR-0066, #479).

A chain is a comma-separated, ordered list of transforms; each transform is a bare token (peak) or a token with a single numeric argument (floor 0.03). Returns either a bare str – when the chain is a single argument-less token, so a legacy normalization = peak / normalization x = peak round-trips byte-identically – or a list whose elements are each a str (argument-less) or a (name, float) tuple (('floor', 0.03)). Transform-name validity is checked in config.py (which owns the “Invalid normalization type” message); this only enforces the <name> [<number>] shape and supplies a defaulted argument for a transform (floor) declared without one.

pybnf.parse.parse_normalization_def(s)[source]

Parse the complicated normalization grammar If the grammar is specified incorrectly, it will end up calling something invalid the normalization type or the exp file, and this error will be caught later.

Parameters:

s – The string following the equals sign in the normalization key

Returns:

What to write in the config dictionary: A string or a chain (list of transforms, ADR-0066) for the whole-fit form, or a dictionary {expfile: string} or {expfile: (string, index_list)} or {expfile: (string, name_list)} for the legacy per-file form