source: pyyaml/branches/working-on-emitter/lib/yaml/events.py @ 121

Revision 121, 1.4 KB checked in by xi, 9 years ago (diff)

Add a branch for working on Emitter.

Line 
1
2class Event:
3    def __init__(self, start_mark, end_mark):
4        self.start_mark = start_mark
5        self.end_mark = end_mark
6    def __repr__(self):
7        attributes = [key for key in self.__dict__
8                if not key.endswith('_mark')]
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):
15    def __init__(self, anchor, start_mark, end_mark):
16        self.anchor = anchor
17        self.start_mark = start_mark
18        self.end_mark = end_mark
19
20class AliasEvent(NodeEvent):
21    pass
22
23class ScalarEvent(NodeEvent):
24    def __init__(self, anchor, tag, value, start_mark, end_mark):
25        self.anchor = anchor
26        self.tag = tag
27        self.value = value
28        self.start_mark = start_mark
29        self.end_mark = end_mark
30
31class CollectionEvent(NodeEvent):
32    def __init__(self, anchor, tag, start_mark, end_mark):
33        self.anchor = anchor
34        self.tag = tag
35        self.start_mark = start_mark
36        self.end_mark = end_mark
37
38class SequenceEvent(CollectionEvent):
39    pass
40
41class MappingEvent(CollectionEvent):
42    pass
43
44class CollectionEndEvent(Event):
45    pass
46
47class DocumentStartEvent(Event):
48    pass
49
50class DocumentEndEvent(Event):
51    pass
52
53class StreamStartEvent(Event):
54    pass
55
56class StreamEndEvent(Event):
57    pass
58
Note: See TracBrowser for help on using the repository browser.