³ò
5ÒÇIc           @   sò  d  d k  Td  d k Td  d k Td  d k Td  d k Td  d k Ty d  d k TWn e j
 o n Xe d „ Z	 e d „ Z
 e d „ Z e d „ Z e d „ Z e d „ Z d „  Z d	 „  Z d e d d d d d d
 „ Z d e d d d d d d d d d d d „ Z d e d „ Z d e d d d d d d d d d d d d d „ Z d e d „ Z d d „ Z d d „ Z d e e d „ Z d e e d „ Z e d „ Z e d „ Z e d „ Z e d „ Z d e  f d „  ƒ  YZ! d e" f d „  ƒ  YZ# d S(   iÿÿÿÿ(   t   *c         c   s0   | |  ƒ } x | i  ƒ  o | i ƒ  Vq Wd S(   s9   
    Scan a YAML stream and produce scanning tokens.
    N(   t   check_tokent	   get_token(   t   streamt   Loadert   loader(    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   scan   s    c         c   s0   | |  ƒ } x | i  ƒ  o | i ƒ  Vq Wd S(   s9   
    Parse a YAML stream and produce parsing events.
    N(   t   check_eventt	   get_event(   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   parse   s    c         C   s+   | |  ƒ } | i  ƒ  o | i ƒ  Sn d S(   sj   
    Parse the first YAML document in a stream
    and produce the corresponding representation tree.
    N(   t
   check_nodet   get_node(   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   compose    s    c         c   s0   | |  ƒ } x | i  ƒ  o | i ƒ  Vq Wd S(   sb   
    Parse all YAML documents in a stream
    and produce corresponsing representation trees.
    N(   R
   R   (   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   compose_all)   s    c         c   s0   | |  ƒ } x | i  ƒ  o | i ƒ  Vq Wd S(   s\   
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    N(   t
   check_datat   get_data(   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   load_all2   s    c         C   s+   | |  ƒ } | i  ƒ  o | i ƒ  Sn d S(   sd   
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    N(   R   R   (   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   load;   s    c         C   s   t  |  t ƒ S(   s~   
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    Resolve only basic YAML tags.
    (   R   t
   SafeLoader(   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   safe_load_allD   s    c         C   s   t  |  t ƒ S(   s†   
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    Resolve only basic YAML tags.
    (   R   R   (   R   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt	   safe_loadL   s    c         C   sÁ   d } | d j oP y d d k l }	 Wn# t j
 o d d k l }	 n X|	 ƒ  } | i } n | | d | d | d | d | d | ƒ}
 x |  D] } |
 i | ƒ q” W| o | ƒ  Sn d S(	   sl   
    Emit YAML parsing events into a stream.
    If stream is None, return the produced string instead.
    iÿÿÿÿ(   t   StringIOt	   canonicalt   indentt   widtht   allow_unicodet
   line_breakN(   t   Nonet	   cStringIOR   t   ImportErrort   getvaluet   emit(   t   eventsR   t   DumperR   R   R   R   R   R   R   t   dumpert   event(    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyR   T   s    	 s   utf-8c         C   só   d } | d j oP y d d k l } Wn# t j
 o d d k l } n X| ƒ  } | i } n | | d | d | d | d | d | d | d	 | d
 | d |	 d |
 ƒ
} | i ƒ  x |  D] } | i | ƒ q¼ W| i ƒ  | o | ƒ  Sn d S(   s…   
    Serialize a sequence of representation trees into a YAML stream.
    If stream is None, return the produced string instead.
    iÿÿÿÿ(   R   R   R   R   R   R   t   encodingt   versiont   tagst   explicit_startt   explicit_endN(   R   R   R   R   R   t   opent	   serializet   close(   t   nodesR   R!   R   R   R   R   R   R$   R'   R(   R%   R&   R   R   R"   t   node(    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   serialize_allj   s&    		
 
c         K   s   t  |  g | d | | S(   sx   
    Serialize a representation tree into a YAML stream.
    If stream is None, return the produced string instead.
    R!   (   R.   (   R-   R   R!   t   kwds(    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyR*   †   s    c         C   sÿ   d } | d j oP y d d k l } Wn# t j
 o d d k l } n X| ƒ  } | i } n | | d | d | d | d | d | d | d	 |	 d
 |
 d | d | d | d | ƒ} | i ƒ  x |  D] } | i | ƒ qÈ W| i ƒ  | o | ƒ  Sn d S(   s   
    Serialize a sequence of Python objects into a YAML stream.
    If stream is None, return the produced string instead.
    iÿÿÿÿ(   R   t   default_stylet   default_flow_styleR   R   R   R   R   R$   R%   R&   R'   R(   N(   R   R   R   R   R   R)   t	   representR+   (   t	   documentsR   R!   R0   R1   R   R   R   R   R   R$   R'   R(   R%   R&   R   R   R"   t   data(    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   dump_all   s*    
	
 
c         K   s   t  |  g | d | | S(   sr   
    Serialize a Python object into a YAML stream.
    If stream is None, return the produced string instead.
    R!   (   R5   (   R4   R   R!   R/   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   dump¬   s    c         K   s   t  |  | d t | S(   s¡   
    Serialize a sequence of Python objects into a YAML stream.
    Produce only basic YAML tags.
    If stream is None, return the produced string instead.
    R!   (   R5   t
   SafeDumper(   R3   R   R/   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt   safe_dump_all³   s    c         K   s   t  |  g | d t | S(   s”   
    Serialize a Python object into a YAML stream.
    Produce only basic YAML tags.
    If stream is None, return the produced string instead.
    R!   (   R5   R7   (   R4   R   R/   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyt	   safe_dump»   s    c         C   s*   | i  |  | | ƒ | i  |  | | ƒ d S(   sÙ   
    Add an implicit scalar detector.
    If an implicit scalar value matches the given regexp,
    the corresponding tag is assigned to the scalar.
    first is a sequence of possible initial characters or None.
    N(   t   add_implicit_resolver(   t   tagt   regexpt   firstR   R!   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyR:   Ã   s    c         C   s*   | i  |  | | ƒ | i  |  | | ƒ d S(   sÁ   
    Add a path based resolver for the given tag.
    A path is a list of keys that forms a path
    to a node in the representation tree.
    Keys can be string values, integers, or None.
    N(   t   add_path_resolver(   R;   t   patht   kindR   R!   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyR>   Î   s    c         C   s   | i  |  | ƒ d S(   s¯   
    Add a constructor for the given tag.
    Constructor is a function that accepts a Loader instance
    and a node object and produces the corresponding Python object.
    N(   t   add_constructor(   R;   t   constructorR   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRA   Ø   s    c         C   s   | i  |  | ƒ d S(   s  
    Add a multi-constructor for the given tag prefix.
    Multi-constructor is called for a node if its tag starts with tag_prefix.
    Multi-constructor accepts a Loader instance, a tag suffix,
    and a node object and produces the corresponding Python object.
    N(   t   add_multi_constructor(   t
   tag_prefixt   multi_constructorR   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRC   à   s    c         C   s   | i  |  | ƒ d S(   sÍ   
    Add a representer for the given type.
    Representer is a function accepting a Dumper instance
    and an instance of the given data type
    and producing the corresponding representation node.
    N(   t   add_representer(   t	   data_typet   representerR!   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRF   é   s    c         C   s   | i  |  | ƒ d S(   sÞ   
    Add a representer for the given type.
    Multi-representer is a function accepting a Dumper instance
    and an instance of the given data type or subtype
    and producing the corresponding representation node.
    N(   t   add_multi_representer(   RG   t   multi_representerR!   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRI   ò   s    t   YAMLObjectMetaclassc           B   s   e  Z d  Z d „  Z RS(   s'   
    The metaclass for YAMLObject.
    c         C   sq   t  t |  ƒ i | | | ƒ d | j oD | d d  j	 o3 |  i i |  i |  i ƒ |  i i	 |  |  i
 ƒ n d  S(   Nt   yaml_tag(   t   superRK   t   __init__R   t   yaml_loaderRA   RL   t	   from_yamlt   yaml_dumperRF   t   to_yaml(   t   clst   namet   basesR/   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRN   ÿ   s    (   t   __name__t
   __module__t   __doc__RN   (    (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRK   û   s   t
   YAMLObjectc           B   sV   e  Z d  Z e Z e Z e Z e	 Z
 e	 Z d „  Z e e ƒ Z d „  Z e e ƒ Z RS(   sa   
    An object that can dump itself to a YAML stream
    and load itself from a YAML stream.
    c         C   s   | i  | |  ƒ S(   sC   
        Convert a representation node to a Python object.
        (   t   construct_yaml_object(   RS   R   R-   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRP     s    c         C   s   | i  |  i | |  d |  i ƒS(   sC   
        Convert a Python object to a representation node.
        t
   flow_style(   t   represent_yaml_objectRL   t   yaml_flow_style(   RS   R"   R4   (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRR     s    (   RV   RW   RX   RK   t   __metaclass__R   RO   R!   RQ   R   RL   R]   RP   t   classmethodRR   (    (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pyRY     s   		N($   t   errort   tokensR    R,   R   R"   t   cyamlR   R   R   R	   R   R   R   R   R   R   R   R!   R   R.   R*   R5   R6   R8   R9   R:   R>   RA   RC   RF   RI   t   typeRK   t   objectRY   (    (    (    s#   /p/zhu/06/nlp/nltk/yaml/__init__.pys   <module>   sX   





											

			
