comparison env/lib/python3.9/site-packages/ruamel/yaml/events.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 # coding: utf-8
2
3 # Abstract classes.
4
5 if False: # MYPY
6 from typing import Any, Dict, Optional, List # NOQA
7
8
9 def CommentCheck():
10 # type: () -> None
11 pass
12
13
14 class Event(object):
15 __slots__ = 'start_mark', 'end_mark', 'comment'
16
17 def __init__(self, start_mark=None, end_mark=None, comment=CommentCheck):
18 # type: (Any, Any, Any) -> None
19 self.start_mark = start_mark
20 self.end_mark = end_mark
21 # assert comment is not CommentCheck
22 if comment is CommentCheck:
23 comment = None
24 self.comment = comment
25
26 def __repr__(self):
27 # type: () -> Any
28 attributes = [
29 key
30 for key in ['anchor', 'tag', 'implicit', 'value', 'flow_style', 'style']
31 if hasattr(self, key)
32 ]
33 arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) for key in attributes])
34 if self.comment not in [None, CommentCheck]:
35 arguments += ', comment={!r}'.format(self.comment)
36 return '%s(%s)' % (self.__class__.__name__, arguments)
37
38
39 class NodeEvent(Event):
40 __slots__ = ('anchor',)
41
42 def __init__(self, anchor, start_mark=None, end_mark=None, comment=None):
43 # type: (Any, Any, Any, Any) -> None
44 Event.__init__(self, start_mark, end_mark, comment)
45 self.anchor = anchor
46
47
48 class CollectionStartEvent(NodeEvent):
49 __slots__ = 'tag', 'implicit', 'flow_style', 'nr_items'
50
51 def __init__(
52 self,
53 anchor,
54 tag,
55 implicit,
56 start_mark=None,
57 end_mark=None,
58 flow_style=None,
59 comment=None,
60 nr_items=None,
61 ):
62 # type: (Any, Any, Any, Any, Any, Any, Any, Optional[int]) -> None
63 NodeEvent.__init__(self, anchor, start_mark, end_mark, comment)
64 self.tag = tag
65 self.implicit = implicit
66 self.flow_style = flow_style
67 self.nr_items = nr_items
68
69
70 class CollectionEndEvent(Event):
71 __slots__ = ()
72
73
74 # Implementations.
75
76
77 class StreamStartEvent(Event):
78 __slots__ = ('encoding',)
79
80 def __init__(self, start_mark=None, end_mark=None, encoding=None, comment=None):
81 # type: (Any, Any, Any, Any) -> None
82 Event.__init__(self, start_mark, end_mark, comment)
83 self.encoding = encoding
84
85
86 class StreamEndEvent(Event):
87 __slots__ = ()
88
89
90 class DocumentStartEvent(Event):
91 __slots__ = 'explicit', 'version', 'tags'
92
93 def __init__(
94 self,
95 start_mark=None,
96 end_mark=None,
97 explicit=None,
98 version=None,
99 tags=None,
100 comment=None,
101 ):
102 # type: (Any, Any, Any, Any, Any, Any) -> None
103 Event.__init__(self, start_mark, end_mark, comment)
104 self.explicit = explicit
105 self.version = version
106 self.tags = tags
107
108
109 class DocumentEndEvent(Event):
110 __slots__ = ('explicit',)
111
112 def __init__(self, start_mark=None, end_mark=None, explicit=None, comment=None):
113 # type: (Any, Any, Any, Any) -> None
114 Event.__init__(self, start_mark, end_mark, comment)
115 self.explicit = explicit
116
117
118 class AliasEvent(NodeEvent):
119 __slots__ = ()
120
121
122 class ScalarEvent(NodeEvent):
123 __slots__ = 'tag', 'implicit', 'value', 'style'
124
125 def __init__(
126 self,
127 anchor,
128 tag,
129 implicit,
130 value,
131 start_mark=None,
132 end_mark=None,
133 style=None,
134 comment=None,
135 ):
136 # type: (Any, Any, Any, Any, Any, Any, Any, Any) -> None
137 NodeEvent.__init__(self, anchor, start_mark, end_mark, comment)
138 self.tag = tag
139 self.implicit = implicit
140 self.value = value
141 self.style = style
142
143
144 class SequenceStartEvent(CollectionStartEvent):
145 __slots__ = ()
146
147
148 class SequenceEndEvent(CollectionEndEvent):
149 __slots__ = ()
150
151
152 class MappingStartEvent(CollectionStartEvent):
153 __slots__ = ()
154
155
156 class MappingEndEvent(CollectionEndEvent):
157 __slots__ = ()