ConfigParser class Dialect
The ConfigParser class is used throughout the project. It assumes and understands a specific dialect, hence it's vital to know it and understand it.
Below are the concepts of that dialect:
-
all configuration elements passed to the
ConfigParserclass are bundled in a list, -
all configuration elements are case-sensitive,
-
if an element is
str, it is the name of an element, -
if an element is
dict, the key is treated as the name of the element and the value is simply a configuration for this element, -
the
allitem is equal to all items from the valid configuration elements, -
an empty list is the same as the list containing only the
allitem, -
excluding elements are supported by prefixing an item with an exclamation mark, for example,
'!config'will skip the'config'element.These elements are called
not-elements. They are useful when combined withall. For example: a list of:['all', '!tcp']or simply['!tcp']would take all valid elements except fortcp.Having that said:
-
a list containing only
not-elements is treated as if'all'would have been specified explicitly, -
order does not matter,
-
you can override elements implicitly specified with
all. This means that:- when:
-
the following list is passed:
- Python
- YAML
[
'all',
{ 'content_version': {
'version': '1234-5678'}
}
]- all
- content_version:
version: '1234-5678' -
content_versionis a valid element
-
- then:
allis expanded to all valid elements butcontent_versionis skipped during expansion (since an explicit definition for it is already available).
- when: