³ò
5ÒÇIc           @   sÝ  d  d d d g Z  d d k Td d k Td d k Z y e Wn# e j
 o d d k l Z n Xd d k Z d d k	 Z	 d e
 f d „  ƒ  YZ d  e f d	 „  ƒ  YZ d e f d
 „  ƒ  YZ e i e d ƒ e i ƒ e i e e i ƒ e i e e i ƒ e i e e i ƒ e i e e i ƒ e i e e i ƒ e i e e i ƒ e i e e i  ƒ e i e! e i  ƒ e i e" e i# ƒ e i e e i$ ƒ e i e i% e i& ƒ e i e i e i' ƒ e i d e i( ƒ d e f d „  ƒ  YZ) e) i e e) i ƒ e) i e e) i ƒ e) i e e) i ƒ e) i e* e) i+ ƒ e) i e! e) i, ƒ e) i e e) i- ƒ e) i e) i. e) i- ƒ e) i e) i/ e) i- ƒ e) i e) i0 e) i- ƒ e) i e) i1 e) i2 ƒ e) i3 e) i4 e) i5 ƒ e) i3 e e) i6 ƒ d S(   t   BaseRepresentert   SafeRepresentert   Representert   RepresenterErroriÿÿÿÿ(   t   *N(   t   Setc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR      s   c           B   s  e  Z h  Z h  Z e e d  „ Z d „  Z d d d „  ƒ  YZ e ƒ  Z d „  Z	 d „  Z
 e e ƒ Z e e ƒ Z e e	 ƒ Z e e
 ƒ  ƒ Z e e ƒ Z e e ƒ Z [ [ [	 [
 d „  Z d „  Z d „  Z e e ƒ Z d	 „  Z e e ƒ Z e d
 „ Z e d „ Z e d „ Z d „  Z RS(   c         C   s1   | |  _  | |  _ h  |  _ g  |  _ d  |  _ d  S(   N(   t   default_stylet   default_flow_stylet   represented_objectst   object_keepert   Nonet	   alias_key(   t   selfR   R	   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   __init__   s
    				c         C   s;   |  i  | ƒ } |  i | ƒ h  |  _ g  |  _ d  |  _ d  S(   N(   t   represent_datat	   serializeR
   R   R   R   (   R   t   datat   node(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt	   represent    s
    		t   Cc           B   s   e  Z RS(    (   R   R   (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   '   s    c           C   s   d  S(   N(    (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   f)   s    c           c   s	   d  Vd  S(   N(   R   (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   g*   s    c         C   s7   | g } x' | i  D] } | i |  i | ƒ ƒ q W| S(   N(   t	   __bases__t   extendt   get_classobj_bases(   R   t   clst   basest   base(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   3   s
    	
 c         C   s›  |  i  | ƒ o d  |  _ n t | ƒ |  _ |  i d  j	 o? |  i |  i j o |  i |  i } | Sn |  i i | ƒ n t | ƒ i } t | ƒ |  i	 j o  |  i
 | i ƒ t | ƒ } n | d |  i j o |  i | d |  | ƒ } n¦ x¢ | D]1 } | |  i j o |  i | |  | ƒ } Pqù qù Wd  |  i j o |  i d  |  | ƒ } n@ d  |  i j o |  i d  |  | ƒ } n t d  t | ƒ ƒ } | S(   Ni    (   t   ignore_aliasesR   R   t   idR
   R   t   appendt   typet   __mro__t   instance_typeR   t	   __class__t   listt   yaml_representerst   yaml_multi_representerst
   ScalarNodet   unicode(   R   R   R   t
   data_typest	   data_type(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   9   s0      	c         C   s7   d |  i  j o |  i i ƒ  |  _ n | |  i | <d  S(   NR&   (   t   __dict__R&   t   copy(   R   R+   t   representer(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   add_representer[   s    c         C   s7   d |  i  j o |  i i ƒ  |  _ n | |  i | <d  S(   NR'   (   R,   R'   R-   (   R   R+   R.   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   add_multi_representera   s    c         C   sW   | d  j o |  i } n t | | d | ƒ} |  i d  j	 o | |  i |  i <n | S(   Nt   style(   R   R   R(   R   R
   (   R   t   tagt   valueR1   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_scalarg   s    c   	      C   sÕ   g  } t  | | d | ƒ} |  i d  j	 o | |  i |  i <n t } xO | D]G } |  i | ƒ } t | t ƒ o | i p
 t	 } n | i
 | ƒ qL W| d  j o- |  i d  j	 o |  i | _ qÑ | | _ n | S(   Nt
   flow_style(   t   SequenceNodeR   R   R
   t   TrueR   t
   isinstanceR(   R1   t   FalseR    R	   R5   (	   R   R2   t   sequenceR5   R3   R   t
   best_stylet   itemt	   node_item(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_sequenceo   s      
c         C   s?  g  } t  | | d | ƒ} |  i d  j	 o | |  i |  i <n t } t | d ƒ o | i ƒ  } | i ƒ  n x | D]‡ \ } } |  i | ƒ }	 |  i | ƒ }
 t	 |	 t
 ƒ o |	 i p
 t } n t	 |
 t
 ƒ o |
 i p
 t } n | i |	 |
 f ƒ qv W| d  j o- |  i d  j	 o |  i | _ q;| | _ n | S(   NR5   t   items(   t   MappingNodeR   R   R
   R7   t   hasattrR?   t   sortR   R8   R(   R1   R9   R    R	   R5   (   R   R2   t   mappingR5   R3   R   R;   t   item_keyt
   item_valuet   node_keyt
   node_value(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_mapping   s,     

c         C   s   t  S(   N(   R9   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   ™   s    (    (   R   R   R&   R'   R   R   R   R   t   cR   R   R!   t   classobj_typeR#   t   function_typet   generator_typet   abst   builtin_function_typet   syst   module_typeR   R   R/   t   classmethodR0   R4   R>   RH   R   (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR       s2   						"		c           B   sÇ   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z	 x, e
 e	 ƒ e
 e	 e	 ƒ j o e	 e	 9Z	 qN Wd „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z e d „ Z d „  Z RS(   c         C   sF   | d  d g j o t Sn t | t t t t t f ƒ o t Sn d  S(   N(    (   R   R7   R8   t   strR)   t   boolt   intt   float(   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   ž   s    c         C   s   |  i  d d ƒ S(   Nu   tag:yaml.org,2002:nullu   null(   R4   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_none¤   s    	c         C   s›   d  } d  } y t | d ƒ } d } Wn] t j
 oQ y t | d ƒ } d } Wq… t j
 o" | i d ƒ } d } d } q… Xn X|  i | | d | ƒS(   Nt   asciiu   tag:yaml.org,2002:strs   utf-8t   base64u   tag:yaml.org,2002:binaryt   |R1   (   R   R)   t   UnicodeDecodeErrort   encodeR4   (   R   R   R2   R1   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_str¨   s    

c         C   s   |  i  d | ƒ S(   Nu   tag:yaml.org,2002:str(   R4   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_unicode¸   s    c         C   s'   | o
 d } n d } |  i  d | ƒ S(   Nu   trueu   falseu   tag:yaml.org,2002:bool(   R4   (   R   R   R3   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_bool»   s    
c         C   s   |  i  d t | ƒ ƒ S(   Nu   tag:yaml.org,2002:int(   R4   R)   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_intÂ   s    c         C   s   |  i  d t | ƒ ƒ S(   Nu   tag:yaml.org,2002:int(   R4   R)   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_longÅ   s    gœu ˆ<ä7~c         C   sˆ   | | j p | d j o | d j o
 d } nH | |  i  j o
 d } n. | |  i  j o
 d } n t t | ƒ ƒ } |  i d | ƒ S(   Ng        g      ð?u   .nanu   .infu   -.infu   tag:yaml.org,2002:float(   t	   inf_valueR)   t   reprR4   (   R   R   R3   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_floatÌ   s    '


c         C   s   |  i  d | ƒ S(   Nu   tag:yaml.org,2002:seq(   R>   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_list×   s    c         C   s   |  i  d | ƒ S(   Nu   tag:yaml.org,2002:map(   RH   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_dictæ   s    c         C   s1   h  } x | D] } d  | | <q W|  i d | ƒ S(   Nu   tag:yaml.org,2002:set(   R   RH   (   R   R   R3   t   key(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_seté   s
     c         C   s"   t  | i ƒ  ƒ } |  i d | ƒ S(   Nu   tag:yaml.org,2002:timestamp(   R)   t	   isoformatR4   (   R   R   R3   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_dateï   s    c         C   s%   t  | i d ƒ ƒ } |  i d | ƒ S(   Nt    u   tag:yaml.org,2002:timestamp(   R)   Rh   R4   (   R   R   R3   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_datetimeó   s    c         C   sE   t  | d ƒ o | i ƒ  } n | i i ƒ  } |  i | | d | ƒS(   Nt   __getstate__R5   (   RA   Rl   R,   R-   RH   (   R   R2   R   R   R5   t   state(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_yaml_object÷   s    c         C   s   t  d | ƒ ‚ d  S(   Ns   cannot represent an object: %s(   R   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_undefinedþ   s    (   R   R   R   RV   R\   R]   R^   R_   R`   Ra   Rb   Rc   Rd   Re   Rg   Ri   Rk   R   Rn   Ro   (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   œ   s$   							 						c           B   sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C   s›   d  } d  } y t | d ƒ } d } Wn] t j
 oQ y t | d ƒ } d } Wq… t j
 o" | i d ƒ } d } d } q… Xn X|  i | | d | ƒS(	   NRW   u   tag:yaml.org,2002:strs   utf-8u   tag:yaml.org,2002:python/strRX   u   tag:yaml.org,2002:binaryRY   R1   (   R   R)   RZ   R[   R4   (   R   R   R2   R1   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR\   ,  s    

c         C   sI   d  } y | i d ƒ d } Wn t j
 o d } n X|  i | | ƒ S(   NRW   u    tag:yaml.org,2002:python/unicodeu   tag:yaml.org,2002:str(   R   R[   t   UnicodeEncodeErrorR4   (   R   R   R2   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR]   <  s    
c         C   s9   d } t  | ƒ | j	 o
 d } n |  i | t | ƒ ƒ S(   Nu   tag:yaml.org,2002:intu   tag:yaml.org,2002:python/long(   RT   R4   R)   (   R   R   R2   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR`   E  s    
c         C   s’   | i  d j o d | i } nb | i d j o d | i  } nA | i  d j o d | i | i  f } n d | i | i  f } |  i d | ƒ S(   Ng        u   %ru   %rji    u   %r+%rju   %r%rju    tag:yaml.org,2002:python/complex(   t   imagt   realR4   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_complexK  s    c         C   s   |  i  d | ƒ S(   Nu   tag:yaml.org,2002:python/tuple(   R>   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_tupleV  s    c         C   s*   d | i  | i f } |  i d | d ƒ S(   Nu   %s.%su   tag:yaml.org,2002:python/name:u    (   R   R   R4   (   R   R   t   name(    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_nameY  s    c         C   s   |  i  d | i d ƒ S(   Nu    tag:yaml.org,2002:python/module:u    (   R4   R   (   R   R   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_module]  s    c         C   s  | i  } d | i | i f } d  } d  } t | d ƒ o t | i ƒ  ƒ } n t | d ƒ o | i ƒ  } n
 | i } | d  j o( t	 | t
 ƒ o |  i d | | ƒ Sn t	 | t
 ƒ o  | o |  i d | | ƒ Sn h  } | o | | d <n | | d <|  i d | | ƒ S(   Nu   %s.%st   __getinitargs__Rl   u    tag:yaml.org,2002:python/object:u$   tag:yaml.org,2002:python/object/new:t   argsRm   (   R$   R   R   R   RA   R%   Rx   Rl   R,   R8   t   dictRH   R>   (   R   R   R   t
   class_nameRy   Rm   R3   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_instancea  s*    		
c         C   so  t  | ƒ } | t i j o t i | | ƒ } nT t | d ƒ o | i d ƒ } n1 t | d ƒ o | i ƒ  } n t d | ƒ ‚ t | ƒ d  g d d  } | \ } } } } } t | ƒ } | d  j o
 h  } n | d  j	 o t | ƒ } n | d  j	 o t	 | ƒ } n | i
 d j o$ | d } | d } d	 }	 t }
 n d
 }	 t }
 d | i | i
 f } | o? | o7 | o/ t | t	 ƒ o |
 o |  i d | | ƒ Sn | o8 | o0 t | t	 ƒ o  | o |  i |	 | | ƒ Sn h  } | o | | d <n | p t | t	 ƒ o | | d <n | o | | d <n | o | | d <n |  i |	 | | ƒ S(   Nt   __reduce_ex__i   t
   __reduce__s   cannot represent object: %ri   t
   __newobj__i    i   u$   tag:yaml.org,2002:python/object/new:u&   tag:yaml.org,2002:python/object/apply:u   %s.%su    tag:yaml.org,2002:python/object:Ry   Rm   t	   listitemst	   dictitems(   R!   t   copy_regt   dispatch_tableRA   R}   R~   R   R%   R   Rz   R   R7   R9   R   R8   RH   R>   (   R   R   R   t   reducet   functionRy   Rm   R€   R   R2   t   newobjt   function_nameR3   (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyt   represent_objectŠ  sT    



(   R   R   R\   R]   R`   Rs   Rt   Rv   Rw   R|   Rˆ   (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pyR   *  s   									)(7   t   __all__t   errort   nodest   datetimet   sett	   NameErrort   setsR   RO   R‚   t	   YAMLErrorR   t   objectR    R   R/   R!   R   RV   RR   R\   R)   R]   RS   R^   RT   R_   t   longR`   RU   Rc   R%   Rd   t   tupleRz   Re   Rg   t   dateRi   Rk   Ro   R   t   complexRs   Rt   Rv   RJ   RK   RN   RP   Rw   R0   R#   R|   Rˆ   (    (    (    s&   /p/zhu/06/nlp/nltk/yaml/representer.pys   <module>   s‚   		

ˆe
	
	
	
	
	
	
	
	
	
	


	
ž	
	
	
	
	
	





	