mivot_validator.utils package
Submodules
mivot_validator.utils.dict_utils module
Code imported from SVOM Created on 29 mai 2019
@author: michel
- class mivot_validator.utils.dict_utils.DictUtils[source]
Bases:
objectstatic class processing implementing convenient operation on dictionaries
- static find_item_by_key(dictionnary, key)[source]
Look for the first dictionary item attached to key
- Parameters:
dictionary ({}) – dictionary to be explored
key (string) – searched key
- static get_fatal_value(dictionary, key)[source]
returns dictionary[key] if available and trigger a system exit otherwise.
- Parameters:
dictionary (Python Dict) – dictionary
key (string) – key of the searched value
- Returns:
the value attached to the key
- Return type:
any supported Dict value
- static get_optional_value(dictionary, key, null=None)[source]
returns dictionary[key] if available or a null value otherwise.
- Parameters:
dictionary (Python Dict) – dictionary
key (string) – key of the searched value
null (string) – value taken when the key os not available (None by default)
- Returns:
the value attached to the key or the null value
- Return type:
any supported Dict value
- static get_permanent_object(dico)[source]
This method make the object content independent of a specific run context It us used to format object in a way they can be checked in unit demo dates values are replaced with DATE and the seq_id with SEQID.
- Parameters:
dico (anything) – object to be formated
- static get_permanent_string(text)[source]
This method make the string independent of a specific run context It us used to format object in a way they can be checked in unit demo dates values are replaced with DATE and the seq_id with SEQID.
- Parameters:
text (string) – string to be formated
- static get_prefixed_keys_dict(dictionnary, prefix)[source]
Returns a copy of dict with all keys prefixed with prefix Works only art root level, no recursion.
- Parameters:
dictionnary (dict) – dict on which key prefixes must be applied
prefix (string) – prefix to be aplied to the keys
- Return type:
prefixed dict
- static get_pretty_json(dictionnary)[source]
- Returns:
A pretty string representation of the dictionary
- Return type:
Python Dict
- static get_required_value(dictionary, key)[source]
returns dictionary[key] if available and rises an exception otherwise.
- Parameters:
dictionary (Python Dict) – dictionary
key (string) – key of the searched value
- Returns:
the value attached to the key
- Return type:
any supported Dict value
- static print_pretty_json(dictionnary)[source]
- Returns:
Print out pretty string representation of the dictionary
- static read_dict_from_file(filename, fatal=False)[source]
Read a Dict in filename, rises an exception if something goes wrong.
- Parameters:
filename (string) – filename
fatal (boolean) – trigger a systeml exit if true
- Returns:
the Dict extracted from the file
- Return type:
Python Dict
- static read_dict_from_url(url, fatal=False)[source]
Read a Dict from url, rises an exception if something goes wrong.
- Parameters:
url (string) – url
fatal (boolean) – trigger a systeml exit if true
- Returns:
the Dict extracted from the file
- Return type:
Python Dict
mivot_validator.utils.json_encoder module
Created on 1 avr. 2020
@author: laurentmichel
- class mivot_validator.utils.json_encoder.MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
JSONEncoderclassdocs
- default(o)[source]
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return super().default(o)
mivot_validator.utils.json_tools module
Created on Jan 11, 2021
@author: laurentmichel
mivot_validator.utils.logger_setup module
Global logger setup Must be used by the whole application
The default format can be restored at any time with LoggerSetup.set_default_format() The log level can be set at any time with LoggerSetup.set_debug/info/warning/error_level The level is set at INFO by default
Created on 4 December 2019
@author: michel
- class mivot_validator.utils.logger_setup.LoggerSetup[source]
Bases:
objectmanage the logger setup
- static get_logger()[source]
Format and return the system logger :return : system logger :rtype: logger
mivot_validator.utils.quantity_converter module
Created on 25 Jan 2022
@author: laurentmichel
mivot_validator.utils.xml_utils module
Created on 16 Dec 2021
@author: laurentmichel
- class mivot_validator.utils.xml_utils.XmlUtils[source]
Bases:
objectclassdocs
- static assertXmltreeEqualsFile(xmltree1, xmltree2_file, message='')[source]
Compare a xml tree with a file
- static get_attribute_value_by_role(model_view, dmrole)[source]
get an attribute value by its dmrole
- static set_column_indices(mapping_block, index_map)[source]
add column ranks to attribute having a ref. Using ranks allow to identify columns even numpy raw have been serialised as []
Module contents
This package contains utility functions and classes used by the validator.