Make configuration and metadata objects immutable
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 15 May 2020 21:12:39 +0000 (17:12 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 22 May 2020 16:30:18 +0000 (12:30 -0400)
commit7f4429f296135cb942e26c019bb6ef727322ead9
treeb29d4acaf39c0762b16b29ffb30ee2b5a37ae7ef
parent79659d8e4459ec39bb7661b5b590b49839c040fc
Make configuration and metadata objects immutable

This patch changes how configuration and metadata objects are built.

Before this patch, the YAML configuration parser in `config.py` created
default metadata objects and then set their properties as it parsed the
YAML node.

Having such mutable objects means they can change at anytime once they
exist.

This patch changes this so that all configuration and metadata objects
accept all they need at construction time and do not offer setters.

`config.py` now only contains the `Config` and `ConfigOptions` classes
as well as the from_file() function. All the YAML parsing and
configuration/metadata construction is in `config_parse.py`.

In `config_parse.py`, there are mutable "pseudo" classes which
correspond to the immutable versions. They are only used during the
parsing stage and, at the end, converted to their public, immutable
equivalents.

The configuration validation is done at the YAML/pseudo level, which
means the public configuration/metadata classes do not validate anything
(narrow contract). Their constructors _should_ at least assert that
everything looks okay, but this work is not part of this patch.

No functional changes intended by this patch at the CLI level, which is
why all tests still pass without modification.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
barectf/cli.py
barectf/config.py
barectf/config_parse.py [new file with mode: 0644]
barectf/metadata.py
barectf/tsdl182gen.py
This page took 0.034179 seconds and 4 git commands to generate.