a b`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@s eZdZdS)rN__name__ __module__ __qualname__rr6/usr/lib64/python3.9/site-packages/yaml/constructor.pyrsrc@seZdZiZiZddZddZddZddZd d Z d d Z dddZ ddZ dddZ dddZd ddZeddZeddZdS)!rcCsi|_i|_g|_d|_dSNF)constructed_objectsrecursive_objectsstate_generatorsdeep_constructselfrrr__init__szBaseConstructor.__init__cCs|SN) check_noderrrr check_dataszBaseConstructor.check_datacCs&||r"tddd|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_noderrnoderrrget_single_data/s zBaseConstructor.get_single_datacCsH||}|jr2|j}g|_|D]}|D]}q(q q i|_i|_d|_|Sr)construct_objectrrrr)rr"datar generatordummyrrrr6s z"BaseConstructor.construct_documentFc Cs||jvr|j|S|r$|j}d|_||jvr>tddd|jd|j|<d}d}|j|jvrj|j|j}n|jD]:}|durp|j|rp|jt |d}|j|}qqpd|jvr|j}|jd}nTd|jvr|jd}n>t |t r|j j }n*t |tr|j j}nt |tr|j j}|dur2|||}n ||||}t |tjrz|}t|}|jrn|D]} qdn |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$CsZ                     z BaseConstructor.construct_objectcCs&t|ts tddd|j|j|jS)Nz$expected a scalar node, but found %s)r.r/ridr(valuer!rrrr1us  z BaseConstructor.construct_scalarcs6t|ts tddd|j|jfdd|jDS)Nz&expected a sequence node, but found %scsg|]}j|dqS)r:)r$).0childr:rrr sz6BaseConstructor.construct_sequence..)r.r2rr=r(r>rr"r:rrBrr3|s  z"BaseConstructor.construct_sequencecCs|t|ts tddd|j|ji}|jD]L\}}|j||d}t|tjj s`td|jd|j|j||d}|||<q*|S)N%expected a mapping node, but found %sr?while constructing a mappingzfound unhashable key) r.r4rr=r(r>r$ collectionsabcHashable)rr"r:mappingkey_node value_noderr>rrrr5s  z!BaseConstructor.construct_mappingcCsbt|ts tddd|j|jg}|jD]2\}}|j||d}|j||d}|||fq*|S)NrEr?)r.r4rr=r(r>r$r9)rr"r:pairsrKrLrr>rrrconstruct_pairss zBaseConstructor.construct_pairscCs$d|jvr|j|_||j|<dS)Nr*)__dict__r*copy)clsr)r;rrradd_constructors  zBaseConstructor.add_constructorcCs$d|jvr|j|_||j|<dS)Nr+)rOr+rP)rQr<Zmulti_constructorrrradd_multi_constructors  z%BaseConstructor.add_multi_constructorN)F)F)F)F)r r r r*r+rrrr r#rr$r1r3r5rN classmethodrRrSrrrrrs" 2    rcseZdZfddZddZd(fdd Zdd Zd dd dd dd Zd d ZddZ dZ e e e krne e 9Z qXe e Z ddZ ddZ edejZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'ZZS))rcs>t|tr2|jD] \}}|jdkr||Sqt|S)Ntag:yaml.org,2002:value)r.r4r>r)r1super)rr"rKrLr0rrr1s   z SafeConstructor.construct_scalarc Csg}d}|t|jkr|j|\}}|jdkr|j|=t|trZ||||jnt|trg}|jD]<}t|tstd|j d|j |j ||| |jqn| |D]}||qntd|j d|j |j q|jdkrd|_|d7}q|d7}q|r||j|_dS) Nr ztag:yaml.org,2002:mergerFz,expected a mapping for merging, but found %sz@expected a mapping or list of mappings for merging, but found %srUtag:yaml.org,2002:strr) r-r>r)r.r4flatten_mappingextendr2rr(r=r9reverse) rr"mergeindexrKrLZsubmergesubnoder>rrrrYsJ          zSafeConstructor.flatten_mappingFcs$t|tr||tj||dS)Nr?)r.r4rYrVr5rDrWrrr5s  z!SafeConstructor.construct_mappingcCs||dSrr1r!rrrconstruct_yaml_nulls z#SafeConstructor.construct_yaml_nullT)ZyesnotrueZfalseZonZoffcCs||}|j|Sr)r1 bool_valueslower)rr"r>rrrconstruct_yaml_bools z#SafeConstructor.construct_yaml_boolcCs ||}|dd}d}|ddkr*d}|ddvrB|dd}|dkrNdS|d rn|t|d dd S|d r|t|d dd S|ddkr|t|d Sd|vrdd|dD}|d}d}|D]}|||7}|d9}q||S|t|SdS)N_rr -+-0Z0b0x:cSsg|] }t|qSr)intr@partrrrrCz6SafeConstructor.construct_yaml_int..<)r1replacer,rqsplitr[rr"r>signdigitsbaseZdigitrrrconstruct_yaml_ints2           z"SafeConstructor.construct_yaml_intgu<7~cCs||}|dd}d}|ddkr.d}|ddvrF|dd}|dkrX||jS|d krf|jSd |vrd d |d D}|d}d }|D]}|||7}|d9}q||S|t|SdS)Nrfrgrr rhrirjz.infz.nanrpcSsg|] }t|qSr)floatrrrrrrCrtz8SafeConstructor.construct_yaml_float..gru)r1rvrd inf_value nan_valuerwr[r}rxrrrconstruct_yaml_floats*       z$SafeConstructor.construct_yaml_floatc Csz||d}Wn8tyL}z tddd||jWYd}~n d}~00z&ttdrft|WSt|WSWn:t j y}z tddd||jWYd}~n d}~00dSNasciiz,failed to convert base64 data into ascii: %s decodebytesz failed to decode base64 data: %s r1encodeUnicodeEncodeErrorrr(hasattrbase64rZ decodestringbinasciiErrorrr"r>excrrrconstruct_yaml_binary&s   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}|dsZt|||St|d}t|d} t|d} d} d} |dr|ddd } t| d kr| d 7} qt| } |d rt|d } t|d pd}tj | |d}|d dkr| }t |} n|dr"tj j } tj||||| | | | dS)Nyearmonthdayhourminutesecondr fractionrkZtz_signtz_hour tz_minute)ZhoursZminutesrhZtz)tzinfo) r1timestamp_regexprr> groupdictrqdatetimedater-Z timedeltatimezoneZutc)rr"r>rvaluesrrrrrrrrrrZdeltarrrconstruct_yaml_timestampBs<             z(SafeConstructor.construct_yaml_timestampccsg}|Vt|ts,td|jd|j|j|jD]}t|tsXtd|jd|j|jt|jdkrtd|jdt|j|j|jd\}}||}||}| ||fq2dS)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 r.r2rr(r=r>r4r-r$r9)rr"Zomapr^rKrLrr>rrrconstruct_yaml_omapas*       z#SafeConstructor.construct_yaml_omapccsg}|Vt|ts,td|jd|j|j|jD]}t|tsXtd|jd|j|jt|jdkrtd|jdt|j|j|jd\}}||}||}| ||fq2dS)Nzwhile constructing pairsrrrrr r)rr"rMr^rKrLrr>rrrconstruct_yaml_pairsws*       z$SafeConstructor.construct_yaml_pairsccs$t}|V||}||dSr)setr5updaterr"r%r>rrrconstruct_yaml_sets z"SafeConstructor.construct_yaml_setcCs ||Srr_r!rrrconstruct_yaml_strsz"SafeConstructor.construct_yaml_strccsg}|V|||dSr)rZr3)rr"r%rrrconstruct_yaml_seqsz"SafeConstructor.construct_yaml_seqccs"i}|V||}||dSr)r5rrrrrconstruct_yaml_maps z"SafeConstructor.construct_yaml_mapccsN||}|Vt|dr4|j|dd}||n||}|j|dS)N __setstate__Tr?)__new__rr5rrOr)rr"rQr%staterrrconstruct_yaml_objects    z%SafeConstructor.construct_yaml_objectcCstddd|j|jdS)Nz0could not determine a constructor for the tag %r)rr)r(r!rrrconstruct_undefinedsz#SafeConstructor.construct_undefined)F)r r r r1rYr5r`rcrer|r~rrrrecompileXrrrrrrrrrr __classcell__rrrWrrs@ #       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:setrXztag:yaml.org,2002:seqztag:yaml.org,2002:mapc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ d%ddZ d&ddZ ddZ ddZd'ddZd(ddZdd Zd)d!d"Zd#d$ZdS)*rcCsddgS)Nz^extend$z^__.*__$rrrrrget_state_keys_blacklistsz(FullConstructor.get_state_keys_blacklistcCs.t|ds(tdd|d|_|jS)Nstate_keys_blacklist_regexp(|))rrrjoinrrrrrrrs z/FullConstructor.get_state_keys_blacklist_regexpcCs ||Srr_r!rrrconstruct_python_strsz$FullConstructor.construct_python_strcCs ||Srr_r!rrrconstruct_python_unicodesz(FullConstructor.construct_python_unicodec Csz||d}Wn8tyL}z tddd||jWYd}~n d}~00z&ttdrft|WSt|WSWn:t j y}z tddd||jWYd}~n d}~00dSrrrrrrconstruct_python_bytess   z&FullConstructor.construct_python_bytescCs ||Sr)r|r!rrrconstruct_python_longsz%FullConstructor.construct_python_longcCst||Sr)complexr1r!rrrconstruct_python_complexsz(FullConstructor.construct_python_complexcCst||Sr)tupler3r!rrrconstruct_python_tuple sz&FullConstructor.construct_python_tupleFc Cs|std|d||r^z t|Wn:ty\}z"td|d||f|WYd}~n d}~00|tjvrztd|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|std|d|d|vr,|dd\}}nd}|}|rz t|Wn:ty~}z"td|d||f|WYd}~n d}~00|tjvrtd|d||tj|}t||std|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_names8     z FullConstructor.find_python_namecCs2||}|r$td|jd||j|||jS)Nz while constructing a Python name&expected the empty value, but found %r)r1rr(rrsuffixr"r>rrrconstruct_python_name5s   z%FullConstructor.construct_python_namecCs2||}|r$td|jd||j|||jS)Nrr)r1rr(rrrrrconstruct_python_module<s   z'FullConstructor.construct_python_moduleNcCs~|sg}|si}|||j}|sFt|tsFtd|jdt||j|rlt|trl|j|g|Ri|S||i|SdS)Nz$while constructing a Python instancezexpected a class, but found %r)rr(r.typerr)rrr"argskwdsnewobjrrQrrrmake_python_instanceCs z$FullConstructor.make_python_instancecCst|dr||ni}t|tr8t|dkr8|\}}t|drp|sb|rb|D]}||qR|j|n|r~||| D]"\}}|s||t |||qdS)NrrlrO) rrr.rr-keysrrOritemssetattr)rinstancerrZ slotstaterr>rrrset_python_instance_stateSs        z)FullConstructor.set_python_instance_stateccs>|j||dd}|Vt|d}|j||d}|||dS)NTrrr?)rrr5r)rrr"rr:rrrrconstruct_python_objectfs  z'FullConstructor.construct_python_objectc Cst|tr*|j|dd}i}i}g}i}nJ|j|dd} | dg}| di}| di}| dg}| di}||||||} |r|| ||r| ||r|D]} || | | <q| S)NTr?rrr listitems dictitems)r.r2r3r5getrrrZ) 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_new)F)F)NNFF)F)F)r r r rrrrrrrrrrrrrrrrrrrrrrs$     #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) rcstt|j||ddSNT)r)rVrrrrrrWrrrsz$UnsafeConstructor.find_python_modulecstt|j||ddSr)rVrrrrWrrrsz"UnsafeConstructor.find_python_nameNFcstt|j|||||ddSr)rVrr)rrr"rrrrWrrrs  z&UnsafeConstructor.make_python_instancecstt|j||ddSr)rVrr)rrrrWrrrs z+UnsafeConstructor.set_python_instance_state)NNF)r r r rrrrrrrrWrrs  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@s eZdZdS)rNr rrrrrsr),__all__errorZnodescollections.abcrGrrrrrr6ZMarkedYAMLErrorrrrrRr`rer|rrrrrrrrrrrrrrrrrrSrrrrrrrrrrrs 84