OwlCyberSecurity - MANAGER
Edit File: btm_utils.cpython-33.pyo
� ��f'��c���������������@���s����d��Z��d�d�l�m�Z�d�d�l�m�Z�m�Z�d�d�l�m�Z�m�Z�e�Z �e�Z �e�j�Z�e�Z �d�Z�d�Z�d�Z�Gd�d����d�e���Z�d�d �d ���Z�d�d����Z�d �d����Z�d�S(���u0���Utility functions used by the btm_matcher modulei���(���u���pytree(���u���grammaru���token(���u���pattern_symbolsu���python_symbolsi���i���c�������������B���s\���|��Ee��Z�d��Z�d�Z�d�d�d�d���Z�d�d����Z�d�d����Z�d�d ����Z�d �d����Z �d�S( ���u���MinNodeu����This class serves as an intermediate representation of the pattern tree during the conversion to sets of leaf-to-root subpatternsc�������������C���sC���|�|��_��|�|��_�g��|��_�d�|��_�d��|��_�g��|��_�g��|��_�d��S(���NF( ���u���typeu���nameu���childrenu���Falseu���leafu���Noneu���parentu���alternativesu���group(���u���selfu���typeu���name(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���__init__���s���� u���MinNode.__init__c�������������C���s���t��|��j���d�t��|��j���S(���Nu��� (���u���stru���typeu���name(���u���self(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���__repr__���s����u���MinNode.__repr__c�������������C���sU��|��}�g��}�xB|�rP|�j��t�k�r��|�j�j�|���t�|�j���t�|�j���k�r|�t�|�j���g�}�g��|�_�|�j�}�q�q��|�j�}�d�}�Pn��|�j��t �k�r|�j �j�|���t�|�j ���t�|�j���k�r��t�|�j ���}�g��|�_ �|�j�}�q�q|�j�}�d�}�Pn��|�j��t�j �k�r4|�j�r4|�j�|�j���n�|�j�|�j����|�j�}�q�W|�S(���u����Internal 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(���u���typeu���TYPE_ALTERNATIVESu���alternativesu���appendu���lenu���childrenu���tupleu���parentu���Noneu ���TYPE_GROUPu���groupu���get_characteristic_subpatternu���token_labelsu���NAMEu���name(���u���selfu���nodeu���subp(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���leaf_to_root!���s8���� u���MinNode.leaf_to_rootc�������������C���s1���x*�|��j�����D]�}�|�j����}�|�r �|�Sq �Wd�S(���u���Drives 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(���u���leavesu���leaf_to_root(���u���selfu���lu���subp(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���get_linear_subpatternK���s����u���MinNode.get_linear_subpatternc�������������c���sE���x-�|��j��D]"�}�x�|�j����D]�}�|�Vq�Wq �W|��j��sA�|��Vn��d�S(���u-���Generator that returns the leaves of the treeN(���u���childrenu���leaves(���u���selfu���childu���x(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���leaves`���s ���� u���MinNode.leavesN( ���u���__name__u ���__module__u���__qualname__u���__doc__u���Noneu���__init__u���__repr__u���leaf_to_rootu���get_linear_subpatternu���leaves(���u ���__locals__(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���MinNode���s��� *u���MinNodec������� ������C���s��d�}�|��j�t�j�k�r(�|��j�d�}��n��|��j�t�j�k�r��t�|��j���d�k�rh�t�|��j�d�|���}�q�t�d�t ���}�x�|��j�D]P�}�|��j�j �|���d�r��q��n��t�|�|���}�|�d�k �r��|�j�j�|���q��q��Wn'|��j�t�j�k�rxt�|��j���d�k�r_t�d�t ���}�x9�|��j�D].�}�t�|�|���}�|�r|�j�j�|���qqW|�j�sud�}�quq�t�|��j�d�|���}�n�|��j�t�j�k�r�t�|��j�d�t�j���r�|��j�d�j�d�k�r�t�|��j�d�|���St�|��j�d�t�j���r�|��j�d�j�d�k�s=t�|��j���d�k�rAt�|��j�d�d���rA|��j�d�j�d�k�rAd�Sd�}�d�}�d�}�d�}�d�} �d�} �x��|��j�D]��}�|�j�t�j�k�r�d�}�|�}�n<�|�j�t�j�k�r�d�}�|�} �n�|�j�t�j�k�r�|�}�n��t�|�d���ro|�j�d�k�rod�} �qoqoW| �rA|��j�d�}�t�|�d���rN|�j�d�k�rN|��j�d �}�qNn �|��j�d�}�|�j�t�j�k�r�|�j�d �k�r�t�d�t���}�qTt�t�|�j���r�t�d�t�t�|�j�����}�qTt�d�t�t�|�j�����}�n��|�j�t�j�k�r0|�j�j�d���}�|�t�k�rt�d�t�|���}�qTt�d�t�j�d�|���}�n$�|�j�t�j�k�rTt�|�|���}�n��|�r�| �j�d�j�d �k�ryd�}�q�| �j�d�j�d�k�r�q�t ���n��|�r�|�d�k �r�xL�|�j�d�d���D]4�}�t�|�|���}�|�d�k �r�|�j�j�|���q�q�Wq�n��|�r|�|�_!�n��|�S(���u���� 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*). i����i���u���typei���u���(u���[u���valueu���=i���u���anyu���'u���nameu���*u���+NTFi����("���u���Noneu���typeu���symsu���Matcheru���childrenu���Alternativesu���lenu���reduce_treeu���MinNodeu���TYPE_ALTERNATIVESu���indexu���appendu���Alternativeu ���TYPE_GROUPu���Unitu ���isinstanceu���pytreeu���Leafu���valueu���hasattru���Trueu���Falseu���Detailsu���Repeateru���token_labelsu���NAMEu���TYPE_ANYu���getattru���pysymsu���STRINGu���stripu���tokensu���NotImplementedErroru���parent( ���u���nodeu���parentu���new_nodeu���childu���reducedu���leafu���details_nodeu���alternatives_nodeu���has_repeateru ���repeater_nodeu���has_variable_nameu ���name_leafu���name(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���reduce_treeh���s����� u���reduce_treec����������������s5��t��|��t���s�|��St�|����d�k�r-�|��d�Sg��}�g��}�d�d�d�d�d�g���g��}�d����x��|��D]��}�t�t�|�d �d ��������ra�t�t�|����f�d�d ��������r��|�j�|���q��t�t�|���f�d�d ��������r��|�j�|���q��|�j�|���qa�qa�W|�r|�}��n�|�r|�}��n�|�r%|�}��n��t�|��d �t��S(���u����Picks the most characteristic from a list of linear patterns Current order used is: names > common_names > common_chars i���i����u���inu���foru���ifu���notu���Noneu���[]().,:c�������������S���s���t��|����t�k�S(���N(���u���typeu���str(���u���x(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���<lambda>����s����u/���get_characteristic_subpattern.<locals>.<lambda>c����������������s���t��|��t���o�|�����k�S(���N(���u ���isinstanceu���str(���u���x(���u���common_chars(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���<lambda>��s����c����������������s���t��|��t���o�|�����k�S(���N(���u ���isinstanceu���str(���u���x(���u���common_names(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���<lambda>��s����u���key(���u ���isinstanceu���listu���lenu���anyu���rec_testu���appendu���max(���u���subpatternsu���subpatterns_with_namesu���subpatterns_with_common_namesu���subpatterns_with_common_charsu ���subpattern(����(���u���common_charsu���common_namesu6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���get_characteristic_subpattern����s2���� u���get_characteristic_subpatternc�������������c���sW���xP�|��D]H�}�t��|�t�t�f���rD�x*�t�|�|���D]�}�|�Vq2�Wq�|�|���Vq�Wd�S(���uP���Tests test_func on all items of sequence and items of included sub-iterablesN(���u ���isinstanceu���listu���tupleu���rec_test(���u���sequenceu ���test_funcu���xu���y(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���rec_test��s ���� u���rec_testNi����i����i����(���u���__doc__u����u���pytreeu���pgen2u���grammaru���tokenu���pygramu���pattern_symbolsu���python_symbolsu���symsu���pysymsu���opmapu���tokensu���token_labelsu���TYPE_ANYu���TYPE_ALTERNATIVESu ���TYPE_GROUPu���objectu���MinNodeu���Noneu���reduce_treeu���get_characteristic_subpatternu���rec_test(����(����(����u6���/opt/alt/python33/lib64/python3.3/lib2to3/btm_utils.pyu���<module>���s��� X�%