U if>3@sddlZedZd"ddZddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ eee e e e dZ iZGdddZd#ddZd$ddZd%ddZd&d d!ZdS)'Nz\('[^']*'|\"[^\"]*\"|::|//?|\.\.|\(\)|[/.*:\[\]\(\)@=])|((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|\s+c cs|r|dnd}d}t|D]}|\}}|r|ddkrd|kr|dd\}}z"|s^t|d|||ffVWqtk rtd|dYqXn"|r|s|d||ffVn|Vd}q |V|d k}q dS) NFr{:z{%s}%sz!prefix %r not found in prefix map@)getxpath_tokenizer_refindallsplitKeyError SyntaxError) pattern namespacesZdefault_namespaceZparsing_attributetokenZttypetagprefixZurir:/opt/alt/python38/lib64/python3.8/xml/etree/ElementPath.pyxpath_tokenizerIs&rcCs>|j}|dkr:i|_}|jD]}|D] }|||<q*q"|SN) parent_maprootiter)contextrperrrget_parent_mapas  rcCs |dddkp|dddkS)N{*}}*rrrrr_is_wildcard_tagksr"csttdkr"fdd}ndkr:fdd}ndddkrddtt dddfd d}nLd dd krƈdd tdtfd d}ntd|S)Nz{*}*c3s |D]}|jr|VqdSrr!rresultelem _isinstance_strrrselectus z_prepare_tag..selectz{}*c3s0|D]&}|j}|r|ddkr|VqdS)Nrrr!rr$r%Zel_tagr&rrr){srrc3s8|D].}|j}|ks,|r|kr|VqdSrr!r*)r'r(no_nssuffixrrrr)srr c3s0|D]&}|j}|r|kr|VqdSrr!r*)r'r(nsns_onlyrrr)szinternal parser error, got ) isinstancestrslicelen RuntimeError)rr)r)r'r(r,r/r0r-rr _prepare_tagos     r6csR|dtr&tfdd}n(dddkrBddfdd}|S)Nrcsdd}|||S)Ncss|D]}|EdHqdSrr)r$r%rrr select_childsz3prepare_child..select..select_childrrr$r7 select_tagrrr)szprepare_child..selectr+{}c3s(|D]}|D]}|jkr |Vq qdSrr!rr$r%rr!rrr)s )r"r6nextrr)rr:rr prepare_childs  r@cCs dd}|S)Ncss|D]}|EdHqdSrrr#rrrr)szprepare_star..selectrr=rrr prepare_starsrAcCs dd}|S)Ncss|EdHdSrr)rr$rrrr)szprepare_self..selectrr=rrr prepare_selfsrBcsz |}Wntk r YdSX|ddkr4dn|dsF|dntdtrltfdd}n(dddkrddfd d}|S) Nr*rzinvalid descendantcsdd}|||S)Ncss*|D] }|D]}||k r|VqqdSrr)r$r%rrrrr7s z8prepare_descendant..select..select_childrr8r9rrr)sz"prepare_descendant..selectr+r;c3s,|D]"}|D]}||k r|VqqdSrrDr<r!rrr)s) StopIterationr r"r6r=rr?rprepare_descendants      rFcCs dd}|S)Ncss@t|}i}|D]*}||kr||}||krd||<|VqdSr)r)rr$rZ result_mapr%parentrrrr)szprepare_parent..selectrr=rrrprepare_parents rHcsLg}g}z |}Wntk r(YdSX|ddkr8q|dkrBq|drr|ddddkrrd|dddf}||dpd||dqd |}|d kr|dfd d }|S|d kr|d|dfdd }|S|dkrtd|ds|dfdd }|S|dksB|dkrxtd|dsx|d|drhfdd }n fdd }|S|dks|dks|dkr@|dkrt|dddkr0tdnl|ddkrtd|dkr,zt|ddWntk rtdYnXdkr0tdndfdd }|StddS) Nr])rrrz'"'r.-rz@-c3s"|D]}|dk r|VqdSrrr#)keyrrr)sz!prepare_predicate..selectz@-='c3s"|D]}|kr|VqdSrrLr#)rMvaluerrr)sz\-?\d+$c3s"|D]}|dk r|VqdSr)findr#r!rrr) sz.='z-='c3s:|D]0}|D] }d|kr|VqqqdSNr)r joinitertextr<)rrNrrr)s c3s&|D]}d|kr|VqdSrP)rQrRr#)rNrrr)sz-()z-()-zXPath position >= 1 expectedZlastzunsupported functionr+zunsupported expressionrz)XPath offset from last() must be negativec 3s^t|}|D]L}z.||}t||j}||kr<|VWq ttfk rVYq Xq dSr)rlistr r IndexErrorr )rr$rr%rGZelems)indexrrr)5s  zinvalid predicate)rEappendrQrematchintr ValueError)r>rZ signatureZ predicater)r)rUrMrrNrprepare_predicatesj     &        r[)rrC.z..z//[c@seZdZdZddZdS)_SelectorContextNcCs ||_dSr)r)selfrrrr__init__Psz_SelectorContext.__init__)__name__ __module__ __qualname__rr`rrrrr^Nsr^c Csj|dddkr|d}|f}|r6|tt|7}zt|}Wntk r@ttdkrjt|dddkrtdtt ||j }z |}Wnt k rYYdSXg}z| t |d||Wnt k rtddYnXz|}|ddkr|}Wqt k r0Yq4YqXq|t|<YnX|g}t|}|D]} | ||}qT|S) Nr./rCdrz#cannot use absolute path on elementrz invalid path)tuplesorteditems_cacher r4clearr rr__next__rErVopsr^) r%pathrZ cache_keyZselectorr>rr$rr)rrriterfindXsD    rncCstt|||dSr)r>rnr%rmrrrrrOsrOcCstt|||Sr)rSrnrorrrr sr cCs:ztt|||}|jpdWStk r4|YSXdSrP)r>rntextrE)r%rmdefaultrrrrfindtexts  rr)N)N)N)N)NN)rWcompilerrrr"r6r@rArBrFrHr[rlrir^rnrOr rrrrrr;s4  ) b  ,