Logger¶
-
class
logger.
Logger
(logging_file_name='logging.conf', logger_name='console_only_logger', log_file_name='base', logger_level='WARNING', reset_stream=False) Bases:
object
General logger
EPJSON¶
-
class
epjson_handler.
EPJSON
(no_schema=False, logger_level='WARNING', logger_name='console_only_logger', reset_stream=False) Bases:
logger.Logger
Handle epJSON and JSON specific tasks
- Attributes:
Validator: schema validator from jsonschema
schema: loaded schema. Only validated schemas will be loaded.
input_epjson: input epjson file
schema_is_valid: initialized as None. False if failed, True if passed.
input_epjson_is_valid: initialized as None. False if failed, True if passed.
-
static
epjson_genexp
(epjson) Create generator of individual epJSON objects in epJSON format from a dictionary of objects in epJSON format.
{object_type: {object_name: object_fields}, {…}} -> {object_type: {object_name: object_fields}}, {…}
- Parameters
epjson – epJSON object
- Returns
generator which returns one unique object in epJSON format for each object in an object_type.
-
epjson_process
(epjson_ref) Default loading and verification of epJSON file :param epjson_ref: epJSON in dictionary format or file location. :return: initialized class attributes and input_epJSON object
-
get_epjson_objects
(epjson: dict, object_type_regexp: str = '.*', object_name_regexp: str = '.*') → dict Get objects from epJSON dictionary after filtering by object type and name.
- Parameters
epjson – epJSON formatted Dictionary to scan
object_type_regexp – regular expression to match with object type
object_name_regexp – regular expression to match with object_name
- Returns
epJSON dictionary of matched objects.
-
static
merge_epjson
(super_dictionary: dict, object_dictionary: dict, unique_name_override: bool = False, unique_name_fail: bool = True) Merge a high level formatted dictionary with a sub-dictionary, both in epJSON format
- Parameters
super_dictionary – high level dictionary used as the base object
object_dictionary – dictionary to merge into base object
unique_name_override – allow a duplicate unique name to overwrite an existing object
unique_name_fail – if override is set to False, choose whether to skip object or fail
- Returns
merged output of the two input dictionaries. Note, the super_dictionary is modified in this operation. A copy operation was not performed intentionally. If the user wants the original super_dictionary to remain unchanged then a copy.deepcopy() should be performed before running the function.
-
static
purge_epjson
(epjson, purge_dictionary=None) Remove objects in an input epJSON object. :param epjson: input epJSON :param purge_dictionary: key-value pair of object_type and list of regular expressions to remove items
(.* removes all objects)
- Returns
epJSON with items referenced in purge_dictionary removed.
-
static
summarize_epjson
(epjson) Provide summary of epJSON dictionary for comparisons and metrics.
- Parameters
epjson – epJSON formatted dictionary
- Returns
dictionary of count summaries
-
validate_epjson
(epjson) Validate json object as epJSON. Return object if valid
- Parameters
epjson – epJSON object
- Returns
validated epJSON object