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

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

Add a skeleton of the emitter.

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