opentea.noob package¶
Submodules¶
opentea.noob.asciigraph module¶
String represeantion of a nested object
-
opentea.noob.asciigraph.
asciigraph_rec
(nob, level)¶ Pretty printing of a nested object Inputs: ———- nob : The nested object level : The initial level to start with
None
-
opentea.noob.asciigraph.
nob_asciigraph
(nob)¶ Pretty printing of a nested object Inputs: ———- nob : The nested object
None
opentea.noob.check_schema module¶
Test the structure of a schema.
The first one is for generic schema
The second is for the use of gui_forms
-
exception
opentea.noob.check_schema.
NobSchemaError
¶ Bases:
Exception
Error due to schema structure
-
opentea.noob.check_schema.
boolean_check_schema
(schema)¶ Same as check schema with a boolean output.
-
opentea.noob.check_schema.
nob_check_schema
(schema)¶ Check if a schema is valid agains opentea requirements
schema : a schema object
-
opentea.noob.check_schema.
read_serialized_data
(fname)¶ read any serialized data file
-
opentea.noob.check_schema.
rec_check_array
(schema, path)¶ Recursive check specific to arrays.
-
opentea.noob.check_schema.
rec_check_leafs
(schema, path)¶ Recursive check specific to leafs.
-
opentea.noob.check_schema.
rec_check_properties
(schema, path)¶ Recursive check specific to properties.
-
opentea.noob.check_schema.
rec_check_schema
(schema, path)¶ Recursive inference.
schema : a schema object
list_err : a list of errors encountered
-
opentea.noob.check_schema.
rec_check_xor
(schema, path)¶ Recursive check specific to exlusive or.
opentea.noob.inferdefault module¶
Infer a nested object from a schema.
-
opentea.noob.inferdefault.
avoid_string_duplication
(list_str)¶ Individualize repated string items.
-
opentea.noob.inferdefault.
infer_number
(schema)¶ Return default number if not provided by schema
-
opentea.noob.inferdefault.
nob_complete
(schema, update_data=None, only_in_schema=True)¶ Infer a nested object from a schema.
schema : a schema object update_data : nested object, providing known
parts of the object to infer
- only_in_schema :
if true the elements absent from the schema are discarded if false they are kep )
nob_out : nested object
-
opentea.noob.inferdefault.
recursive_infer
(schema, path, update_data=None, only_in_schema=True)¶ Recursive inference.
schema : a schema object update_data : nested object, providing known
parts of the object to infer
nob_out : nested object
-
opentea.noob.inferdefault.
recursive_infer_array
(schema, path, update_data=None, only_in_schema=True)¶ Recursive inference specific to arrays.
-
opentea.noob.inferdefault.
recursive_infer_leafs
(schema, update_data=None)¶ Recursive inference specific to leafs.
-
opentea.noob.inferdefault.
recursive_infer_oneof
(schema, path, update_data=None, only_in_schema=True)¶ Recursive inference specific to oneOfs.
-
opentea.noob.inferdefault.
recursive_infer_properties
(schema, path, update_data=None, only_in_schema=True)¶ Recursive inference specific to properties.
opentea.noob.noob module¶
Nested object services.
- A nested object is here:
-nested dicts -nested lists -a mix of nested lists and nested dicts
An address is a list of strings and/or integers giving a position in the nested object
Hereafter, the -address, complete or not- statement refer to an address with potentially missing elements.
EXAMPLE:@ for a dict such as : d[“a”][“b”][“c”][“d”][“e”][“f”] this the full address [ [“a”,”b”,”c”,”d”,”e”] ] can be found with either: nob_find(d, “a”,”b”,”c”,”d”,”e”) (full path) nob_find(d, “b”,”d”,”e”) (partial path) nob_find(d, “e”) (only one hint )
-
exception
opentea.noob.noob.
NobReferenceError
¶ Bases:
Exception
TO BE ADDED
-
opentea.noob.noob.
nob_del
(obj_, *keys, verbose=False)¶ Delete all matchinf addresses in the nested object. Not a deletion in place, only the output argument is cropped.
obj_ : nested object keys : address, complete or not
obj_ : nested object without the matching keys
-
opentea.noob.noob.
nob_find
(obj_, *keys)¶ Find all occurences matching a serie of keys in a nested object.
obj_ : nested object keys : address, complete or not
list of addresses matching the input address
-
opentea.noob.noob.
nob_find_unique
(obj_, *keys)¶ Find a unique occurences of a key in a nested object. Raise exceptions if problems
obj_ : nested object keys : address, complete or not
one single address matching the input address
-
opentea.noob.noob.
nob_get
(obj_, *keys, failsafe=False)¶ Access a nested object by keys.
obj_ : nested object keys : address, complete or not failsafe : what to do if the node is missing
False : raise an exception
- Truereturn None is missing
return the shortes path is several matches
- if points to a leaf:
immutable, the value stored in the leaf
- if points to a node:
mutable : the object (dict or list) found at this address
-
opentea.noob.noob.
nob_get_only_child
(obj_, *keys)¶ Return the only key of a single child dict.
-
opentea.noob.noob.
nob_merge_agressive
(base_obj, obj_to_add)¶ Merge two nested objects.
In case of conflict, the object to add is prevalent
base_obj : the initial object obj_to_add : the object to add
merged_obj : the merged dictionnaries
-
opentea.noob.noob.
nob_node_exist
(obj_, *keys)¶ Test if one node exist in a nested object
obj_ : nested object keys : address, complete or not
boolean
-
opentea.noob.noob.
nob_pprint
(obj_, max_lvl=None)¶ return a pretty print of a nested object. yaml.dump() in use for the display
obj_ : nested object max_lvel : optional : maximum nber of levels to show
out : string showing the nested_object structure
-
opentea.noob.noob.
nob_set
(obj_, value, *keys)¶ Assign a value to an object from a nested object.
obj_ : nested object keys : address, complete or not
change the object in argument (NOT STATELESS)
-
opentea.noob.noob.
str_address
(addr)¶ Return an address -key list- into a path-like string.
-
opentea.noob.noob.
unique_dict_key
(dict_)¶ Return the only key of a single child dict.
opentea.noob.schema module¶
Helper functions for schema handling
-
opentea.noob.schema.
clean_schema_addresses
(list_, udf_stages=None)¶ Clean a address from the addtitionnal layers of SCHEMA.
Used only when a SCHEMA address must be found in the data to validate
Parameters :
- list_a list of string
address in a nested dict
udf_stages : a list of additionnal user defined stages (udf) Returns : ——— list
the same list without SCHEMA intermedaite stages
opentea.noob.validate_light module¶
Lightweight validate from jsonschema
-
opentea.noob.validate_light.
validate_light
(data, schema)¶ Schema validation procedure.
data : a nested dict to validate schema : the schema to validate against (jsonschema grammar)
THIS IS NOT A BOOLEAN Only exceptions are returned if any problem, else none.
opentea.noob.validation module¶
Module to operate a trplie layer of validation
-
exception
opentea.noob.validation.
ErrorExistIf
¶ Bases:
Exception
Errors on exist if elements.
-
exception
opentea.noob.validation.
ErrorRequire
¶ Bases:
Exception
Errors on require elements.
-
exception
opentea.noob.validation.
OpenteaSchemaError
¶ Bases:
Exception
Error in OptenTea schema structure
-
opentea.noob.validation.
clean_opentea_list_item
(item_in, existing_names)¶ Add # to list elements to avoid duplication.
-
opentea.noob.validation.
main_validate
(data, schema)¶ Main validation procedure.
data : a nested dict to validate schema : the schema to validate agains (jsonschema grammar)
Only exceptions are returned if any problem
-
opentea.noob.validation.
opentea_clean_data
(nobj)¶ Check if data is opentea proof
-
opentea.noob.validation.
opentea_resolve_existif
(data, schema)¶ Validate existif dependencies.
if an item existence depends on the value of one other item
data : a nested dict to validate schema : the schema to validate against (jsonschema grammar)
data_out : a nested dict to synchronize data with require updated
-
opentea.noob.validation.
opentea_resolve_require
(data, schema, verbose=False)¶ Validate require dependencies.
if children of an item depends of the value of one other item. -tgt- is the node to update -src- is the information used to update
data : a nested dict to synchronize schema : the schema to validate against (jsonschema grammar)
data_out : a nested dict to synchronize data with require updated
-
opentea.noob.validation.
rec_validate_opentea_data
(nobj)¶ Recursive validation for opeatea structured dict
-
opentea.noob.validation.
rec_validate_schema
(schema)¶ Validate if schema is compatible with opetea structure.
-
opentea.noob.validation.
validate_array
(schema)¶ Validate an opentea multiple structure.
-
opentea.noob.validation.
validate_oneof
(schema)¶ Validate an opentea multiple structure.
-
opentea.noob.validation.
validate_opentea_schema
(schema)¶ Check if schema is OpenTEA-proof.
named items in arrays of dicts,
required optin in xors
existif and require defined