Changeset 130 for pyyaml/trunk/lib/yaml/events.py
- Timestamp:
- 04/03/06 14:20:25 (7 years ago)
- File:
-
- 1 edited
-
pyyaml/trunk/lib/yaml/events.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/lib/yaml/events.py
r118 r130 1 2 # Abstract classes. 1 3 2 4 class Event: 3 def __init__(self, start_mark , end_mark):5 def __init__(self, start_mark=None, end_mark=None): 4 6 self.start_mark = start_mark 5 7 self.end_mark = end_mark 6 8 def __repr__(self): 7 attributes = [key for key in self.__dict__ 8 if not key.endswith('_mark')] 9 attributes.sort() 9 attributes = [key for key in ['anchor', 'tag', 'value'] 10 if hasattr(self, key)] 10 11 arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) 11 12 for key in attributes]) … … 13 14 14 15 class NodeEvent(Event): 15 def __init__(self, anchor, start_mark , end_mark):16 def __init__(self, anchor, start_mark=None, end_mark=None): 16 17 self.anchor = anchor 17 18 self.start_mark = start_mark 18 19 self.end_mark = end_mark 20 21 class CollectionStartEvent(NodeEvent): 22 def __init__(self, anchor, tag, start_mark=None, end_mark=None, 23 flow_style=None): 24 self.anchor = anchor 25 self.tag = tag 26 self.start_mark = start_mark 27 self.end_mark = end_mark 28 self.flow_style = flow_style 29 30 class CollectionEndEvent(Event): 31 pass 32 33 # Implementations. 34 35 class StreamStartEvent(Event): 36 def __init__(self, start_mark=None, end_mark=None, 37 encoding=None, canonical=None, indent=None, width=None): 38 self.start_mark = start_mark 39 self.end_mark = end_mark 40 self.encoding = encoding 41 self.canonical = canonical 42 self.indent = indent 43 self.width = width 44 45 class StreamEndEvent(Event): 46 pass 47 48 class DocumentStartEvent(Event): 49 def __init__(self, start_mark=None, end_mark=None, 50 implicit=None, version=None, tags=None): 51 self.start_mark = start_mark 52 self.end_mark = end_mark 53 self.implicit = implicit 54 self.version = version 55 self.tags = tags 56 57 class DocumentEndEvent(Event): 58 def __init__(self, start_mark=None, end_mark=None, 59 implicit=None): 60 self.start_mark = start_mark 61 self.end_mark = end_mark 62 self.implicit = implicit 19 63 20 64 class AliasEvent(NodeEvent): … … 22 66 23 67 class ScalarEvent(NodeEvent): 24 def __init__(self, anchor, tag, value, start_mark, end_mark): 68 def __init__(self, anchor, tag, value, start_mark=None, end_mark=None, 69 implicit=None, style=None): 25 70 self.anchor = anchor 26 71 self.tag = tag … … 28 73 self.start_mark = start_mark 29 74 self.end_mark = end_mark 75 self.implicit = implicit 76 self.style = style 30 77 31 class CollectionEvent(NodeEvent): 32 def __init__(self, anchor, tag, start_mark, end_mark): 33 self.anchor = anchor 34 self.tag = tag 35 self.start_mark = start_mark 36 self.end_mark = end_mark 37 38 class SequenceEvent(CollectionEvent): 78 class SequenceStartEvent(CollectionStartEvent): 39 79 pass 40 80 41 class MappingEvent(CollectionEvent):81 class SequenceEndEvent(CollectionEndEvent): 42 82 pass 43 83 44 class CollectionEndEvent(Event):84 class MappingStartEvent(CollectionStartEvent): 45 85 pass 46 86 47 class DocumentStartEvent(Event):87 class MappingEndEvent(CollectionEndEvent): 48 88 pass 49 89 50 class DocumentEndEvent(Event):51 pass52 53 class StreamStartEvent(Event):54 pass55 56 class StreamEndEvent(Event):57 pass58
Note: See TracChangeset
for help on using the changeset viewer.
