ROOTPLOIT
Server: LiteSpeed
System: Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User: niphet (1079)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //lib64/python3.8/lib2to3/__pycache__/btm_utils.cpython-38.opt-1.pyc
U

e5d&@s|dZddlmZddlmZmZddlmZmZeZ	eZ
ejZeZ
dZdZdZGdd	d	eZdddZd
dZddZd
S)z0Utility functions used by the btm_matcher module)pytree)grammartoken)pattern_symbolspython_symbolsc@s:eZdZdZd
ddZddZddZd	d
ZddZdS)MinNodezThis class serves as an intermediate representation of the
    pattern tree during the conversion to sets of leaf-to-root
    subpatternsNcCs.||_||_g|_d|_d|_g|_g|_dS)NF)typenamechildrenleafparentalternativesgroup)selfrrr)/usr/lib64/python3.8/lib2to3/btm_utils.py__init__szMinNode.__init__cCst|jdt|jS)N )strrr)rrrr__repr__szMinNode.__repr__cCs|}g}|r|jtkr^|j|t|jt|jkrRt|jg}g|_|j}qn|j}d}q|jtkr|j	|t|j	t|jkrt
|j	}g|_	|j}qn|j}d}q|jtjkr|j
r||j
n||j|j}q|S)zInternal method. Returns a characteristic path of the
        pattern tree. This method must be run for all leaves until the
        linear subpatterns are merged into a singleN)rTYPE_ALTERNATIVESrappendlenr
tupler
TYPE_GROUPrget_characteristic_subpatterntoken_labelsNAMEr)rnodesubprrrleaf_to_root!s8


zMinNode.leaf_to_rootcCs&|D]}|}|r|SqdS)aDrives the leaf_to_root method. The reason that
        leaf_to_root must be run multiple times is because we need to
        reject 'group' matches; for example the alternative form
        (a | b c) creates a group [b c] that needs to be matched. Since
        matching multiple linear patterns overcomes the automaton's
        capabilities, leaf_to_root merges each group into a single
        choice based on 'characteristic'ity,

        i.e. (a|b c) -> (a|b) if b more characteristic than c

        Returns: The most 'characteristic'(as defined by
          get_characteristic_subpattern) path for the compiled pattern
          tree.
        N)leavesr#)rlr"rrrget_linear_subpatternKszMinNode.get_linear_subpatternccs*|jD]}|EdHq|js&|VdS)z-Generator that returns the leaves of the treeN)r
r$)rchildrrrr$`s
zMinNode.leaves)NN)	__name__
__module____qualname____doc__rrr#r&r$rrrrr
s
	*r
Nc
Csd}|jtjkr|jd}|jtjkrt|jdkrFt|jd|}nFttd}|jD]4}|j	|drlqVt||}|dk	rV|j
|qVn|jtjkrt|jdkrttd}|jD]}t||}|r|j
|q|jsd}nt|jd|}n|jtj
krt|jdtjr>|jdjdkr>t|jd|St|jdtjrd|jdjdkst|jdkrt|jddr|jdjdkrdSd	}d}d}d
}d}	d
}
|jD]d}|jtjkrd
}|}n*|jtjkrd	}|}	n|jtjkr|}t|dr|jdkrd	}
q|
rT|jd}t|dr^|jdkr^|jd}n
|jd}|jtjkr|jd
krttd}n4tt|jrttt|jd}nttt|jd}n\|jtjkr|jd}|tkrtt|d}nttj|d}n|jtjkrt||}|rL|	jdjdkr4d}n|	jdjdkrHnt|r|dk	r|jddD]&}t||}|dk	rj|j
|qj|r||_|S)z
    Internal function. Reduces a compiled pattern tree to an
    intermediate representation suitable for feeding the
    automaton. This also trims off any optional pattern elements(like
    [a], a*).
    N)rr([valueTF=any')rr*+r)rsymsZMatcherr
ZAlternativesrreduce_treer
rindexrZAlternativerZUnit
isinstancerZLeafr0hasattrZDetailsZRepeaterrr TYPE_ANYgetattrpysymsSTRINGstriptokensNotImplementedErrorr)
r!rZnew_noder'ZreducedrZdetails_nodeZalternatives_nodeZhas_repeaterZ
repeater_nodeZhas_variable_nameZ	name_leafrrrrr8gs













r8cst|ts|St|dkr"|dSg}g}dddddgg}d|D]d}tt|d	d
rDtt|fdd
r|||qDtt|fdd
r||qD||qD|r|}n|r|}n|r|}t|td
S)zPicks the most characteristic from a list of linear patterns
    Current order used is:
    names > common_names > common_chars
    rr,inforifnotNonez[]().,:cSst|tkSN)rrxrrr<lambda>z/get_characteristic_subpattern.<locals>.<lambda>cst|to|kSrHr:rrI)common_charsrrrKrLcst|to|kSrHrMrI)common_namesrrrKrL)key)r:listrr3rec_testrmax)ZsubpatternsZsubpatterns_with_namesZsubpatterns_with_common_namesZsubpatterns_with_common_chars
subpatternr)rNrOrrs6


rccs8|D].}t|ttfr(t||EdHq||VqdS)zPTests test_func on all items of sequence and items of included
    sub-iterablesN)r:rQrrR)ZsequenceZ	test_funcrJrrrrRsrR)N)r+rZpgen2rrZpygramrrr7r>ZopmaprArr<rrobjectr
r8rrRrrrr<module>sW
%