anyconfig.parser¶
Misc simple parsers.
- anyconfig.parser.parse_single(str_)¶
Parse an expression gives a primitive value.
- Return type:
Union[str,int,float,bool]
- anyconfig.parser.parse_list(str_, sep=',')¶
Parse an expression gives a list of values.
An expression
str_might contain a list of str-es separated withsep, represents a list of primitive values.- Return type:
list[Union[str,int,float,bool]]
- anyconfig.parser.attr_val_itr(str_, avs_sep=':', vs_sep=',', as_sep=';')¶
Parse a list of atrribute and value pairs.
This is a helper function for parse_attrlist_0.
- Parameters:
str – String represents a list of pairs of attribute and value
avs_sep (
str) – char to separate attribute and valuesvs_sep (
str) – char to separate valuesas_sep (
str) – char to separate attributes
- Return type:
Iterator[tuple[str,Union[list[Union[str,int,float,bool]],str,int,float,bool]]]
- anyconfig.parser.parse_attrlist_0(str_, avs_sep=':', vs_sep=',', as_sep=';')¶
Parse a list of atrribute and value pairs.
This is a helper function for parse_attrlist.
The expressions to parse should be in the form of [ATTR1:VAL0,VAL1,…;ATTR2:VAL0,VAL2,..].
- Parameters:
str – input string
avs_sep (
str) – char to separate attribute and valuesvs_sep (
str) – char to separate valuesas_sep (
str) – char to separate attributes
- Return type:
list[tuple[str,Union[list[Union[str,int,float,bool]],str,int,float,bool]]]- Returns:
- a list of tuples of (key, value | [value])
where key = (Int | String | …), value = (Int | Bool | String | …) | [Int | Bool | String | …]
- anyconfig.parser.parse_attrlist(str_, avs_sep=':', vs_sep=',', as_sep=';')¶
Parse a list of atrribute and value pairs.
The expressions to parse should be in the form of [ATTR1:VAL0,VAL1,…;ATTR2:VAL0,VAL2,..].
- Parameters:
str – input string
avs_sep (
str) – char to separate attribute and valuesvs_sep (
str) – char to separate valuesas_sep (
str) – char to separate attributes
- Return type:
dict[str,Union[list[Union[str,int,float,bool]],str,int,float,bool]]
- anyconfig.parser.parse(str_, lsep=',', avsep=':', vssep=',', avssep=';')¶
Very simple generic parser.
- Return type:
Union[str,int,float,bool,list[Union[str,int,float,bool]],dict[str,Union[list[Union[str,int,float,bool]],str,int,float,bool]]]