util module¶
DEPG Utility Library
- Various helper functions:
- addr() : Convert a coord like B37 to formulas module style
- dict_to_list(): Flatten a dict to a list
- get_cache() : Read JSON cache for quick loading
- get_config() : Read JSON config
-
util.addr(coord, sheet_name=None)[source]¶ Given a coordinate, convert to formulas style.
Parameters: - coord (str) – Coordinate like
B37 - sheet_name (str, optional) – Like PROFILE_GENERATOR, only needed if cache was not generated yet
Returns: A value like
[PROFILE_GENERATOR.XLSX]PROFILE_GENERATOR!B37Return type: str
- coord (str) – Coordinate like
-
util.dict_to_list(d)[source]¶ Flatten a dictionary to a one-dimensional list.
Parameters: d (dict) – Any one-dimensional dict, e.g. {k1: v1, k2: v2}Returns: A flattened list, e.g. [k1, v1, k2, v2]Return type: list
-
util.get_cache(xl=None, wb=None)[source]¶ Cache parts of the spreadsheet, including dropdown widgets.
The formulas spreadsheet takes a long time to load, so cache enough details to render the initial page.
If xl and wb are supplied, create or refresh cache.
Parameters: - xl (formulas.ExcelModel, optional) – The object created with the profile generator spreadsheet
- wb (openpyxl.workbook.workbook.Workbook, optional) – The internal workbook object, pulled from the xl object
Returns: cache_data – Data used to render index template
Return type: dict