utils¶
Cross module utility functions.
- 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
- 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
- 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
- utils.utilities.find_replace_multi(string, dictionary)[source]¶
Substitute every value in a dict if it matches.
- Return type:
str
- 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.
- 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
- utils.utilities.logging_level(loglevel)[source]¶
Utility function to return the logging level.
- Parameters:
loglevel – One of
INFO,WARNING,ERRORorDEBUG- Return type:
int
- utils.utilities.nested_dict()[source]¶
A recursive function that creates a default dictionary where each value is another default dictionary.
- 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