salt.serializers.yaml

salt.serializers.yaml

Implements YAML serializer.

Underneath, it is based on pyyaml and use the safe dumper and loader. It also use C bindings if they are available.

salt.serializers.yaml.BaseDumper

alias of yaml.cyaml.CSafeDumper

salt.serializers.yaml.BaseLoader

alias of yaml.cyaml.CSafeLoader

exception salt.serializers.yaml.ConstructorError(context=None, context_mark=None, problem=None, problem_mark=None, note=None)
exception salt.serializers.yaml.DeserializationError(message, line_num=None, buf='', marker='    <======================', trace=None)

Raised when stream of string failed to be deserialized

class salt.serializers.yaml.Dumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)

Overwrites Dumper as not for pollute legacy Dumper

yaml_multi_representers = {<class 'salt.serializers.yaml.EncryptedString'>: <function EncryptedString.yaml_dumper>, <class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'tuple'>: <function SafeRepresenter.represent_list>, <class 'dict'>: <function SafeRepresenter.represent_dict>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, None: <function SafeRepresenter.represent_undefined>, <class 'salt.utils.odict.OrderedDict'>: <function SafeRepresenter.represent_dict>}
class salt.serializers.yaml.EncryptedString
static yaml_constructor(loader, tag, node)
static yaml_dumper(dumper, data)
yaml_tag = '!encrypted'
class salt.serializers.yaml.Loader(stream)

Overwrites Loader as not for pollute legacy Loader

yaml_multi_constructors = {'!encrypted': <function EncryptedString.yaml_constructor>, 'tag:yaml.org,2002:binary': <function SafeConstructor.construct_yaml_binary>, 'tag:yaml.org,2002:bool': <function SafeConstructor.construct_yaml_bool>, 'tag:yaml.org,2002:float': <function SafeConstructor.construct_yaml_float>, 'tag:yaml.org,2002:int': <function SafeConstructor.construct_yaml_int>, 'tag:yaml.org,2002:map': <function SafeConstructor.construct_yaml_map>, 'tag:yaml.org,2002:null': <function SafeConstructor.construct_yaml_null>, 'tag:yaml.org,2002:omap': <function SafeConstructor.construct_yaml_omap>, 'tag:yaml.org,2002:pairs': <function SafeConstructor.construct_yaml_pairs>, 'tag:yaml.org,2002:seq': <function SafeConstructor.construct_yaml_seq>, 'tag:yaml.org,2002:set': <function SafeConstructor.construct_yaml_set>, 'tag:yaml.org,2002:str': <function SafeConstructor.construct_yaml_str>, 'tag:yaml.org,2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>}
class salt.serializers.yaml.OrderedDict
exception salt.serializers.yaml.ScannerError(context=None, context_mark=None, problem=None, problem_mark=None, note=None)
exception salt.serializers.yaml.SerializationError(message='')

Raised when stream of string failed to be serialized

salt.serializers.yaml.deserialize(stream_or_string, **options)

Deserialize any string of stream like object into a Python data structure.

Parameters
  • stream_or_string -- stream or string to deserialize.

  • options -- options given to lower yaml module.

salt.serializers.yaml.serialize(obj, **options)

Serialize Python data to YAML.

Parameters
  • obj -- the data structure to serialize

  • options -- options given to lower yaml module.