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.


alias of CSafeDumper


alias of 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 ''>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, None: <function SafeRepresenter.represent_undefined>, <class 'collections.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>, ',2002:binary': <function SafeConstructor.construct_yaml_binary>, ',2002:bool': <function SafeConstructor.construct_yaml_bool>, ',2002:float': <function SafeConstructor.construct_yaml_float>, ',2002:int': <function SafeConstructor.construct_yaml_int>, ',2002:map': <function SafeConstructor.construct_yaml_map>, ',2002:null': <function SafeConstructor.construct_yaml_null>, ',2002:omap': <function SafeConstructor.construct_yaml_omap>, ',2002:pairs': <function SafeConstructor.construct_yaml_pairs>, ',2002:seq': <function SafeConstructor.construct_yaml_seq>, ',2002:set': <function SafeConstructor.construct_yaml_set>, ',2002:str': <function SafeConstructor.construct_yaml_str>, ',2002:timestamp': <function SafeConstructor.construct_yaml_timestamp>}
class salt.serializers.yaml.OrderedDict

Dictionary that remembers insertion order

clear() None.  Remove all items from od.
copy() a shallow copy of od

Create a new ordered dictionary with keys from iterable and values set to value.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
move_to_end(key, last=True)

Move an existing element to the end (or beginning if last is false).

Raise KeyError if the element does not exist.

pop(k[, d]) v, remove specified key and return the corresponding

value. If key is not found, d is returned if given, otherwise KeyError is raised.


Remove and return a (key, value) pair from the dictionary.

Pairs are returned in LIFO order if last is true or FIFO order if false.

setdefault(key, default=None)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
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.

  • 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.

  • obj -- the data structure to serialize

  • options -- options given to lower yaml module.