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

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

Add a skeleton of the emitter.

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