3
‘^p3  ã               @   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defd3d4„Z%ddefd5d6„Z&dId7d8„Z'dJd9d:„Z(efd;d<„Z)efd=d>„Z*G d?d@„ d@e+ƒZ,G dAdB„ dBe,dC�Z-dS )Ké   )Ú*z5.3TFé    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	   ú@/home/yuhw/zmq/venv/lib/python3.6/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   zŽcalling 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|j ƒ r |jƒ V  qW W d|jƒ  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|j ƒ r |jƒ V  qW W d|jƒ  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|j ƒ S |jƒ  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|j ƒ r |jƒ V  qW W d|jƒ  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|jƒ S |jƒ  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|jƒ r4|jƒ V  q W W d|jƒ  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ƒ }|j}|||||||d�}	zx| D ]}
|	j|
ƒ q6W W d|	jƒ  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   ÚdumperÚeventr	   r	   r
   r1   Â   s    



r1   c             C   s�   d}|dkr,|dkrt jƒ }nt jƒ }|j}|||||||||||	|
d�}z,|jƒ  x| D ]}|j|ƒ qZW |jƒ  W d|jƒ  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-   r6   r9   r:   r7   r8   r0   r4   Únoder	   r	   r
   Úserialize_all×   s$    	




rA   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   )rA   )r@   r   r3   Úkwdsr	   r	   r
   r=   õ   s    r=   c             C   s–   d}|dkr,|
dkrt jƒ }nt jƒ }|j}|||||||||	|
|||||d�}z,|jƒ  x| D ]}|j|ƒ q`W |jƒ  W d|jƒ  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-   r6   r7   r8   r9   r:   Ú	sort_keys)r.   r/   r;   r0   r<   Z	representr>   r   )Ú	documentsr   r3   rC   rD   r)   r*   r+   r,   r-   r6   r9   r:   r7   r8   rE   r0   r4   Údatar	   r	   r
   Údump_allü   s(    



rH   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   )rH   )rG   r   r3   rB   r	   r	   r
   Údump  s    rI   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   )rH   Ú
SafeDumper)rF   r   rB   r	   r	   r
   Úsafe_dump_all$  s    rK   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   )rH   rJ   )rG   r   rB   r	   r	   r
   Ú	safe_dump,  s    rL   c             C   sZ   |dkr:t jj| ||ƒ t jj| ||ƒ t jj| ||ƒ n|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)r   r   Úadd_implicit_resolverr   r&   )ÚtagZregexpÚfirstr   r3   r	   r	   r
   rM   4  s    rM   c             C   sZ   |dkr:t jj| ||ƒ t jj| ||ƒ t jj| ||ƒ n|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)r   r   Úadd_path_resolverr   r&   )rN   ÚpathÚkindr   r3   r	   r	   r
   rP   D  s    rP   c             C   sD   |dkr4t jj| |ƒ t jj| |ƒ t jj| |ƒ n|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)r   r   Úadd_constructorr   r&   )rN   Úconstructorr   r	   r	   r
   rS   S  s
    rS   c             C   sD   |dkr4t jj| |ƒ t jj| |ƒ t jj| |ƒ n|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)r   r   Úadd_multi_constructorr   r&   )Z
tag_prefixZmulti_constructorr   r	   r	   r
   rU   `  s
    rU   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representerr3   r	   r	   r
   rV   n  s    rV   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)rW   Zmulti_representerr3   r	   r	   r
   rX   w  s    rX   c                   s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚYAMLObjectMetaclassz'
    The metaclass for YAMLObject.
    c                s|   t t| ƒj|||ƒ d|krx|d d k	rxt| jtƒrVx2| jD ]}|j| j| jƒ q<W n| jj| j| jƒ | j	j
| | jƒ d S )NÚyaml_tag)ÚsuperrY   Ú__init__Ú
isinstanceÚyaml_loaderÚlistrS   rZ   Ú	from_yamlÚyaml_dumperrV   Úto_yaml)ÚclsÚnameÚbasesrB   r   )Ú	__class__r	   r
   r\   „  s    zYAMLObjectMetaclass.__init__)r   r   r   Ú__doc__r\   Ú__classcell__r	   r	   )rf   r
   rY   €  s   rY   c               @   sB   e Zd ZdZf Zeeeg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)rc   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_objectrZ   Úyaml_flow_style)rc   r4   rG   r	   r	   r
   rb   ¤  s    zYAMLObject.to_yaml)r   r   r   rg   Ú	__slots__r   r   r&   r^   r3   ra   rZ   rj   Úclassmethodr`   rb   r	   r	   r	   r
   ri   �  s   
ri   )Ú	metaclass)N)N)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   rA   r=   rH   rI   rK   rL   rM   rP   rS   rU   rV   rX   r   rY   ri   r	   r	   r	   r
   Ú<module>   sn   


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