This module is the main LCONF code module
(int) the lconf base indentation (number of spaces for one indentation level)
Important
This MUST be kept at 3
(str) ___SECTION The Lconf-Section Start TAG
(str) ___END The Lconf-Section End TAG
(int) used for arguments instead of a bool if there are more options than 2
(int) used for arguments instead of a bool if there are more options than 2
(int) used for arguments instead of a bool if there are more options than 2
Extracts all LCONF-Sections from the raw string.
Parameters: | source – (raw str) which contains one or more LCONF-Sections |
---|---|
Returns: | (list) of LCONF-Sections text each inclusive the ___SECTION, ___END TAG these are not split by line but each in one txt |
Raises Err: | project error |
Extracts one LCONF-Sections from the raw string.
This will immediately return if the given section is found and not scan the whole source
Parameters: |
|
---|---|
Returns: | (str) Extracted LCONF-Sections text inclusive the ___SECTION, ___END TAG these are not split by line but all in one txt |
Raises Err: | project error e.g: if a section with section_name is not found |
Split a section raw string into lines and validate the first line
Parameters: |
|
---|---|
Returns: | (tuple) section_lines, section_name |
Raises Err: |
Validates one LCONF-Section raw string: the section must be already correctly extracted
Warning
does not validate
This does not validate correct names for Keys, Repeated Block Identifiers ect.. as implemented in the corresponding LCONF-Default-Template-Structure
It does also not validate for unique keys: Restrictions: Unique names
Validates/Checks for:
No Trailing Spaces
Most Indentation Errors: inclusive indent of Comment lines
correct Key :: Value Separators :ref:` <key_value_separator>`
number of other related checks like correct:
Parameters: | lconf_section_raw_str – raw str) which contains one extracted LCONF-Sections inclusive the Start/End Tags |
---|---|
Returns: | (bool) True if success else raises an error |
Raises Err: |
Validates a LCONF-Section raw string containing one or more LCONF-Sections This does not validate with the corresponding Section-Template classes: like correct names for: Keys, Repeated Block Identifiers ect..
IMPORTANT NOTE: this uses the function: lconf_extract_all_sections() to extract valid LCONF-Sections. If a code extracts sections in an other way the first/last line might differ
No Trailing Spaces
Most Indentation Errors: inclusive indent of Comment lines
MISSING characters after <::>
WRONG CHAR/SPACES after <::>
WRONG CHAR/SPACES before <::>
Parameters: | lconf_source – (raw str) which contains one or more LCONF-Sections |
---|---|
Returns: | (bool) True if success else raises an error |
Validates a file containing one or more LCONF-Sections This does not validate with the corresponding Section-Template classes: like correct names for: Keys, Repeated Block Identifiers ect..
IMPORTANT NOTE: this uses the function: lconf_extract_all_sections() to extract valid LCONF-Sections. If code extracts sections in an other way the first/last line might differ
No Trailing Spaces
Most Indentation Errors
Parameters: | path_to_lconf_file – (str) path to a file |
---|---|
Returns: | (bool) True if success else raises an error |
Raises Err: |
Returns a recursively copy of the lconf_section__template_obj: with the same key_order but without Default Comment/Empty Line
SeeAlso
_prepare_default_obj__with_comments(), _prepare_default_obj__no_comments()
Important
Empty-KeyValuePair-ReplacementValues
if a default Key :: Value Pair has an empty value (empty string) and a Empty-KeyValuePair-ReplacementValue is defined the lconf_prepare_default_obj will have the supplied Empty-KeyValuePair-ReplacementValue
Parameters: |
|
---|---|
Returns: | (lconf_default_obj obj) prepared copy of the lconf_section__template_obj |
Returns a new parsed lconf obj. Basically it does lconf_prepare_default_obj() and lconf_parse_section
Parameters: |
|
---|---|
Returns: | (obj) copy of the lconf_section__template_obj: attributes updated by the data in lconf_section_raw_str.
|
Returns a new parsed lconf obj. Basically it does lconf_prepare_default_obj() and lconf_parse_section_lines()
Parameters: |
|
---|---|
Returns: | (obj) copy of the lconf_section__template_obj: attributes updated by the data in lconf_section_raw_str.
|
Parses a LCONF-Section raw string already split into lines and updates the section object
SeeAlso
Note
Does not validate the section_lines for correct LCONF: e.g. indentation
Parameters: |
|
---|---|
Returns: | (obj) updated lconf_default_obj attributes updated by the data in section_lines
|
Raises Err: |
Todo
maybe try to speed up checking correct number of blocks without looping through all again
Parses a LCONF-Section raw string and updates the section object
Parameters: |
|
---|---|
Returns: | (obj) updated lconf_default_obj: attributes updated by the data in lconf_section_raw_str.
|
Parses/Extracts one LCONF-Sections from the raw string by name and returns an updated copy of the the section object
Similar to lconf_prepare_and_parse_section() but also extract the session by name - Basically it does lconf_extract_one_section_by_name(), lconf_prepare_default_obj() and lconf_parse_section()
Main usage: if one needs only one known section from the source:
- if one needs multiple sections it might be better to use lconf_extract_all_sections()
Parameters: |
|
---|---|
Returns: | (obj) copy of the lconf_section__template_obj: attributes updated by the data in lconf_section_raw_str.
|
Return a section_string from a lconf_section_obj
Note
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | (str) a LCONF text string |
||||||||
Raises Err: |
Return a section_string from a none parsed lconf_section_obj
Parameters: |
|
---|---|
Returns: |
Return a section_string from a regular dictionary as well as OrderedDict.
it is used instead of the supplied section_name
Parameters: |
|
---|---|
Returns: | (str) a LCONF text string. |
Return a recursive copy of the lconf_section_obj with Lconf objs replaced by python native objs keeping order - e.g. uses OrderedDict
e.g. useful for dumping ordered json
Parameters: | lconf_section_obj – (obj) instance of lconf section object |
---|---|
Returns: | (OrderedDict) recursive copy of the lconf_section_obj with Lconf objs replaced by python native objs |
Return a recursive copy of the lconf_section_obj with Lconf objs replaced by python native objs
e.g. useful for dumping yaml
LconfRoot, LconfKVMap, LconfBlkI, LconfBlk will be recursively copied the types will be cast to: dict
LconfKVList, LconfListOT: will be cast to: list
- LconfListOT tuple items will be cast to lists
Parameters: | lconf_section_obj – (obj) instance of lconf section object |
---|---|
Returns: | (dict) recursive copy of the lconf_section_obj with Lconf objs replaced by python native objs |