corset.serialize#
- class corset.serialize.YamlSerializableMixin#
Mixin class to add YAML serialization/deserialization to dataclasses and a few other common types.
- classmethod load_yaml(filename) Self#
Load an object from a YAML file.
If this is called from a subclass the loaded object type must match that subclass.
- Parameters:
- Return type:
Self- Returns:
The loaded object.
- Raises:
ValueError – If the YAML file does not contain a ‘data’ field.
TypeError – If the loaded object type does not match the class used to call this method.
- corset.serialize.load_yaml(filename) Self#
Load any
YamlSerializableMixininstance or basic collection containing them from a YAML file. This is an alias forYamlSerializableMixin.load_yaml().
- corset.serialize.save_yaml(self, filename) None#
Save any
YamlSerializableMixininstance or basic collection containing them to a YAML file. This is an alias forYamlSerializableMixin.save_yaml().