salt.serializers.keyvalue

salt.serializers.keyvalue

New in version 3006.0.

Implements keyvalue serializer which can be used for serializing or deserializing any file which defines keys and values separated by a common set of characters, such environment files, which are in "KEY=value" format.

Options:

param line_ending:

String representation of LF or CRLF to be used for serialization to a file. Defaults to \r\n on Windows and \n on other operating systems.

param quoting:

Boolean flag to determine if values should be quoted (True) during serialization or dequoted (False) during deserialization. Defaults to None (no action).

param separator:

String representing the character(s) used when concatenating or reading key/value pairs. Defaults to =.

A dataset such as:

foo: bar
wang: chung

or

- [foo, bar]
- [wang, chung]

can be represented as:

foo=bar
wang=chung
exception salt.serializers.keyvalue.DeserializationError(message, line_num=None, buf='', marker='    <======================', trace=None)

Raised when stream of string failed to be deserialized

exception salt.serializers.keyvalue.SerializationError(message='')

Raised when stream of string failed to be serialized

salt.serializers.keyvalue.dequote(value)

Remove extra quotes around a string.

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

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

Parameters:
  • stream_or_string -- stream or string to deserialize.

  • options -- options given to the function

salt.serializers.keyvalue.quote(txt)

Wraps a text around quotes.

{% set my_text = 'my_text' %}
{{ my_text | quote }}

will be rendered as:

'my_text'
salt.serializers.keyvalue.serialize(obj, **options)

Serialize Python data to environment file.

Parameters:
  • obj -- the data structure to serialize

  • options -- options given to the function