yggdrasil.metaschema package¶
Subpackages¶
- yggdrasil.metaschema.datatypes package
- Submodules
- yggdrasil.metaschema.datatypes.AnyMetaschemaType module
- yggdrasil.metaschema.datatypes.ArrayMetaschemaType module
- yggdrasil.metaschema.datatypes.ClassMetaschemaType module
- yggdrasil.metaschema.datatypes.ContainerMetaschemaType module
- yggdrasil.metaschema.datatypes.FixedMetaschemaType module
- yggdrasil.metaschema.datatypes.FunctionMetaschemaType module
- yggdrasil.metaschema.datatypes.InstanceMetaschemaType module
- yggdrasil.metaschema.datatypes.JSONArrayMetaschemaType module
- yggdrasil.metaschema.datatypes.JSONMetaschemaType module
- yggdrasil.metaschema.datatypes.JSONObjectMetaschemaType module
- yggdrasil.metaschema.datatypes.MetaschemaType module
- yggdrasil.metaschema.datatypes.MultiMetaschemaType module
- yggdrasil.metaschema.datatypes.ObjMetaschemaType module
- yggdrasil.metaschema.datatypes.PlyMetaschemaType module
- yggdrasil.metaschema.datatypes.ScalarMetaschemaType module
- yggdrasil.metaschema.datatypes.SchemaMetaschemaType module
- yggdrasil.metaschema.datatypes.conversions module
- Module contents
- yggdrasil.metaschema.properties package
- Submodules
- yggdrasil.metaschema.properties.AnyMetaschemaProperties module
- yggdrasil.metaschema.properties.ArgsMetaschemaProperty module
- yggdrasil.metaschema.properties.ArrayMetaschemaProperties module
- yggdrasil.metaschema.properties.ClassMetaschemaProperty module
- yggdrasil.metaschema.properties.DefaultProperty module
- yggdrasil.metaschema.properties.JSONArrayMetaschemaProperties module
- yggdrasil.metaschema.properties.JSONObjectMetaschemaProperties module
- yggdrasil.metaschema.properties.KwargsMetaschemaProperty module
- yggdrasil.metaschema.properties.MetaschemaProperty module
- yggdrasil.metaschema.properties.ScalarMetaschemaProperties module
- yggdrasil.metaschema.properties.TitleMetaschemaProperty module
- yggdrasil.metaschema.properties.TypeMetaschemaProperty module
- Module contents
Submodules¶
yggdrasil.metaschema.encoder module¶
- class yggdrasil.metaschema.encoder.JSONDecoder[source]¶
Bases:
rapidjson.Decoder
Decoder class for Ygg messages.
- class yggdrasil.metaschema.encoder.JSONEncoder[source]¶
Bases:
rapidjson.Encoder
Encoder class for Ygg messages.
- class yggdrasil.metaschema.encoder.JSONReadableEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
json.encoder.JSONEncoder
Encoder class for Ygg messages.
- yggdrasil.metaschema.encoder.decode_json(msg, **kwargs)[source]¶
Decode a Python object from a JSON serialization.
- yggdrasil.metaschema.encoder.decode_yaml(msg, sorted_dict_type=None, **kwargs)[source]¶
Decode a Python object from a YAML serialization.
- Parameters
- Returns
Deserialized Python object.
- Return type
- yggdrasil.metaschema.encoder.encode_json(obj, fd=None, indent=None, sort_keys=True, **kwargs)[source]¶
Encode a Python object in JSON format.
- Parameters
obj (object) – Python object to encode.
fd (file, optional) – File descriptor for file that encoded object should be written to. Defaults to None and string is returned.
indent (int, str, optional) – Indentation for new lines in encoded string. Defaults to None.
sort_keys (bool, optional) – If True, the keys will be output in sorted order. Defaults to True.
**kwargs – Additional keyword arguments are passed to json.dumps.
- Returns
Encoded object.
- Return type
- yggdrasil.metaschema.encoder.encode_yaml(obj, fd=None, indent=None, sorted_dict_type=None, **kwargs)[source]¶
Encode a Python object in YAML format.
- Parameters
obj (object) – Python object to encode.
fd (file, optional) – File descriptor for file that encoded object should be written to. Defaults to None and string is returned.
indent (int, str, optional) – Indentation for new lines in encoded string. Defaults to None.
**kwargs – Additional keyword arguments are passed to yaml.dump.
- Returns
Encoded object.
- Return type
- yggdrasil.metaschema.encoder.indent_char2int(indent)[source]¶
Convert a character indent into a number of spaces that should be used. Tabs are set to be equivalent to 4 spaces.
yggdrasil.metaschema.normalizer module¶
- class yggdrasil.metaschema.normalizer.UndefinedProperty[source]¶
Bases:
object
Class to be used as a flag for undefined properties.
- class yggdrasil.metaschema.normalizer.UninitializedNormalized[source]¶
Bases:
object
Class to be used as a flag for uninitialized normalized value.
- yggdrasil.metaschema.normalizer.create(*args, **kwargs)[source]¶
Dynamically create a validation/normalization class that subclasses the jsonschema validation class.
- Parameters
normalizers (dict, optional) – Keys are tuples representing paths that exist within the schema at which the normalization functions stored in lists as their value counterparts should be executed. Defaults to empty dictionary.
no_defaults (bool, optional) – If True, defaults will not be set during normalization. Defaults to False.
required_defaults (bool, optional) – If True, defaults will be set for required properties, even if no_defaults is True. Defaults to False.
*args – Additional arguments are passed to jsonschema.validators.create.
**kwargs – Additional keyword arguments are passed to jsonschema.validators.create.
Module contents¶
- exception yggdrasil.metaschema.MetaschemaTypeError[source]¶
Bases:
TypeError
Error that should be raised when a class encounters a type it cannot handle.
- yggdrasil.metaschema.create_metaschema(overwrite=False)[source]¶
Create the meta schema for validating ygg schema.
- Parameters
overwrite (bool, optional) – If True, the existing meta schema will be overwritten. If False and the metaschema exists, an error will be raised. Defaults to False.
- Returns
- Meta schema specifying rules for ygg type schema. This includes
all original JSON schema rules with the addition of types and property definitions.
- Return type
- Raises
RuntimeError – If the file already exists and overwrite is False.
- yggdrasil.metaschema.data2dtype(data)[source]¶
Get numpy data type for an object.
- Parameters
data (object) – Python object.
- Returns
Numpy data type.
- Return type
np.dtype
- yggdrasil.metaschema.definition2dtype(props)[source]¶
Get numpy data type for a type definition.
- Parameters
props (dict) – Type definition properties.
- Returns
Numpy data type.
- Return type
np.dtype
- yggdrasil.metaschema.get_metaschema()[source]¶
Return the meta schema for validating ygg schema.
- Returns
- Meta schema specifying rules for ygg type schema. This includes
all original JSON schema rules with the addition of types and property definitions.
- Return type
Note
This function should not be called at the module level as it can cause the metaschema (if it dosn’t exist) to be generated before all of the necessary modules have been loaded.
- yggdrasil.metaschema.get_validator(overwrite=False, normalizers=None, **kwargs)[source]¶
Return the validator that includes ygg expansion types.
- Parameters
- Returns
JSON schema validator.
- Return type
jsonschema.IValidator
- yggdrasil.metaschema.normalize_instance(obj, schema, **kwargs)[source]¶
Normalize an object using the provided schema.
- yggdrasil.metaschema.type2numpy(typedef)[source]¶
Convert a type definition into a numpy dtype.
- Parameters
typedef (dict) – Type definition.
- Returns
Numpy data type.
- Return type
np.dtype