o
    jac                     @   s6  g d Z ddlT ddlT ddlZddlZddlZddlZddlZddl	Z	ddl
Z
G dd deZG dd dZG d	d
 d
eZedej edej edej edej edej edej edej edej edej edej edej edej edej G dd deZedej edej edej edej edej  edej edej! ed ej ed!ej" ed"ej ed#ej# ed$ej e$d%ej% e$d&ej& e$d'ej' e$d(ej( e$d)ej) dS )*)BaseConstructorSafeConstructorConstructorConstructorError   )*    Nc                   @   s   e Zd ZdS )r   N)__name__
__module____qualname__ r   r   g/oak/stanford/groups/akundaje/marinovg/programs/SPAdes-3.15.4-Linux/share/spades/pyyaml3/constructor.pyr   
   s    r   c                   @   s   e Zd Zi Zi Zdd Zdd Zdd Zdd Zd	d
 Z	dddZ
dd ZdddZdddZdddZedd Zedd ZdS )r   c                 C   s   i | _ i | _g | _d| _d S NF)constructed_objectsrecursive_objectsstate_generatorsdeep_constructselfr   r   r   __init__   s   
zBaseConstructor.__init__c                 C   s   |   S N)
check_noder   r   r   r   
check_data   s   zBaseConstructor.check_datac                 C   s   |   r| |  S d S r   )r   construct_documentget_noder   r   r   r   get_data   s   zBaseConstructor.get_datac                 C   s   |   }|d ur| |S d S r   )get_single_noder   r   noder   r   r   get_single_data!   s   
zBaseConstructor.get_single_datac                 C   sL   |  |}| jr| j}g | _|D ]}|D ]}qq| jsi | _i | _d| _|S r   )construct_objectr   r   r   r   )r   r   datar   	generatordummyr   r   r   r   (   s   
z"BaseConstructor.construct_documentFc           
      C   s  || j v r
| j | S |r| j}d| _|| jv rtd d d|jd | j|< d }d }|j| jv r5| j|j }nR| jD ]}|j|rP|jt	|d  }| j| } n7q8d | jv r_|j}| jd  }n(d | jv rj| jd  }nt
|trt| jj}nt
|tr~| jj}n	t
|tr| jj}|d u r|| |}n|| ||}t
|tjr|}t|}| jr|D ]}	qn| j| || j |< | j|= |r|| _|S )NTz$found unconstructable recursive node)r   r   r   r   
start_marktagyaml_constructorsyaml_multi_constructors
startswithlen
isinstance
ScalarNode	__class__construct_scalarSequenceNodeconstruct_sequenceMappingNodeconstruct_mappingtypesGeneratorTypenextr   append)
r   r   deepZold_deepconstructorZ
tag_suffix
tag_prefixr    r!   r"   r   r   r   r   5   s^   













z BaseConstructor.construct_objectc                 C   s&   t |tstd d d|j |j|jS )Nz$expected a scalar node, but found %s)r)   r*   r   idr#   valuer   r   r   r   r,   g   s   
z BaseConstructor.construct_scalarc                    s6   t |tstd d d|j |j fdd|jD S )Nz&expected a sequence node, but found %sc                    s   g | ]	}j | d qS )r5   )r   ).0childr5   r   r   r   
<listcomp>s   s    z6BaseConstructor.construct_sequence.<locals>.<listcomp>)r)   r-   r   r8   r#   r9   r   r   r5   r   r=   r   r.   n   s   
z"BaseConstructor.construct_sequencec                 C   s|   t |tstd d d|j |ji }|jD ]&\}}| j||d}t |tjj	s0td|jd|j| j||d}|||< q|S )N%expected a mapping node, but found %sr:   while constructing a mappingzfound unhashable key)
r)   r/   r   r8   r#   r9   r   collectionsabcHashable)r   r   r5   mappingkey_node
value_nodekeyr9   r   r   r   r0   v   s   

z!BaseConstructor.construct_mappingc                 C   sb   t |tstd d d|j |jg }|jD ]\}}| j||d}| j||d}|||f q|S )Nr@   r:   )r)   r/   r   r8   r#   r9   r   r4   )r   r   r5   pairsrF   rG   rH   r9   r   r   r   construct_pairs   s   
zBaseConstructor.construct_pairsc                 C   $   d| j vr| j | _|| j|< d S )Nr%   )__dict__r%   copy)clsr$   r6   r   r   r   add_constructor      
zBaseConstructor.add_constructorc                 C   rK   )Nr&   )rL   r&   rM   )rN   r7   multi_constructorr   r   r   add_multi_constructor   rP   z%BaseConstructor.add_multi_constructorNF)r   r	   r
   r%   r&   r   r   r   r   r   r   r,   r.   r0   rJ   classmethodrO   rR   r   r   r   r   r      s"    
2



r   c                       s   e Zd Z fddZdd Zd( fdd	Zdd	 Zd
dd
dd
ddZdd Zdd Z	dZ
e
e
e
 kr<e
e
9 Z
e
e
e
 ks2e
 e
 Zdd Zdd ZedejZdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Z  ZS ))r   c                    s>   t |tr|jD ]\}}|jdkr| |  S qt |S )Ntag:yaml.org,2002:value)r)   r/   r9   r$   r,   super)r   r   rF   rG   r+   r   r   r,      s   

z SafeConstructor.construct_scalarc           	      C   s(  g }d}|t |jk r|j| \}}|jdkrp|j|= t|tr,| | ||j nUt|trdg }|jD ]}t|tsItd|j	d|j
 |j	| | ||j q6|  |D ]}|| q[ntd|j	d|j
 |j	|jdkr}d|_|d7 }n|d7 }|t |jk s|r||j |_d S d S )	Nr   ztag:yaml.org,2002:mergerA   z,expected a mapping for merging, but found %sz@expected a mapping or list of mappings for merging, but found %srU   tag:yaml.org,2002:strr   )r(   r9   r$   r)   r/   flatten_mappingextendr-   r   r#   r8   r4   reverse)	r   r   mergeindexrF   rG   Zsubmergesubnoder9   r   r   r   rY      sP   








zSafeConstructor.flatten_mappingFc                    s$   t |tr
| | t j||dS )Nr:   )r)   r/   rY   rV   r0   r?   rW   r   r   r0      s   

z!SafeConstructor.construct_mappingc                 C   s   |  | d S r   r,   r   r   r   r   construct_yaml_null   s   
z#SafeConstructor.construct_yaml_nullT)yesnotruefalseonoffc                 C   s   |  |}| j|  S r   )r,   bool_valueslower)r   r   r9   r   r   r   construct_yaml_bool   s   
z#SafeConstructor.construct_yaml_boolc                 C   s  |  |}|dd}d}|d dkrd}|d dv r!|dd  }|dkr'dS |d	r7|t|d
d  d
 S |drG|t|d
d  d S |d dkrT|t|d S d|v r}dd |dD }|  d}d}|D ]}||| 7 }|d9 }ql|| S |t| S )N_ r   r   -+-0Z0b   0x      :c                 S      g | ]}t |qS r   )intr;   partr   r   r   r>          z6SafeConstructor.construct_yaml_int.<locals>.<listcomp><   )r,   replacer'   rv   splitr[   r   r   r9   signdigitsbaseZdigitr   r   r   construct_yaml_int   s2   



z"SafeConstructor.construct_yaml_intgu <7~c                 C   s   |  |}|dd }d}|d dkrd}|d dv r#|dd  }|dkr,|| j S |d	kr3| jS d
|v r\dd |d
D }|  d}d}|D ]}||| 7 }|d9 }qK|| S |t| S )Nrj   rk   r   r   rl   rm   rn   z.infz.nanrt   c                 S   ru   r   )floatrw   r   r   r   r>     ry   z8SafeConstructor.construct_yaml_float.<locals>.<listcomp>g        rz   )r,   r{   rh   	inf_value	nan_valuer|   r[   r   r}   r   r   r   construct_yaml_float   s*   


z$SafeConstructor.construct_yaml_floatc              
   C      z
|  |d}W n ty  } z
td d d| |jd }~ww zttdr-t|W S t|W S  t	j
yI } z
td d d| |jd }~ww Nasciiz,failed to convert base64 data into ascii: %sdecodebytesz failed to decode base64 data: %sr,   encodeUnicodeEncodeErrorr   r#   hasattrbase64r   decodestringbinasciiErrorr   r   r9   excr   r   r   construct_yaml_binary  &   

z%SafeConstructor.construct_yaml_binarya  ^(?P<year>[0-9][0-9][0-9][0-9])
                -(?P<month>[0-9][0-9]?)
                -(?P<day>[0-9][0-9]?)
                (?:(?:[Tt]|[ \t]+)
                (?P<hour>[0-9][0-9]?)
                :(?P<minute>[0-9][0-9])
                :(?P<second>[0-9][0-9])
                (?:\.(?P<fraction>[0-9]*))?
                (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
                (?::(?P<tz_minute>[0-9][0-9]))?))?)?$c              	   C   s0  |  |}| j|j}| }t|d }t|d }t|d }|d s-t|||S t|d }t|d }	t|d }
d}|d ra|d d d	 }t|d	k r]|d
7 }t|d	k sSt|}d }|d rt|d }t|d psd}tj	||d}|d dkr| }t|||||	|
|}|r||8 }|S )Nyearmonthdayhourminutesecondr   fraction   ro   Ztz_signtz_hour	tz_minute)hoursminutesrl   )
r,   timestamp_regexpmatchr9   	groupdictrv   datetimedater(   	timedelta)r   r   r9   r   valuesr   r   r   r   r   r   r   deltar   r   r    r   r   r   construct_yaml_timestamp4  s:   
z(SafeConstructor.construct_yaml_timestampc                 c       g }|V  t |tstd|jd|j |j|jD ]@}t |ts-td|jd|j |jt|jdkrBtd|jdt|j |j|jd \}}| |}| |}|	||f qd S )Nz!while constructing an ordered map!expected a sequence, but found %s,expected a mapping of length 1, but found %sr   2expected a single mapping item, but found %d itemsr   
r)   r-   r   r#   r8   r9   r/   r(   r   r4   )r   r   Zomapr^   rF   rG   rH   r9   r   r   r   construct_yaml_omapR  s.   




z#SafeConstructor.construct_yaml_omapc                 c   r   )Nzwhile constructing pairsr   r   r   r   r   r   )r   r   rI   r^   rF   rG   rH   r9   r   r   r   construct_yaml_pairsh  s.   




z$SafeConstructor.construct_yaml_pairsc                 c   s&    t  }|V  | |}|| d S r   )setr0   updater   r   r    r9   r   r   r   construct_yaml_set}  s
   
z"SafeConstructor.construct_yaml_setc                 C   
   |  |S r   r_   r   r   r   r   construct_yaml_str     
z"SafeConstructor.construct_yaml_strc                 c   s     g }|V  | | | d S r   )rZ   r.   )r   r   r    r   r   r   construct_yaml_seq  s   z"SafeConstructor.construct_yaml_seqc                 c   s$    i }|V  |  |}|| d S r   )r0   r   r   r   r   r   construct_yaml_map  s
   
z"SafeConstructor.construct_yaml_mapc                 c   sR    | |}|V  t|dr| j|dd}|| d S | |}|j| d S )N__setstate__Tr:   )__new__r   r0   r   rL   r   )r   r   rN   r    stater   r   r   construct_yaml_object  s   


z%SafeConstructor.construct_yaml_objectc                 C   s   t d d d|j |j)Nz0could not determine a constructor for the tag %r)r   r$   r#   r   r   r   r   construct_undefined  s   z#SafeConstructor.construct_undefinedrS   )r   r	   r
   r,   rY   r0   r`   rg   ri   r   r   r   r   r   recompileXr   r   r   r   r   r   r   r   r   r   __classcell__r   r   rW   r   r      sD    #	
	
r   ztag:yaml.org,2002:nullztag:yaml.org,2002:boolztag:yaml.org,2002:intztag:yaml.org,2002:floatztag:yaml.org,2002:binaryztag:yaml.org,2002:timestampztag:yaml.org,2002:omapztag:yaml.org,2002:pairsztag:yaml.org,2002:setrX   ztag:yaml.org,2002:seqztag:yaml.org,2002:mapc                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Z	d!ddZdd Zdd Zd"ddZdd  ZdS )#r   c                 C   r   r   r_   r   r   r   r   construct_python_str  r   z Constructor.construct_python_strc                 C   r   r   r_   r   r   r   r   construct_python_unicode  r   z$Constructor.construct_python_unicodec              
   C   r   r   r   r   r   r   r   construct_python_bytes  r   z"Constructor.construct_python_bytesc                 C   r   r   )r   r   r   r   r   construct_python_long  r   z!Constructor.construct_python_longc                 C      t | |S r   )complexr,   r   r   r   r   construct_python_complex     z$Constructor.construct_python_complexc                 C   r   r   )tupler.   r   r   r   r   construct_python_tuple  r   z"Constructor.construct_python_tuplec              
   C   sX   |s	t d|d|zt| W n ty& } zt d|d||f |d }~ww tj| S )N"while constructing a Python module+expected non-empty name appended to the tagcannot find module %r (%s))r   
__import__ImportErrorsysmodules)r   namemarkr   r   r   r   find_python_module  s   
zConstructor.find_python_modulec              
   C   s   |s	t d|d|d|v r|dd\}}nd}|}zt| W n ty7 } zt d|d||f |d }~ww tj| }t||sNt d|d||jf |t||S )Nz"while constructing a Python objectr   .r   builtinsr   zcannot find %r in the module %r)	r   rsplitr   r   r   r   r   r   getattr)r   r   r   module_nameZobject_namer   moduler   r   r   find_python_name  s2   


zConstructor.find_python_namec                 C   2   |  |}|rtd|jd| |j| ||jS )Nz while constructing a Python name&expected the empty value, but found %r)r,   r   r#   r   r   suffixr   r9   r   r   r   construct_python_name     

z!Constructor.construct_python_namec                 C   r   )Nr   r   )r,   r   r#   r   r   r   r   r   construct_python_module  r   z#Constructor.construct_python_moduleNFc                 C   sR   |sg }|si }|  ||j}|r"t|tr"|j|g|R i |S ||i |S r   )r   r#   r)   typer   )r   r   r   argskwdsnewobjrN   r   r   r   make_python_instance"  s   z Constructor.make_python_instancec                 C   s   t |dr|| d S i }t|trt|dkr|\}}t |dr)|j| n|r0|| | D ]
\}}tt	|| q4d S )Nr   rp   rL   )
r   r   r)   r   r(   rL   r   itemssetattrobject)r   instancer   	slotstaterH   r9   r   r   r   set_python_instance_state.  s   


z%Constructor.set_python_instance_statec                 c   s@    | j ||dd}|V  t|d}| j||d}| || d S )NTr   r   r:   )r   r   r0   r   )r   r   r   r   r5   r   r   r   r   construct_python_object<  s   
z#Constructor.construct_python_objectc                 C   s   t |tr| j|dd}i }i }g }i }n%| j|dd}	|	dg }|	di }|	di }|	dg }|	di }| |||||}
|rK| |
| |rR|
| |r_|D ]}|| |
|< qV|
S )NTr:   r   r   r   	listitems	dictitems)r)   r-   r.   r0   getr   r   rZ   )r   r   r   r   r   r   r   r   r   r9   r   rH   r   r   r   construct_python_object_applyE  s*   

z)Constructor.construct_python_object_applyc                 C   s   | j ||ddS )NTr   )r   )r   r   r   r   r   r   construct_python_object_newh  s   z'Constructor.construct_python_object_new)NNFrS   )r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s"    

	#r   ztag:yaml.org,2002:python/noneztag:yaml.org,2002:python/boolztag:yaml.org,2002:python/strz tag:yaml.org,2002:python/unicodeztag:yaml.org,2002:python/bytesztag:yaml.org,2002:python/intztag:yaml.org,2002:python/longztag:yaml.org,2002:python/floatz tag:yaml.org,2002:python/complexztag:yaml.org,2002:python/listztag:yaml.org,2002:python/tupleztag:yaml.org,2002:python/dictztag:yaml.org,2002:python/name:z tag:yaml.org,2002:python/module:z tag:yaml.org,2002:python/object:z&tag:yaml.org,2002:python/object/apply:z$tag:yaml.org,2002:python/object/new:)*__all__errornodescollections.abcrB   r   r   r   r   r   r1   MarkedYAMLErrorr   r   r   rO   r`   ri   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rR   r   r   r   r   r   r   r   r   r   <module>   s  8    