utils
Cross module utility functions.
- ocx_schema_parser.utils.utilities.camel_case_split(str)[source]
Split camel case string to individual strings.
- Return type:
List
- ocx_schema_parser.utils.utilities.current_dir(file)[source]
The full path to the folder containing the
file
- Parameters:
file – The name of an existing file
- Return type:
str
- ocx_schema_parser.utils.utilities.default_to_grid(d)[source]
Converts defaultdicts to a data grid with unique row ids.
- Parameters:
d – The dict to be converted
- Return type:
Dict
- ocx_schema_parser.utils.utilities.default_to_regular(d)[source]
Converts defaultdicts of defaultdicts to dict of dicts.
- Parameters:
d – The dict to be converted
- Return type:
Dict
- ocx_schema_parser.utils.utilities.dromedary_case_split(str)[source]
Split camel case string to individual strings.
- Return type:
List
- ocx_schema_parser.utils.utilities.find_replace_multi(string, dictionary)[source]
Substitute every value in a dict if it matches.
- Return type:
str
- ocx_schema_parser.utils.utilities.list_files_in_directory(directory, file_ext='.3docx')[source]
Utility function to list files in a directory.
- Parameters:
directory – the name of the directory.
file_ext – Only files with matching extension will be listed.
- Return type:
list
- Returns:
list of matching files.
- ocx_schema_parser.utils.utilities.load_yaml_config(config)[source]
Safely read a yaml config file and return the content as a dict.
- Parameters:
config – Path to yaml file
- Raises:
Raise errno.ENOENT if yaml file does not exist –
- Return type:
dict
- ocx_schema_parser.utils.utilities.logging_level(loglevel)[source]
Utility function to return the logging level.
- Parameters:
loglevel – One of
INFO
,WARNING
,ERROR
orDEBUG
- Return type:
int
- ocx_schema_parser.utils.utilities.nested_dict()[source]
A recursive function that creates a default dictionary where each value is another default dictionary.
- ocx_schema_parser.utils.utilities.number_table_rows(table, first_index=0)[source]
Utility function to add row numbers to the first column of a table stored as a dict.
- Parameters:
table – The input table dict
first_index – The first row index value. Default = 0
- Return type:
Dict
- Returns:
a table (dict) with numbered rows in the first column
- ocx_schema_parser.utils.utilities.resource_path(relative_path)[source]
Get absolute path to resource, works for dev and for PyInstaller