
U"3S%                 @   sQ  d  d l  Td  d l Td  d l Td  d l Td  d l Td  d l Td Z y d  d l Td Z Wn e	 k
 rp d Z Yn Xd d l
 Z
 e d d  Z e d	 d
  Z e d d  Z e d d  Z e d d  Z e d d  Z d d   Z d d   Z d e d d d d d d d  Z d e d d d d d d d d d d d d  Z d e d d  Z d e d d d d d d d d d d d d d d  Z d e d d   Z d d! d"  Z d d# d$  Z d e e d% d&  Z d e e d' d(  Z e d) d*  Z e d+ d,  Z e d- d.  Z  e d/ d0  Z! Gd1 d2   d2 e"  Z# Gd3 d4   d4 d5 e# Z$ d S)6   )*z3.11TF    Nc          
   c   s@   | |   } z" x | j    r, | j   Vq WWd | j   Xd S)z9
    Scan a YAML stream and produce scanning tokens.
    N)Zcheck_tokenZ	get_tokendispose)streamLoaderloader r   //usr/lib/python3/dist-packages/yaml/__init__.pyscan   s
    r
   c          
   c   s@   | |   } z" x | j    r, | j   Vq WWd | j   Xd S)z9
    Parse a YAML stream and produce parsing events.
    N)Zcheck_eventZ	get_eventr   )r   r   r   r   r   r	   parse   s
    r   c          
   C   s,   | |   } z | j    SWd | j   Xd S)zj
    Parse the first YAML document in a stream
    and produce the corresponding representation tree.
    N)Zget_single_noder   )r   r   r   r   r   r	   compose*   s    r   c          
   c   s@   | |   } z" x | j    r, | j   Vq WWd | j   Xd S)zb
    Parse all YAML documents in a stream
    and produce corresponding representation trees.
    N)Z
check_nodeZget_noder   )r   r   r   r   r   r	   compose_all5   s
    r   c          
   C   s,   | |   } z | j    SWd | j   Xd S)zd
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    N)Zget_single_datar   )r   r   r   r   r   r	   loadA   s    r   c          
   c   s@   | |   } z" x | j    r, | j   Vq WWd | j   Xd S)z\
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    N)Z
check_dataget_datar   )r   r   r   r   r   r	   load_allL   s
    r   c             C   s   t  |  t  S)z
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    Resolve only basic YAML tags.
    )r   
SafeLoader)r   r   r   r	   	safe_loadX   s    r   c             C   s   t  |  t  S)z~
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    Resolve only basic YAML tags.
    )r   r   )r   r   r   r	   safe_load_all`   s    r   c             C   s   d } | d k r' t  j   } | j } | | d | d | d | d | d | }	 z" x |  D] }
 |	 j |
  q[ WWd |	 j   X| r |   Sd S)zl
    Emit YAML parsing events into a stream.
    If stream is None, return the produced string instead.
    N	canonicalindentwidthallow_unicode
line_break)ioStringIOgetvalueemitr   )eventsr   Dumperr   r   r   r   r   r   dumperZeventr   r   r	   r   h   s    	r   c             C   s   d } | d k rB | d k r- t  j   } n t  j   } | j } | | d | d | d | d | d | d | d | d	 | d
 |	 d |
 
} z6 | j   x |  D] } | j |  q W| j   Wd | j   X| r |   Sd S)z
    Serialize a sequence of representation trees into a YAML stream.
    If stream is None, return the produced string instead.
    Nr   r   r   r   r   encodingversiontagsexplicit_startexplicit_end)r   r   BytesIOr   open	serializecloser   )nodesr   r   r   r   r   r   r   r    r#   r$   r!   r"   r   r   noder   r   r	   serialize_all}   s$    		
r+   c             K   s   t  |  g | d | | S)zx
    Serialize a representation tree into a YAML stream.
    If stream is None, return the produced string instead.
    r   )r+   )r*   r   r   kwdsr   r   r	   r'      s    r'   c             C   s   d } | d k rB |
 d k r- t  j   } n t  j   } | j } | | d | d | d | d | d | d | d |	 d	 |
 d
 | d | d | d | } z6 | j   x |  D] } | j |  q W| j   Wd | j   X| r |   Sd S)z
    Serialize a sequence of Python objects into a YAML stream.
    If stream is None, return the produced string instead.
    Ndefault_styledefault_flow_styler   r   r   r   r   r    r!   r"   r#   r$   )r   r   r%   r   r&   Z	representr(   r   )	documentsr   r   r-   r.   r   r   r   r   r   r    r#   r$   r!   r"   r   r   datar   r   r	   dump_all   s(    
	
r1   c             K   s   t  |  g | d | | S)zr
    Serialize a Python object into a YAML stream.
    If stream is None, return the produced string instead.
    r   )r1   )r0   r   r   r,   r   r   r	   dump   s    r2   c             K   s   t  |  | d t | S)z
    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   )r1   
SafeDumper)r/   r   r,   r   r   r	   safe_dump_all   s    r4   c             K   s   t  |  g | d t | S)z
    Serialize a Python object into a YAML stream.
    Produce only basic YAML tags.
    If stream is None, return the produced string instead.
    r   )r1   r3   )r0   r   r,   r   r   r	   	safe_dump   s    r5   c             C   s*   | j  |  | |  | j  |  | |  d S)z
    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)add_implicit_resolver)tagZregexpfirstr   r   r   r   r	   r6      s    r6   c             C   s*   | j  |  | |  | j  |  | |  d S)z
    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)add_path_resolver)r7   pathZkindr   r   r   r   r	   r9      s    r9   c             C   s   | j  |  |  d S)z
    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)add_constructor)r7   constructorr   r   r   r	   r;      s    r;   c             C   s   | j  |  |  d S)a  
    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)add_multi_constructor)Z
tag_prefixZmulti_constructorr   r   r   r	   r=      s    r=   c             C   s   | j  |  |  d S)z
    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)add_representer)	data_typeZrepresenterr   r   r   r	   r>      s    r>   c             C   s   | j  |  |  d S)z
    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)add_multi_representer)r?   Zmulti_representerr   r   r   r	   r@   	  s    r@   c                   s(   e  Z d  Z d Z   f d d   Z   S)YAMLObjectMetaclassz'
    The metaclass for YAMLObject.
    c                sk   t  t |   j | | |  d | k rg | d d  k	 rg |  j j |  j |  j  |  j j |  |  j	  d  S)Nyaml_tag)
superrA   __init__yaml_loaderr;   rB   	from_yamlyaml_dumperr>   to_yaml)clsnamebasesr,   )	__class__r   r	   rD     s    zYAMLObjectMetaclass.__init__)__name__
__module____qualname____doc__rD   r   r   )rL   r	   rA     s   rA   c               @   sX   e  Z d  Z d Z f  Z e Z e Z d Z	 d Z
 e d d    Z e d d    Z d S)
YAMLObjectza
    An object that can dump itself to a YAML stream
    and load itself from a YAML stream.
    Nc             C   s   | j  | |   S)zC
        Convert a representation node to a Python object.
        )Zconstruct_yaml_object)rI   r   r*   r   r   r	   rF   *  s    zYAMLObject.from_yamlc             C   s   | j  |  j | |  d |  j S)zC
        Convert a Python object to a representation node.
        Z
flow_style)Zrepresent_yaml_objectrB   yaml_flow_style)rI   r   r0   r   r   r	   rH   1  s    zYAMLObject.to_yaml)rM   rN   rO   rP   	__slots__r   rE   r   rG   rB   rR   classmethodrF   rH   r   r   r   r	   rQ     s   rQ   	metaclass)%errortokensr   r)   r   r   __version__ZcyamlZ__with_libyaml__ImportErrorr   r   r
   r   r   r   r   r   r   r   r   r   r+   r'   r1   r2   r4   r5   r6   r9   r;   r=   r>   r@   typerA   rQ   r   r   r   r	   <module>   s^   







					

			
