Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pass
_E.__name__ = str(node.tag)
_E._node = node
return _E(data)
def represent_encapsulated_node(s, o):
value = s.represent_data(o.__class__.__bases__[0](o))
value.tag = o.__class__.__name__
return value
ShyamlSafeDumper.add_multi_representer(EncapsulatedNode,
represent_encapsulated_node)
ShyamlSafeLoader.add_constructor(None, mk_encapsulated_node)
##
## Key specifier
##
def tokenize(s):
r"""Returns an iterable through all subparts of string splitted by '.'
So:
>>> list(tokenize('foo.bar.wiz'))
['foo', 'bar', 'wiz']
Contrary to traditional ``.split()`` method, this function has to
deal with any type of data in the string. So it actually
pass
ShyamlSafeDumper.add_representer(
MyOrderedDict,
lambda cls, data: cls.represent_dict(data.items()))
def construct_omap(cls, node):
## Force unfolding reference and merges
## otherwise it would fail on 'merge'
cls.flatten_mapping(node)
return MyOrderedDict(cls.construct_pairs(node))
ShyamlSafeLoader.add_constructor(
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
construct_omap)
##
## Support local and global objects
##
class EncapsulatedNode(object):
"""Holds a yaml node"""
def mk_encapsulated_node(s, node):
method = "construct_%s" % (node.id, )
data = getattr(s, method)(node)