pureyaml package

pureyaml

Yet another yaml parser, in pure python.

pureyaml.dump(obj, fp=None, indent=None, sort_keys=False, **kw)[source]

Dump object to a file like object or string.

Parameters:
  • obj
  • fp – Open file like object
  • indent (int) – Indent size, default 2
  • sort_keys (bool) – Optionally sort dictionary keys.
Returns:

Yaml serialized data.

pureyaml.dumps(obj, indent=None, default=None, sort_keys=False, **kw)[source]

Dump string.

pureyaml.load(s, **kwargs)[source]

Load yaml file

pureyaml.loads(s, cls=None, **kwargs)[source]

Load string

Submodules

pureyaml.decoder module

class pureyaml.decoder.YAMLDecoder(*args, **kwargs)[source]

Bases: pureyaml.nodes.NodeVisitor

Convert node tree into python object.

__doc__ = 'Convert node tree into python object.'
__module__ = 'pureyaml.decoder'
decode(s)[source]
visit_Binary(node)[source]
visit_Bool(node)
visit_Doc(node)
visit_Docs(node)[source]
visit_Float(node)
visit_Int(node)
visit_Map(node)[source]
visit_Null(_)[source]
visit_Scalar(node)[source]
visit_Sequence(node)[source]
visit_Str(node)

pureyaml.encoder module

class pureyaml.encoder.SYMBOL(name)[source]
__doc__ = None
__init__(name)[source]
__module__ = 'pureyaml.encoder'
__repr__()[source]
class pureyaml.encoder.YAMLEncoder(indent=None, sort_keys=None, **kw)[source]

Bases: pureyaml.nodes.NodeVisitor

Convert node tree into string.

__doc__ = 'Convert node tree into string.'
__init__(indent=None, sort_keys=None, **kw)[source]
__module__ = 'pureyaml.encoder'
_encode(obj)[source]
encode(obj)[source]
iter_map_items(node)[source]
iterencode(obj)[source]
stack = []
visit_Binary(node)[source]
visit_Bool(node)[source]
visit_Float(node)[source]
visit_Int(node)
visit_Map(node)[source]
visit_Null(node)[source]
visit_Scalar(node)[source]
visit_Sequence(node)[source]
visit_Str(node)[source]
pureyaml.encoder._(obj)[source]
pureyaml.encoder.is_float(string)[source]
pureyaml.encoder.node_encoder(*args, **kw)[source]

Convert python object to node tree.

pureyaml.exceptions module

exception pureyaml.exceptions.YAMLCastTypeError(message=None, cast=None)[source]

Bases: exceptions.TypeError, pureyaml.exceptions.YAMLException

__doc__ = None
__init__(message=None, cast=None)[source]
__module__ = 'pureyaml.exceptions'
__weakref__

list of weak references to the object (if defined)

exception pureyaml.exceptions.YAMLException(message)[source]

Bases: exceptions.Exception

Base exception for package

__doc__ = 'Base exception for package'
__init__(message)[source]
__module__ = 'pureyaml.exceptions'
__str__()[source]
__weakref__

list of weak references to the object (if defined)

exception pureyaml.exceptions.YAMLStrictTypeError(token, types, func)[source]

Bases: exceptions.TypeError, pureyaml.exceptions.YAMLException

__doc__ = None
__init__(token, types, func)[source]
__module__ = 'pureyaml.exceptions'
__str__()[source]
__weakref__

list of weak references to the object (if defined)

exception pureyaml.exceptions.YAMLSyntaxError(p, value=None)[source]

Bases: exceptions.SyntaxError, pureyaml.exceptions.YAMLException

__doc__ = None
__init__(p, value=None)[source]
__module__ = 'pureyaml.exceptions'
__str__()[source]
__weakref__

list of weak references to the object (if defined)

msg_lines()[source]
exception pureyaml.exceptions.YAMLUnknownSyntaxError[source]

Bases: exceptions.SyntaxError, pureyaml.exceptions.YAMLException

Unexpected syntax error

__doc__ = 'Unexpected syntax error'
__module__ = 'pureyaml.exceptions'
__weakref__

list of weak references to the object (if defined)

pureyaml.nodes module

Node definitions for intermediary node tree.

class pureyaml.nodes.Node(value, **kwargs)[source]

Bases: object

__dict__ = dict_proxy({'__ne__': <function __ne__ at 0x7f6244523848>, '__module__': 'pureyaml.nodes', '__ge__': <function __ge__ at 0x7f6244523c80>, '__weakref__': <attribute '__weakref__' of 'Node' objects>, 'repr_value': <function repr_value at 0x7f62445238c0>, 'init_value': <function init_value at 0x7f62445236e0>, '__le__': <function __le__ at 0x7f6244523cf8>, '__repr__': <function __repr__ at 0x7f6244523938>, '__gt__': <function __gt__ at 0x7f62445237d0>, '__dict__': <attribute '__dict__' of 'Node' objects>, '__lt__': <function __lt__ at 0x7f6244523c08>, '__eq__': <function __eq__ at 0x7f6244523758>, '__doc__': None, '__init__': <function __init__ at 0x7f6244523668>})
__doc__ = None
__eq__(other)[source]
__ge__(other)

x.__ge__(y) <==> x>=y

__gt__(other)[source]
__init__(value, **kwargs)[source]
__le__(other)

x.__le__(y) <==> x<=y

__lt__(other)

x.__lt__(y) <==> x<y

__module__ = 'pureyaml.nodes'
__ne__(other)[source]
__repr__()[source]
__weakref__

list of weak references to the object (if defined)

init_value(*values, **kwargs)[source]
repr_value(value)[source]
class pureyaml.nodes.Collection(*values, **kwargs)[source]

Bases: pureyaml.nodes.SequenceMixin, pureyaml.nodes.Node

__abstractmethods__ = frozenset([])
__add__(other)
__doc__ = None
__init__(*values, **kwargs)
__module__ = 'pureyaml.nodes'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 25
_abc_registry = <_weakrefset.WeakSet object>
init_value(*value, **kwargs)
class pureyaml.nodes.Docs(*values, **kwargs)[source]

Bases: pureyaml.nodes.Collection

__abstractmethods__ = frozenset([])
__doc__ = None
__module__ = 'pureyaml.nodes'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 25
_abc_registry = <_weakrefset.WeakSet object>
class pureyaml.nodes.Doc(*values, **kwargs)[source]

Bases: pureyaml.nodes.Collection

__abstractmethods__ = frozenset([])
__doc__ = None
__module__ = 'pureyaml.nodes'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 25
_abc_registry = <_weakrefset.WeakSet object>
class pureyaml.nodes.Sequence(*values, **kwargs)[source]

Bases: pureyaml.nodes.Collection

__abstractmethods__ = frozenset([])
__doc__ = None
__module__ = 'pureyaml.nodes'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 25
_abc_registry = <_weakrefset.WeakSet object>
class pureyaml.nodes.Map(*args, **kwargs)[source]

Bases: pureyaml.nodes.MappingMixin, pureyaml.nodes.Collection

__abstractmethods__ = frozenset([])
__doc__ = None
__eq__(other)[source]
__module__ = 'pureyaml.nodes'
_abc_cache = <_weakrefset.WeakSet object>
_abc_negative_cache = <_weakrefset.WeakSet object>
_abc_negative_cache_version = 25
_abc_registry = <_weakrefset.WeakSet object>
init_value(*values, **kwargs)[source]
class pureyaml.nodes.Scalar(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Node

__doc__ = None
__eq__(other)[source]
__gt__(other)[source]
__init__(value, *args, **kwargs)[source]
__len__()[source]
__module__ = 'pureyaml.nodes'
init_value(value, *args, **kwargs)[source]
type = NotImplemented
class pureyaml.nodes.Null(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Scalar

__doc__ = None
__module__ = 'pureyaml.nodes'
init_value(*values, **kwargs)[source]
type = None
class pureyaml.nodes.Str(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Scalar

__doc__ = None
__module__ = 'pureyaml.nodes'
init_value(value, *args, **kwargs)[source]
type

alias of str

class pureyaml.nodes.Int(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Scalar

__doc__ = None
__module__ = 'pureyaml.nodes'
init_value(value, base=None, *args, **kwargs)[source]
type

alias of int

class pureyaml.nodes.Float(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Scalar

__doc__ = None
__eq__(other)[source]
__module__ = 'pureyaml.nodes'
init_value(value, *args, **kwargs)[source]
type

alias of float

class pureyaml.nodes.Bool(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Scalar

FALSE_VALUES = ['FALSE', 'NO', '0']
TRUE_VALUES = ['TRUE', 'YES', '1']
__doc__ = None
__module__ = 'pureyaml.nodes'
init_value(value, *args, **kwargs)[source]
type

alias of bool

class pureyaml.nodes.Binary(value, *args, **kwargs)[source]

Bases: pureyaml.nodes.Scalar

__doc__ = None
__module__ = 'pureyaml.nodes'
classmethod from_decoded(data)[source]
init_value(value, *args, **kwargs)[source]
type = 'binary'
class pureyaml.nodes.ScalarDispatch[source]

Bases: object

__dict__ = dict_proxy({'map': {'int16': <functools.partial object at 0x7f62444d7a48>, 'infinity': <class 'pureyaml.nodes.Float'>, 'int10': <functools.partial object at 0x7f62444d7998>, 'int': <class 'pureyaml.nodes.Int'>, 'float': <class 'pureyaml.nodes.Float'>, 'null': <class 'pureyaml.nodes.Null'>, 'int8': <functools.partial object at 0x7f62444d79f0>, 'binary': <class 'pureyaml.nodes.Binary'>, 'nan': <class 'pureyaml.nodes.Float'>, 'bool': <class 'pureyaml.nodes.Bool'>, 'str': <class 'pureyaml.nodes.Str'>}, '__module__': 'pureyaml.nodes', '__new__': <staticmethod object at 0x7f62444c7948>, 're_dispatch': <_sre.SRE_Pattern object at 0x17d3530>, '__dict__': <attribute '__dict__' of 'ScalarDispatch' objects>, '__weakref__': <attribute '__weakref__' of 'ScalarDispatch' objects>, '__doc__': None})
__doc__ = None
__module__ = 'pureyaml.nodes'
static __new__(value, cast=None)[source]
__weakref__

list of weak references to the object (if defined)

map = {'int16': <functools.partial object at 0x7f62444d7a48>, 'infinity': <class 'pureyaml.nodes.Float'>, 'int10': <functools.partial object at 0x7f62444d7998>, 'int': <class 'pureyaml.nodes.Int'>, 'float': <class 'pureyaml.nodes.Float'>, 'null': <class 'pureyaml.nodes.Null'>, 'int8': <functools.partial object at 0x7f62444d79f0>, 'binary': <class 'pureyaml.nodes.Binary'>, 'nan': <class 'pureyaml.nodes.Float'>, 'bool': <class 'pureyaml.nodes.Bool'>, 'str': <class 'pureyaml.nodes.Str'>}
re_dispatch = <_sre.SRE_Pattern object at 0x17d3530>
class pureyaml.nodes.NodeVisitor(*args, **kwargs)[source]

Bases: object

__dict__ = dict_proxy({'__module__': 'pureyaml.nodes', '_visit': <function _visit at 0x7f62444db578>, 'visit': <function visit at 0x7f62444db500>, '__doc__': None, '__dict__': <attribute '__dict__' of 'NodeVisitor' objects>, '__weakref__': <attribute '__weakref__' of 'NodeVisitor' objects>, 'generic_visit': <function generic_visit at 0x7f62444db5f0>, '__init__': <function __init__ at 0x7f62444db488>})
__doc__ = None
__init__(*args, **kwargs)[source]
__module__ = 'pureyaml.nodes'
__weakref__

list of weak references to the object (if defined)

_visit(node)[source]
generic_visit(node)[source]
visit(node)[source]

pureyaml.parser module

Build yacc parser from lex tokens.

class pureyaml.parser.YAMLLexer[source]

Bases: pureyaml.grammar.tokens.YAMLTokens

__doc__ = None
__module__ = 'pureyaml.parser'
classmethod build(**kwargs)[source]
t_ANY_error(t)[source]
classmethod tokenize(data)[source]
class pureyaml.parser.YAMLParser(**kwargs)[source]

Bases: pureyaml.grammar.productions.YAMLProductions

__doc__ = None
__init__(**kwargs)
__module__ = 'pureyaml.parser'
p_error(p)
parse(data, **kwargs)
parsedebug(data, **kwargs)
tokenize(data)