B
    D\.                 @   s  d dl T d dlT d dlT d dlT d dlT d dlT dZyd dlT dZW n e	k
r\   dZY nX ddl
Z
ddiZdDdd	ZG d
d deZdd ZefddZefddZefddZefddZdEddZdFddZdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zdedddddfd%d&Zdeddddddddddfd'd(Zdefd)d*Z dedddddddddddddfd+d,Z!defd-d.Z"dGd/d0Z#dHd1d2Z$deefd3d4Z%deefd5d6Z&efd7d8Z'efd9d:Z(efd;d<Z)efd=d>Z*G d?d@ d@e+Z,G dAdB dBe,dCZ-dS )I   )*z5.1TF    NYAMLLoadWarningc             C   s>   | d krt S t| tkr:x | D ]}|t kr| | t |< qW d S )N)_warnings_enabledtypedict)Zsettingskey r	   ,lib/python3.7/site-packages/yaml/__init__.pywarnings   s    
r   c               @   s   e Zd ZdS )r   N)__name__
__module____qualname__r	   r	   r	   r
   r   (   s   c             C   s4   t d dkrd S dd l}d|  }|j|tdd d S )Nr   Fr   zcalling yaml.%s() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.   )
stacklevel)r   r   warnr   )methodr   messager	   r	   r
   load_warning+   s    r   c             c   s4   || }zx|  r | V  qW W d|  X dS )z9
    Scan a YAML stream and produce scanning tokens.
    N)Zcheck_tokenZ	get_tokendispose)streamLoaderloaderr	   r	   r
   scan:   s
    
r   c             c   s4   || }zx|  r | V  qW W d|  X dS )z9
    Parse a YAML stream and produce parsing events.
    N)Zcheck_eventZ	get_eventr   )r   r   r   r	   r	   r
   parseE   s
    
r   c             C   s    || }z|  S |  X d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
   composeP   s    r   c             c   s4   || }zx|  r | V  qW W d|  X d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_all[   s
    
r   c             C   s4   |dkrt d t}|| }z| S |  X dS )zd
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    Nload)r   
FullLoaderZget_single_datar   )r   r   r   r	   r	   r
   r   g   s    r   c             c   sH   |dkrt d t}|| }zx| r4| V  q W W d|  X dS )z\
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    Nload_all)r   r   Z
check_dataget_datar   )r   r   r   r	   r	   r
   r   v   s    
r   c             C   s
   t | tS )z
    Parse the first YAML document in a stream
    and produce the corresponding Python object.

    Resolve all tags except those known to be
    unsafe on untrusted input.
    )r   r   )r   r	   r	   r
   	full_load   s    r!   c             C   s
   t | tS )z
    Parse all YAML documents in a stream
    and produce corresponding Python objects.

    Resolve all tags except those known to be
    unsafe on untrusted input.
    )r   r   )r   r	   r	   r
   full_load_all   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. This is known
    to be safe for untrusted input.
    )r   
SafeLoader)r   r	   r	   r
   	safe_load   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. This is known
    to be safe for untrusted input.
    )r   r#   )r   r	   r	   r
   safe_load_all   s    r%   c             C   s
   t | tS )z
    Parse the first YAML document in a stream
    and produce the corresponding Python object.

    Resolve all tags, even those known to be
    unsafe on untrusted input.
    )r   UnsafeLoader)r   r	   r	   r
   unsafe_load   s    r'   c             C   s
   t | tS )z
    Parse all YAML documents in a stream
    and produce corresponding Python objects.

    Resolve all tags, even those known to be
    unsafe on untrusted input.
    )r   r&   )r   r	   r	   r
   unsafe_load_all   s    r(   c             C   sd   d}|dkrt  }|j}|||||||d}	zx| D ]}
|	|
 q6W W d|	  X |r`| S d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-   r0   dumperZeventr	   r	   r
   r1      s    



r1   c             C   s   d}|dkr,|dkrt  }nt  }|j}|||||||||||	|
d}z,|  x| D ]}|| qZW |  W d|  X |r| S dS )z
    Serialize a sequence of representation trees into a YAML stream.
    If stream is None, return the produced string instead.
    N)
r)   r*   r+   r,   r-   encodingversiontagsexplicit_startexplicit_end)r.   r/   BytesIOr0   open	serializecloser   )nodesr   r3   r)   r*   r+   r,   r-   r5   r8   r9   r6   r7   r0   r4   noder	   r	   r
   serialize_all   s$    	




r@   c             K   s   t | g|fd|i|S )zx
    Serialize a representation tree into a YAML stream.
    If stream is None, return the produced string instead.
    r3   )r@   )r?   r   r3   kwdsr	   r	   r
   r<      s    r<   c             C   s   d}|dkr,|
dkrt  }nt  }|j}|||||||||	|
|||||d}z,|  x| D ]}|| q`W |  W d|  X |r| S d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-   r5   r6   r7   r8   r9   	sort_keys)r.   r/   r:   r0   r;   Z	representr=   r   )	documentsr   r3   rB   rC   r)   r*   r+   r,   r-   r5   r8   r9   r6   r7   rD   r0   r4   datar	   r	   r
   dump_all   s(    



rG   c             K   s   t | g|fd|i|S )zr
    Serialize a Python object into a YAML stream.
    If stream is None, return the produced string instead.
    r3   )rG   )rF   r   r3   rA   r	   r	   r
   dump  s    rH   c             K   s   t | |fdti|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.
    r3   )rG   
SafeDumper)rE   r   rA   r	   r	   r
   safe_dump_all$  s    rJ   c             K   s   t | g|fdti|S )z
    Serialize a Python object into a YAML stream.
    Produce only basic YAML tags.
    If stream is None, return the produced string instead.
    r3   )rG   rI   )rF   r   rA   r	   r	   r
   	safe_dump,  s    rK   c             C   s    | | || | | || 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   r3   r	   r	   r
   rL   4  s    rL   c             C   s    | | || | | || 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)rM   pathZkindr   r3   r	   r	   r
   rO   ?  s    rO   c             C   s   | | | 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)rM   constructorr   r	   r	   r
   rQ   I  s    rQ   c             C   s   | | | 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
   rS   Q  s    rS   c             C   s   | | | 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representerr3   r	   r	   r
   rT   Z  s    rT   c             C   s   | | | 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)rU   Zmulti_representerr3   r	   r	   r
   rV   c  s    rV   c                   s    e Zd ZdZ fddZ  ZS )YAMLObjectMetaclassz'
    The metaclass for YAMLObject.
    c                sN   t t| ||| d|krJ|d d k	rJ| j| j| j | j| | j	 d S )Nyaml_tag)
superrW   __init__yaml_loaderrQ   rX   	from_yamlyaml_dumperrT   to_yaml)clsnamebasesrA   )	__class__r	   r
   rZ   p  s    zYAMLObjectMetaclass.__init__)r   r   r   __doc__rZ   __classcell__r	   r	   )rb   r
   rW   l  s   rW   c               @   s<   e Zd ZdZd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.
    r	   Nc             C   s   | || S )zC
        Convert a representation node to a Python object.
        )Zconstruct_yaml_object)r_   r   r?   r	   r	   r
   r\     s    zYAMLObject.from_yamlc             C   s   |j | j|| | jdS )zC
        Convert a Python object to a representation node.
        )Z
flow_style)Zrepresent_yaml_objectrX   yaml_flow_style)r_   r4   rF   r	   r	   r
   r^     s    zYAMLObject.to_yaml)r   r   r   rc   	__slots__r   r[   r3   r]   rX   rf   classmethodr\   r^   r	   r	   r	   r
   re   v  s   re   )	metaclass)N)N)N)N)N).errortokensr2   r>   r   r4   __version__ZcyamlZ__with_libyaml__ImportErrorr.   r   r   RuntimeWarningr   r   r   r   r   r   r   r   r   r!   r"   r$   r%   r'   r(   r3   r1   r@   r<   rG   rH   rJ   rK   rL   rO   rQ   rS   rT   rV   r   rW   re   r	   r	   r	   r
   <module>   sn   














			
