o `o@sVgdZddlTddlTddlZddlZddlZddlZddlZddl Z ddl Z Gddde Z GdddZ Gd d d e Zed ejed ejed ejedejedejedejedejedejedejedejedejedejedejGdddeZedejedejedejedejedej edejedej!ed ejed!ej"ed"ejed#ej#ed$eje$d%ej%Gd&d'd'eZ&e&$d(e&j'e&$d)e&j(e&$d*e&j)e&$d+e&j*Gd,d-d-e&Z+dS).)BaseConstructorSafeConstructorFullConstructorUnsafeConstructor ConstructorConstructorError)*Nc@ eZdZdS)rN__name__ __module__ __qualname__rr2/usr/lib/python3/dist-packages/yaml/constructor.pyrrc@seZdZiZiZddZddZddZddZd d Z d d Z dddZ ddZ dddZ dddZdddZeddZeddZdS)rcCsi|_i|_g|_d|_dSNF)constructed_objectsrecursive_objectsstate_generatorsdeep_constructselfrrr__init__s zBaseConstructor.__init__cCs|SN) check_noderrrr check_dataszBaseConstructor.check_datacCs&||rtddd|fddS)zBlock special attributes/methods from being set in a newly created object, to prevent user-controlled methods from being called during deserializationNz,blacklisted key '%s' in instance state found)get_state_keys_blacklist_regexpmatchr)rkeyrrrcheck_state_key"s  zBaseConstructor.check_state_keycCs|r ||SdSr)rconstruct_documentZget_noderrrrget_data*szBaseConstructor.get_datacCs|}|dur ||SdSr)Zget_single_noder!rnoderrrget_single_data/s zBaseConstructor.get_single_datacCsL||}|jr|j}g|_|D]}|D]}qq|jsi|_i|_d|_|Sr)construct_objectrrrr)rr$datar generatordummyrrrr!6s z"BaseConstructor.construct_documentFc Cs||jvr |j|S|r|j}d|_||jvrtddd|jd|j|<d}d}|j|jvr5|j|j}nV|jD]}|durT|j|rT|jt |d}|j|}n7q8d|jvrc|j}|jd}n(d|jvrn|jd}nt |t rx|j j }nt |tr|j j}n t |tr|j j}|dur|||}n||||}t |tjr|}t|}|jr|D]} qn|j|||j|<|j|=|r||_|S)NTz$found unconstructable recursive node)rrrr start_marktagyaml_constructorsyaml_multi_constructors startswithlen isinstance ScalarNode __class__construct_scalar SequenceNodeconstruct_sequence MappingNodeconstruct_mappingtypes GeneratorTypenextrappend) rr$deepZold_deep constructorZ tag_suffix tag_prefixr'r(r)rrrr&Cs^                     z BaseConstructor.construct_objectcCs&t|tstddd|j|j|jS)Nz$expected a scalar node, but found %s)r0r1ridr*valuer#rrrr3us z BaseConstructor.construct_scalarcs6t|tstddd|j|jfdd|jDS)Nz&expected a sequence node, but found %scsg|] }j|dqS)r<)r&).0childr<rrr sz6BaseConstructor.construct_sequence..)r0r4rr?r*r@rr$r<rrDrr5|s  z"BaseConstructor.construct_sequencecCs|t|tstddd|j|ji}|jD]&\}}|j||d}t|tjj s0td|jd|j|j||d}|||<q|S)N%expected a mapping node, but found %srAwhile constructing a mappingzfound unhashable key) r0r6rr?r*r@r& collectionsabcHashable)rr$r<mappingkey_node value_noderr@rrrr7s  z!BaseConstructor.construct_mappingcCsbt|tstddd|j|jg}|jD]\}}|j||d}|j||d}|||fq|S)NrGrA)r0r6rr?r*r@r&r;)rr$r<pairsrMrNrr@rrrconstruct_pairss zBaseConstructor.construct_pairscC$d|jvr |j|_||j|<dS)Nr,)__dict__r,copy)clsr+r=rrradd_constructor  zBaseConstructor.add_constructorcCrQ)Nr-)rRr-rS)rTr>Zmulti_constructorrrradd_multi_constructorrVz%BaseConstructor.add_multi_constructorNF)r r rr,r-rrr r"r%r!r&r3r5r7rP classmethodrUrWrrrrrs$ 2    rcseZdZfddZddZd(fdd Zdd Zd dd dd dd Zd d ZddZ dZ e e e krt|tr|jD]\}}|jdkr||Sqt|S)Ntag:yaml.org,2002:value)r0r6r@r+r3super)rr$rMrNr2rrr3s   z SafeConstructor.construct_scalarc Cs(g}d}|t|jkr|j|\}}|jdkrp|j|=t|tr,||||jnUt|trdg}|jD]}t|tsItd|j d|j |j ||| |jq6| |D]}||q[ntd|j d|j |j |jdkr}d|_|d7}n|d7}|t|jks |r||j|_dSdS) Nr ztag:yaml.org,2002:mergerHz,expected a mapping for merging, but found %sz@expected a mapping or list of mappings for merging, but found %srZtag:yaml.org,2002:strr) r/r@r+r0r6flatten_mappingextendr4rr*r?r;reverse) rr$ZmergeindexrMrNZsubmergesubnoder@rrrr^sP          zSafeConstructor.flatten_mappingFcs$t|tr ||tj||dS)NrA)r0r6r^r[r7rFr\rrr7s  z!SafeConstructor.construct_mappingcCs||dSrr3r#rrrconstruct_yaml_nulls z#SafeConstructor.construct_yaml_nullT)ZyesnotrueZfalseZonZoffcCs||}|j|Sr)r3 bool_valueslower)rr$r@rrrconstruct_yaml_bools z#SafeConstructor.construct_yaml_boolcCs||}|dd}d}|ddkrd}|ddvr!|dd}|dkr'dS|d r7|t|d dd S|d rG|t|d dd S|ddkrT|t|d Sd|vr}dd|dD}|d}d}|D] }|||7}|d9}ql||S|t|S)N_rr -+-0Z0b0x:cSg|]}t|qSr)intrBpartrrrrEz6SafeConstructor.construct_yaml_int..<)r3replacer.rvsplitr`rr$r@signdigitsbaseZdigitrrrconstruct_yaml_ints2           z"SafeConstructor.construct_yaml_intgu<7~cCs||}|dd}d}|ddkrd}|ddvr#|dd}|dkr,||jS|d kr3|jSd |vr\d d |d D}|d}d }|D] }|||7}|d9}qK||S|t|S)Nrjrkrr rlrmrnz.infz.nanrtcSrur)floatrwrrrrEryz8SafeConstructor.construct_yaml_float..grz)r3r{rh inf_value nan_valuer|r`rr}rrrconstruct_yaml_floats*        z$SafeConstructor.construct_yaml_floatc Cz ||d}Wnty }z tddd||jd}~wwzttdr-t|WSt|WSt j yI}z tddd||jd}~wwNasciiz,failed to convert base64 data into ascii: %s decodebytesz failed to decode base64 data: %s r3encodeUnicodeEncodeErrorrr*hasattrbase64rZ decodestringbinasciiErrorrr$r@excrrrconstruct_yaml_binary&&    z%SafeConstructor.construct_yaml_binarya^(?P[0-9][0-9][0-9][0-9]) -(?P[0-9][0-9]?) -(?P[0-9][0-9]?) (?:(?:[Tt]|[ \t]+) (?P[0-9][0-9]?) :(?P[0-9][0-9]) :(?P[0-9][0-9]) (?:\.(?P[0-9]*))? (?:[ \t]*(?PZ|(?P[-+])(?P[0-9][0-9]?) (?::(?P[0-9][0-9]))?))?)?$c Cs@||}|j|j}|}t|d}t|d}t|d}|ds-t|||St|d}t|d} t|d} d} d} |drc|ddd } t| d kr_| d 7} t| d ksUt| } |d rt|d } t|d psd}tj | |d}|d dkr| }t |} n|drtj j } tj||||| | | | dS)Nyearmonthdayhourminutesecondr fractionroZtz_signtz_hour tz_minute)ZhoursZminutesrlZtz)tzinfo) r3timestamp_regexprr@ groupdictrvdatetimedater/Z timedeltatimezoneZutc)rr$r@rvaluesrrrrrrrrrrZdeltarrrconstruct_yaml_timestampBs>            z(SafeConstructor.construct_yaml_timestampccg}|Vt|tstd|jd|j|j|jD]@}t|ts-td|jd|j|jt|jdkrBtd|jdt|j|j|jd\}}||}||}| ||fqdS)Nz!while constructing an ordered map!expected a sequence, but found %s,expected a mapping of length 1, but found %sr2expected a single mapping item, but found %d itemsr r0r4rr*r?r@r6r/r&r;)rr$ZomaprbrMrNrr@rrrconstruct_yaml_omapas.       z#SafeConstructor.construct_yaml_omapccr)Nzwhile constructing pairsrrrrr r)rr$rOrbrMrNrr@rrrconstruct_yaml_pairsws.       z$SafeConstructor.construct_yaml_pairsccs&t}|V||}||dSr)setr7updaterr$r'r@rrrconstruct_yaml_sets  z"SafeConstructor.construct_yaml_setcC ||Srrcr#rrrconstruct_yaml_str z"SafeConstructor.construct_yaml_strccs g}|V|||dSr)r_r5)rr$r'rrrconstruct_yaml_seqsz"SafeConstructor.construct_yaml_seqccs$i}|V||}||dSr)r7rrrrrconstruct_yaml_maps  z"SafeConstructor.construct_yaml_mapccsR||}|Vt|dr|j|dd}||dS||}|j|dS)N __setstate__TrA)__new__rr7rrRr)rr$rTr'staterrrconstruct_yaml_objects   z%SafeConstructor.construct_yaml_objectcCstddd|j|j)Nz0could not determine a constructor for the tag %r)rr+r*r#rrrconstruct_undefinedsz#SafeConstructor.construct_undefinedrX)r r rr3r^r7rdrgrirrrrrrecompileXrrrrrrrrrr __classcell__rrr\rrsD #      rztag:yaml.org,2002:nullztag:yaml.org,2002:boolztag:yaml.org,2002:intztag:yaml.org,2002:floatztag:yaml.org,2002:binaryztag:yaml.org,2002:timestampztag:yaml.org,2002:omapztag:yaml.org,2002:pairsztag:yaml.org,2002:setr]ztag:yaml.org,2002:seqztag:yaml.org,2002:mapc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ d%ddZ d%ddZ ddZ ddZ d&ddZd%ddZdd Zd%d!d"Zd#d$ZdS)'rcCsddgS)Nz^extend$z^__.*__$rrrrrget_state_keys_blacklistsz(FullConstructor.get_state_keys_blacklistcCs.t|dstdd|d|_|jS)Nstate_keys_blacklist_regexp(|))rrrjoinrrrrrrrs z/FullConstructor.get_state_keys_blacklist_regexpcCrrrcr#rrrconstruct_python_strrz$FullConstructor.construct_python_strcCrrrcr#rrrconstruct_python_unicoderz(FullConstructor.construct_python_unicodec Crrrrrrrconstruct_python_bytesrz&FullConstructor.construct_python_bytescCrr)rr#rrrconstruct_python_longrz%FullConstructor.construct_python_longcCt||Sr)complexr3r#rrrconstruct_python_complexz(FullConstructor.construct_python_complexcCrr)tupler5r#rrrconstruct_python_tuple rz&FullConstructor.construct_python_tupleFc Csx|s td|d||r)zt|Wnty(}z td|d||f|d}~ww|tjvr7td|d||tj|S)N"while constructing a Python module+expected non-empty name appended to the tagcannot find module %r (%s)module %r is not imported)r __import__ ImportErrorsysmodules)rnamemarkunsaferrrrfind_python_module s$    z"FullConstructor.find_python_modulec Cs|s td|d|d|vr|dd\}}nd}|}|r:zt|Wnty9}z td|d||f|d}~ww|tjvrHtd|d||tj|}t||s^td|d||jf|t||S) Nz"while constructing a Python objectr.rbuiltinsrrzcannot find %r in the module %r) rrsplitrrrrrr getattr)rrrrZ module_nameZ object_namermodulerrrfind_python_names<      z FullConstructor.find_python_namecC2||}|rtd|jd||j|||jS)Nz while constructing a Python name&expected the empty value, but found %r)r3rr*rrsuffixr$r@rrrconstruct_python_name5  z%FullConstructor.construct_python_namecCr)Nrr)r3rr*rrrrrconstruct_python_module<rz'FullConstructor.construct_python_moduleNcCsz|sg}|si}|||j}|s#t|ts#td|jdt||j|r6t|tr6|j|g|Ri|S||i|S)Nz$while constructing a Python instancezexpected a class, but found %r)rr*r0typerr)rrr$argskwdsnewobjrrTrrrmake_python_instanceCs z$FullConstructor.make_python_instancecCst|dr ||dSi}t|trt|dkr|\}}t|dr9|s2|r2|D]}||q*|j|n|r@||| D]\}}|sO||t |||qDdS)NrrprR) rrr0rr/keysr rRritemssetattr)rinstancerrZ slotstaterr@rrrset_python_instance_stateSs"      z)FullConstructor.set_python_instance_stateccs@|j||dd}|Vt|d}|j||d}|||dS)NTrrrA)rrr7r)rrr$rr<rrrrconstruct_python_objectfs  z'FullConstructor.construct_python_objectc Cst|tr|j|dd}i}i}g}i}n%|j|dd} | dg}| di}| di}| dg}| di}||||||} |rK|| ||rR| ||r_|D]} || | | <qV| S)NTrArrr listitems dictitems)r0r4r5r7getrrr_) rrr$rrrrrrr@rrrrrconstruct_python_object_applyos*        z-FullConstructor.construct_python_object_applycCs|j||ddS)NTr)r)rrr$rrrconstruct_python_object_newsz+FullConstructor.construct_python_object_newrX)NNFF)r r rrrrrrrrrrrrrrrrrrrrrrrs&    #rztag:yaml.org,2002:python/noneztag:yaml.org,2002:python/boolztag:yaml.org,2002:python/strz tag:yaml.org,2002:python/unicodeztag:yaml.org,2002:python/bytesztag:yaml.org,2002:python/intztag:yaml.org,2002:python/longztag:yaml.org,2002:python/floatz tag:yaml.org,2002:python/complexztag:yaml.org,2002:python/listztag:yaml.org,2002:python/tupleztag:yaml.org,2002:python/dictztag:yaml.org,2002:python/name:csBeZdZfddZfddZd fdd Zfd d ZZS) rctt|j||ddSNT)r)r[rrrrrr\rrrz$UnsafeConstructor.find_python_modulecrr)r[rrrr\rrrrz"UnsafeConstructor.find_python_nameNFcstt|j|||||ddSr)r[rr)rrr$rrrr\rrrs  z&UnsafeConstructor.make_python_instancecrr)r[rr)rrrr\rrrs z+UnsafeConstructor.set_python_instance_state)NNF)r r rrrrrrrrr\rrs   rz tag:yaml.org,2002:python/module:z tag:yaml.org,2002:python/object:z$tag:yaml.org,2002:python/object/new:z&tag:yaml.org,2002:python/object/apply:c@r )rNr rrrrrrr),__all__errorZnodesZcollections.abcrIrrrrrr8ZMarkedYAMLErrorrrrrUrdrirrrrrrrrrrrrrrrrrrrWrrrrrrrrrrrs  84