pyrtma.parser.YAML

class YAML(*, typ=None, pure=False, output=None, plug_ins=None)[source]

Bases: object

typ: ‘rt’/None -> RoundTripLoader/RoundTripDumper, (default)

‘safe’ -> SafeLoader/SafeDumper, ‘unsafe’ -> normal/unsafe Loader/Dumper (pending deprecation) ‘full’ -> full Dumper only, including python built-ins that are

potentially unsafe to load

‘base’ -> baseloader

pure: if True only use Python modules input/output: needed to work as context manager plug_ins: a list of plug-in files

Methods

Xdump_all

Serialize a sequence of Python objects into a YAML stream.

compact

rtype:

None

compose

Parse the first YAML document in a stream and produce the corresponding representation tree.

compose_all

Parse all YAML documents in a stream and produce corresponding representation trees.

dump

rtype:

Any

dump_all

rtype:

Any

emit

Emit YAML parsing events into a stream.

get_constructor_parser

the old cyaml needs special setup, and therefore the stream

get_serializer_representer_emitter

rtype:

Any

load

at this point you either have the non-pure Parser (which has its own reader and scanner) or you have the pure Parser.

load_all

rtype:

Any

map

rtype:

Any

official_plug_ins

search for list of subdirs that are plug-ins, if __file__ is not available, e.g.

parse

Parse a YAML stream and produce parsing events.

register_class

register a class for dumping/loading :rtype: Any

scan

Scan a YAML stream and produce scanning tokens.

seq

rtype:

Any

serialize

Serialize a representation tree into a YAML stream.

serialize_all

Serialize a sequence of representation trees into a YAML stream.

Attributes

block_seq_indent

composer

constructor

emitter

indent

parser

reader

representer

resolver

scanner

serializer

tags

version

Parameters:
  • typ (Optional[Union[List[Text], Text]]) –

  • pure (Any) –

  • output (Any) –

  • plug_ins (Any) –

Xdump_all(documents, stream, *, transform=None)[source]

Serialize a sequence of Python objects into a YAML stream.

Return type:

Any

Parameters:
  • documents (Any) –

  • stream (Any) –

  • transform (Any) –

compose(stream)[source]

Parse the first YAML document in a stream and produce the corresponding representation tree.

Return type:

Any

Parameters:

stream (Union[Path, StreamTextType]) –

compose_all(stream)[source]

Parse all YAML documents in a stream and produce corresponding representation trees.

Return type:

Any

Parameters:

stream (Union[Path, StreamTextType]) –

emit(events, stream)[source]

Emit YAML parsing events into a stream. If stream is None, return the produced string instead.

Return type:

None

Parameters:
  • events (Any) –

  • stream (Any) –

get_constructor_parser(stream)[source]

the old cyaml needs special setup, and therefore the stream

Return type:

Any

Parameters:

stream (StreamTextType) –

load(stream)[source]

at this point you either have the non-pure Parser (which has its own reader and scanner) or you have the pure Parser. :rtype: Any

If the pure Parser is set, then set the Reader and Scanner, if not already set. If either the Scanner or Reader are set, you cannot use the non-pure Parser,

so reset it to the pure parser and set the Reader resp. Scanner if necessary

Parameters:

stream (Union[Path, StreamTextType]) –

Return type:

Any

official_plug_ins()[source]

search for list of subdirs that are plug-ins, if __file__ is not available, e.g. single file installers that are not properly emulating a file-system (issue 324) :rtype: Any

no plug-ins will be found. If any are packaged, you know which file that are and you can explicitly provide it during instantiation:

yaml = ruamel.yaml.YAML(plug_ins=[‘ruamel/yaml/jinja2/__plug_in__’])

Return type:

Any

parse(stream)[source]

Parse a YAML stream and produce parsing events.

Return type:

Any

Parameters:

stream (StreamTextType) –

register_class(cls)[source]

register a class for dumping/loading :rtype: Any

  • if it has attribute yaml_tag use that to register, else use class name

  • if it has methods to_yaml/from_yaml use those to dump/load else dump attributes as mapping

Parameters:

cls (Any) –

Return type:

Any

scan(stream)[source]

Scan a YAML stream and produce scanning tokens.

Return type:

Any

Parameters:

stream (StreamTextType) –

serialize(node, stream)[source]

Serialize a representation tree into a YAML stream. If stream is None, return the produced string instead.

Return type:

Any

Parameters:
  • node (Any) –

  • stream (Optional[StreamType]) –

serialize_all(nodes, stream)[source]

Serialize a sequence of representation trees into a YAML stream. If stream is None, return the produced string instead.

Return type:

Any

Parameters:
  • nodes (Any) –

  • stream (Optional[StreamType]) –