| [51] | 1 | |
|---|
| 2 | class Event: |
|---|
| 3 | def __init__(self, start_marker, end_marker): |
|---|
| 4 | self.start_marker = start_marker |
|---|
| 5 | self.end_marker = end_marker |
|---|
| 6 | def __repr__(self): |
|---|
| 7 | attributes = [key for key in self.__dict__ |
|---|
| 8 | if not key.endswith('_marker')] |
|---|
| 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 | |
|---|
| 14 | class NodeEvent(Event): |
|---|
| [53] | 15 | def __init__(self, anchor, start_marker, end_marker): |
|---|
| [51] | 16 | self.anchor = anchor |
|---|
| 17 | self.start_marker = start_marker |
|---|
| 18 | self.end_marker = end_marker |
|---|
| 19 | |
|---|
| 20 | class AliasEvent(NodeEvent): |
|---|
| [53] | 21 | pass |
|---|
| [51] | 22 | |
|---|
| 23 | class ScalarEvent(NodeEvent): |
|---|
| 24 | def __init__(self, anchor, tag, value, start_marker, end_marker): |
|---|
| 25 | self.anchor = anchor |
|---|
| 26 | self.tag = tag |
|---|
| 27 | self.value = value |
|---|
| 28 | self.start_marker = start_marker |
|---|
| 29 | self.end_marker = end_marker |
|---|
| 30 | |
|---|
| 31 | class CollectionEvent(NodeEvent): |
|---|
| [53] | 32 | def __init__(self, anchor, tag, start_marker, end_marker): |
|---|
| 33 | self.anchor = anchor |
|---|
| 34 | self.tag = tag |
|---|
| 35 | self.start_marker = start_marker |
|---|
| 36 | self.end_marker = end_marker |
|---|
| [51] | 37 | |
|---|
| 38 | class SequenceEvent(CollectionEvent): |
|---|
| 39 | pass |
|---|
| 40 | |
|---|
| 41 | class MappingEvent(CollectionEvent): |
|---|
| 42 | pass |
|---|
| 43 | |
|---|
| 44 | class CollectionEndEvent(Event): |
|---|
| 45 | pass |
|---|
| 46 | |
|---|
| 47 | class StreamEndEvent(Event): |
|---|
| 48 | pass |
|---|
| 49 | |
|---|