source: branches/pyyaml3000/lib/yaml/events.py @ 53

Revision 53, 1.3 KB checked in by xi, 9 years ago (diff)

Implement Composer and BaseResolver?.

RevLine 
[51]1
2class Event:
3    def __init__(self, start_marker, end_marker):
4        self.start_marker = start_marker
5        self.end_marker = end_marker
6    def __repr__(self):
7        attributes = [key for key in self.__dict__
8                if not key.endswith('_marker')]
9        attributes.sort()
10        arguments = ', '.join(['%s=%r' % (key, getattr(self, key))
11                for key in attributes])
12        return '%s(%s)' % (self.__class__.__name__, arguments)
13
14class NodeEvent(Event):
[53]15    def __init__(self, anchor, start_marker, end_marker):
[51]16        self.anchor = anchor
17        self.start_marker = start_marker
18        self.end_marker = end_marker
19
20class AliasEvent(NodeEvent):
[53]21    pass
[51]22
23class ScalarEvent(NodeEvent):
24    def __init__(self, anchor, tag, value, start_marker, end_marker):
25        self.anchor = anchor
26        self.tag = tag
27        self.value = value
28        self.start_marker = start_marker
29        self.end_marker = end_marker
30
31class CollectionEvent(NodeEvent):
[53]32    def __init__(self, anchor, tag, start_marker, end_marker):
33        self.anchor = anchor
34        self.tag = tag
35        self.start_marker = start_marker
36        self.end_marker = end_marker
[51]37
38class SequenceEvent(CollectionEvent):
39    pass
40
41class MappingEvent(CollectionEvent):
42    pass
43
44class CollectionEndEvent(Event):
45    pass
46
47class StreamEndEvent(Event):
48    pass
49
Note: See TracBrowser for help on using the repository browser.