
Both @jlowdermilk and I have tried to use this for initial configuration work. It's cheaper just to import it for now: Name: PyYAML Version: 3.11 Summary: YAML parser and emitter for Python Home-page: http://pyyaml.org/wiki/PyYAML Author: Kirill Simonov Author-email: xi@resolvent.net License: MIT Download-URL: http://pyyaml.org/download/pyyaml/PyYAML-3.11.tar.gz Description: YAML is a data serialization format designed for human readability and interaction with scripting languages. PyYAML is a YAML parser and emitter for Python. PyYAML features a complete YAML 1.1 parser, Unicode support, pickle support, capable extension API, and sensible error messages. PyYAML supports standard YAML tags and provides Python-specific tags that allow to represent an arbitrary Python object. PyYAML is applicable for a broad range of tasks from complex configuration files to object serialization and persistance.
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
|
|
class Node(object):
|
|
def __init__(self, tag, value, start_mark, end_mark):
|
|
self.tag = tag
|
|
self.value = value
|
|
self.start_mark = start_mark
|
|
self.end_mark = end_mark
|
|
def __repr__(self):
|
|
value = self.value
|
|
#if isinstance(value, list):
|
|
# if len(value) == 0:
|
|
# value = '<empty>'
|
|
# elif len(value) == 1:
|
|
# value = '<1 item>'
|
|
# else:
|
|
# value = '<%d items>' % len(value)
|
|
#else:
|
|
# if len(value) > 75:
|
|
# value = repr(value[:70]+u' ... ')
|
|
# else:
|
|
# value = repr(value)
|
|
value = repr(value)
|
|
return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value)
|
|
|
|
class ScalarNode(Node):
|
|
id = 'scalar'
|
|
def __init__(self, tag, value,
|
|
start_mark=None, end_mark=None, style=None):
|
|
self.tag = tag
|
|
self.value = value
|
|
self.start_mark = start_mark
|
|
self.end_mark = end_mark
|
|
self.style = style
|
|
|
|
class CollectionNode(Node):
|
|
def __init__(self, tag, value,
|
|
start_mark=None, end_mark=None, flow_style=None):
|
|
self.tag = tag
|
|
self.value = value
|
|
self.start_mark = start_mark
|
|
self.end_mark = end_mark
|
|
self.flow_style = flow_style
|
|
|
|
class SequenceNode(CollectionNode):
|
|
id = 'sequence'
|
|
|
|
class MappingNode(CollectionNode):
|
|
id = 'mapping'
|
|
|