summaryrefslogtreecommitdiff
path: root/lib/yaml/events.py
blob: d468c53120c3aa71ebbcfb751ce3eab15e946afc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

class Event:
    def __init__(self, start_marker, end_marker):
        self.start_marker = start_marker
        self.end_marker = end_marker
    def __repr__(self):
        attributes = [key for key in self.__dict__
                if not key.endswith('_marker')]
        attributes.sort()
        arguments = ', '.join(['%s=%r' % (key, getattr(self, key))
                for key in attributes])
        return '%s(%s)' % (self.__class__.__name__, arguments)

class NodeEvent(Event):
    def __init__(self, anchor, start_marker, end_marker):
        self.anchor = anchor
        self.start_marker = start_marker
        self.end_marker = end_marker

class AliasEvent(NodeEvent):
    pass

class ScalarEvent(NodeEvent):
    def __init__(self, anchor, tag, value, start_marker, end_marker):
        self.anchor = anchor
        self.tag = tag
        self.value = value
        self.start_marker = start_marker
        self.end_marker = end_marker

class CollectionEvent(NodeEvent):
    def __init__(self, anchor, tag, start_marker, end_marker):
        self.anchor = anchor
        self.tag = tag
        self.start_marker = start_marker
        self.end_marker = end_marker

class SequenceEvent(CollectionEvent):
    pass

class MappingEvent(CollectionEvent):
    pass

class CollectionEndEvent(Event):
    pass

class StreamEndEvent(Event):
    pass