Ignore:
Timestamp:
03/20/06 18:31:07 (8 years ago)
Author:
xi
Message:

Add a skeleton of the emitter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/branches/working-on-emitter/lib/yaml/events.py

    r121 r122  
    11 
    22class Event: 
    3     def __init__(self, start_mark, end_mark): 
     3    def __init__(self, start_mark=None, end_mark=None): 
    44        self.start_mark = start_mark 
    55        self.end_mark = end_mark 
    66    def __repr__(self): 
    7         attributes = [key for key in self.__dict__ 
    8                 if not key.endswith('_mark')] 
    9         attributes.sort() 
     7        attributes = [key for key in ['anchor', 'tag', 'value'] 
     8                if hasattr(self, key)] 
    109        arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) 
    1110                for key in attributes]) 
     
    1312 
    1413class NodeEvent(Event): 
    15     def __init__(self, anchor, start_mark, end_mark): 
     14    def __init__(self, anchor, start_mark=None, end_mark=None): 
    1615        self.anchor = anchor 
    1716        self.start_mark = start_mark 
     
    2221 
    2322class ScalarEvent(NodeEvent): 
    24     def __init__(self, anchor, tag, value, start_mark, end_mark): 
     23    def __init__(self, anchor, tag, value, start_mark=None, end_mark=None): 
    2524        self.anchor = anchor 
    2625        self.tag = tag 
     
    3029 
    3130class CollectionEvent(NodeEvent): 
    32     def __init__(self, anchor, tag, start_mark, end_mark): 
     31    def __init__(self, anchor, tag, start_mark=None, end_mark=None): 
    3332        self.anchor = anchor 
    3433        self.tag = tag 
Note: See TracChangeset for help on using the changeset viewer.