Subclass all base classes from `object`.
[pyyaml/python3.git] / lib / yaml / nodes.py
blobc4f070c41e1fb1bc01af27d69329e92dded38908
2 class Node(object):
3 def __init__(self, tag, value, start_mark, end_mark):
4 self.tag = tag
5 self.value = value
6 self.start_mark = start_mark
7 self.end_mark = end_mark
8 def __repr__(self):
9 value = self.value
10 #if isinstance(value, list):
11 # if len(value) == 0:
12 # value = '<empty>'
13 # elif len(value) == 1:
14 # value = '<1 item>'
15 # else:
16 # value = '<%d items>' % len(value)
17 #else:
18 # if len(value) > 75:
19 # value = repr(value[:70]+u' ... ')
20 # else:
21 # value = repr(value)
22 value = repr(value)
23 return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value)
25 class ScalarNode(Node):
26 id = 'scalar'
27 def __init__(self, tag, value,
28 start_mark=None, end_mark=None, style=None):
29 self.tag = tag
30 self.value = value
31 self.start_mark = start_mark
32 self.end_mark = end_mark
33 self.style = style
35 class CollectionNode(Node):
36 def __init__(self, tag, value,
37 start_mark=None, end_mark=None, flow_style=None):
38 self.tag = tag
39 self.value = value
40 self.start_mark = start_mark
41 self.end_mark = end_mark
42 self.flow_style = flow_style
44 class SequenceNode(CollectionNode):
45 id = 'sequence'
47 class MappingNode(CollectionNode):
48 id = 'mapping'