moler.parser package¶
Submodules¶
moler.parser.table_text module¶
- Last modification: adding support for EPC tables and partially empty tables changes till 23.05.2018
- added adjustements for project requirements
Commad TableText is parsing Linux Command to according to headers and columns (adjusted) For initialization it is getting 4 parameters (2 required 2 optional) Required parameters: _header_regexps –> regexp array for finding headers _header_keys –> array of keys assigned for found columns Optional parameters: _skip –> regexp for skipping line _finish –> regexp for finishing parsing (next parse execution will not give any line) Value_splitter –> value for splitting values in line by default 1+ spaces WARNING ==> in current version no special signs or spaces are allowed in Name field (header key regexp)
-
class
moler.parser.table_text.
TableText
(_header_regexps, _header_keys, _skip='', _finish='', value_splitter='\s+')¶ Bases:
object
-
build_hdr_groups
()¶ Function for building group of headers. If not enough keys defined name COL_x will be added at the end :return: regexp allowing to read headers group with column names in format (?P<name>regexp) what allows to read assign correct name for matched value
-
static
convert_data_to_type
(data)¶
-
get_value_for_header
(current_header_position, values, start_value_index)¶ Parameters: - current_header_position – matched headers positions (get with re.search(regexp, line)) for which search will take place
- values – values connected into list
- start_value_index – current start from which search will take place
Returns: Returns found value for specific header
-
parse
(data)¶ Parameters: data – accepts one parameter which is line for parsing. Without headers found it will look for it Returns: returns result dictionary according to your header regexps set during initialization returns None when nothing was found or headers when values were found
-
static
split_with_end_position
(values, data)¶ Parameters: - values – values splitted from data
- data – data full line with values in raw form
Returns: returns list of dictionary where each dict contains 2 keys ‘value’ and ‘end’ which is end position of string
-