Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/__pycache__/mccabe.cpython-311.pyc

�

�܋f�)��f�dZddlmZddlZddlZddlZddlmZ	ddlZddlm	Z	n#e
$rddlmZm	Z	YnwxYwdZGd�d	e
��ZGd
�de
��ZGd�d
e
��ZGd�de��ZGd�de
��Zdd�Zdd�Zd�Zdd�Zedkreejdd���dSdS)z� Meager code path measurement tool.
    Ned Batchelder
    http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
    MIT License.
�)�with_statementN)�defaultdict)�iter_child_nodes)�astrz0.7.0c�*�eZdZdZd�Zd�Zd�Zd�ZdS)�
ASTVisitorz'Performs a depth-first walk of the AST.c�"�d|_i|_dS�N)�node�_cache��selfs �W/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/mccabe.py�__init__zASTVisitor.__init__s����	������c�F�t|��D]}|j|g|�R��dSr
)r�dispatch)rr�args�childs    r�defaultzASTVisitor.defaults@��%�d�+�+�	(�	(�E��D�M�%�'�$�'�'�'�'�'�	(�	(rc���||_|j}|j�|��}|�/|j}t|jd|z|j��}||j|<||g|�R�S)N�visit)r�	__class__r�get�__name__�getattr�visitorr)rrr�klass�meth�	classNames      rrzASTVisitor.dispatch!sm����	�����{���u�%�%���<���I��4�<��9�)<�d�l�K�K�D�!%�D�K����t�D� �4� � � � rc�H�||_|j|_|j|g|�R�dS)z&Do preorder walk of tree using visitorN)rrr)r�treerrs    r�preorderzASTVisitor.preorder+s2������
��
���
�d�"�T�"�"�"�"�"�"rN)r�
__module__�__qualname__�__doc__rrrr#�rrrrsV������1�1����(�(�(�!�!�!�#�#�#�#�#rrc�"�eZdZdd�Zd�Zd�ZdS)�PathNode�circlec�"�||_||_dSr
)�name�look)rr,r-s   rrzPathNode.__init__3s����	���	�	�	rc�h�td|j|j|���fz��dS)Nznode [shape=%s,label="%s"] %d;)�printr-r,�dot_idr
s r�to_dotzPathNode.to_dot7s>��
�.��I�t�y�$�+�+�-�-�21�1�	2�	2�	2�	2�	2rc� �t|��Sr
)�idr
s rr0zPathNode.dot_id;s
���$�x�x�rN)r*)rr$r%rr1r0r'rrr)r)2sF����������2�2�2�����rr)c�(�eZdZdd�Zd�Zd�Zd�ZdS)�	PathGraphrc�p�||_||_||_||_t	t
��|_dSr
)r,�entity�lineno�columnr�list�nodes)rr,r7r8r9s     rrzPathGraph.__init__@s1����	���������� ��&�&��
�
�
rc�Z�|j|�|��g|j|<dSr
)r;�append)r�n1�n2s   r�connectzPathGraph.connectGs+���
�2����b�!�!�!���
�2���rc�8�td��|jD]}|����|j���D]C\}}|D];}t|����d|����d����<�Dtd��dS)Nz
subgraph {z -- �;�})r/r;r1�itemsr0)rr�nexts�nexts    rr1zPathGraph.to_dotLs���
�l�����J�	�	�D��K�K�M�M�M�M��:�+�+�-�-�	D�	D�K�D�%��
D�
D���T�[�[�]�]�]�]�D�K�K�M�M�M�M�B�C�C�C�C�
D�
�c�
�
�
�
�
rc��td�|j���D����}t|j��}||z
dzS)zG Return the McCabe complexity for the graph.
            V-E+2
        c�,�g|]}t|����Sr')�len)�.0�ns  r�
<listcomp>z(PathGraph.complexity.<locals>.<listcomp>Ys��=�=�=�A��Q���=�=�=r�)�sumr;�valuesrI)r�	num_edges�	num_nodess   r�
complexityzPathGraph.complexityUsK���=�=���):�):�)<�)<�=�=�=�>�>�	���
�O�O�	��9�$�q�(�(rN)r)rr$r%rr@r1rRr'rrr5r5?sU������'�'�'�'����
���)�)�)�)�)rr5c���eZdZdZ�fd�Zd�Zd�Zd�ZeZd�Z	d�Z
d�Z�fd	�Zd
�Z
e
xZxZZd�Zdd
�Zd�Zd�ZeZd�ZeZ�xZS)�PathGraphingAstVisitorz\ A visitor for a parsed Abstract Syntax Tree which finds executable
        statements.
    c���tt|�����d|_i|_|���dS)N�)�superrTr�	classname�graphs�reset)rrs �rrzPathGraphingAstVisitor.__init__cs?���
�$�d�+�+�4�4�6�6�6��������
�
�����rc�"�d|_d|_dSr
)�graph�tailr
s rrZzPathGraphingAstVisitor.resetis����
���	�	�	rc�:�|D]}|�|���dSr
)r)r�	node_listrs   r�
dispatch_listz$PathGraphingAstVisitor.dispatch_listms0���	 �	 �D��M�M�$�����	 �	 rc��|jr|j�|j��}n|j}d|j|j|fz}|j��|�|��}||_|�|j��tdd���}|j�
|j|��|j�
||��||_dSt|||j|j��|_t|��}||_|�|j��|j|j|j�|j��<|�
��dS)Nz	%d:%d: %rrV�point�r-)rXr,r8�
col_offsetr\�appendPathNoder]r`�bodyr)r@r5rYrZ)rrr7r,�pathnode�bottoms      r�visitFunctionDefz'PathGraphingAstVisitor.visitFunctionDefqs0���>�	�#�~�~�t�y�y�9�F�F��Y�F��d�k�4�?�F�C�C���:�!��*�*�4�0�0�H� �D�I����t�y�)�)�)��b�w�/�/�/�F��J���t�y�&�1�1�1��J���x��0�0�0��D�I�I�I�"�4����d�o�N�N�D�J���~�~�H� �D�I����t�y�)�)�)�@D�
�D�K�$�.�.�$�)�)�<�=��J�J�L�L�L�L�Lrc��|j}|xj|jdzz
c_|�|j��||_dS)N�.)rXr,r`rf)rr�
old_classnames   r�
visitClassDefz$PathGraphingAstVisitor.visitClassDef�s@����
����$�)�c�/�)������4�9�%�%�%�&����rc��|jsdSt|��}|j�|j|��||_|Sr
)r]r)r\r@)rr,rgs   rrez%PathGraphingAstVisitor.appendPathNode�sB���y�	��F��D�>�>���
���4�9�h�/�/�/���	��rc�\�|j�d}n|j}d|z}|�|��dS)NrzStmt %d)r8re)rrr8r,s    r�visitSimpleStatementz+PathGraphingAstVisitor.visitSimpleStatement�s<���;���F�F��[�F��6�!�����D�!�!�!�!�!rc���t|tj��r|�|��dSt	t
|��j|g|�R�dSr
)�
isinstancer�stmtrprWrTr)rrrrs   �rrzPathGraphingAstVisitor.default�s^����d�C�H�%�%�	E��%�%�d�+�+�+�+�+�7�E�(�$�/�/�7��D�t�D�D�D�D�D�Drc�F�d|jz}|�||��dS)NzLoop %d�r8�	_subgraph�rrr,s   r�	visitLoopz PathGraphingAstVisitor.visitLoop�s(���4�;�&�����t�T�"�"�"�"�"rc�F�d|jz}|�||��dS)NzIf %drurws   r�visitIfzPathGraphingAstVisitor.visitIf�s(�����$�����t�T�"�"�"�"�"rr'c�V�|j�ut|||j|j��|_t	|��}|�|||��|j|j|j�|��<|���dS|�	|��}|�|||��dS)z?create the subgraphs representing any `if` and `for` statementsN)
r\r5r8rdr)�_subgraph_parserYrXrZre)rrr,�extra_blocksrgs     rrvz PathGraphingAstVisitor._subgraph�s����:��"�4��t�{�D�O�L�L�D�J���~�~�H�� � ��x��>�>�>�;?�:�D�K�$�.�.�$�$�7�8��J�J�L�L�L�L�L��*�*�4�0�0�H�� � ��x��>�>�>�>�>rc�(�g}||_|�|j��|�|j��|D]=}||_|�|j��|�|j���>|jr<||_|�|j��|�|j��n|�|��|r:tdd���}|D]}|j�||���||_dSdS)z@parse the body and any `else` block of `if` and `for` statementsrVrbrcN)r]r`rfr=�orelser)r\r@)rrrgr}�
loose_ends�extrarh�les        rr|z&PathGraphingAstVisitor._subgraph_parse�s,���
���	����4�9�%�%�%����$�)�$�$�$�!�	)�	)�E� �D�I����u�z�*�*�*����d�i�(�(�(�(��;�	(� �D�I����t�{�+�+�+����d�i�(�(�(�(����h�'�'�'��	��b�w�/�/�/�F� �
/�
/���
�"�"�2�v�.�.�.�.��D�I�I�I�		�	rc�T�d|jz}|�|||j���dS)NzTryExcept %d)r})r8rv�handlersrws   r�visitTryExceptz%PathGraphingAstVisitor.visitTryExcept�s.�����+�����t�T��
��>�>�>�>�>rc�x�d|jz}|�|��|�|j��dS)NzWith %d)r8rer`rfrws   r�	visitWithz PathGraphingAstVisitor.visitWith�s>���4�;�&�����D�!�!�!����4�9�%�%�%�%�%r)r')rr$r%r&rrZr`ri�visitAsyncFunctionDefrmrerprrx�
visitAsyncFor�visitFor�
visitWhilerzrvr|r��visitTryr��visitAsyncWith�
__classcell__)rs@rrTrT^s4����������������� � � ����4-��'�'�'����"�"�"�E�E�E�E�E�#�#�#�-6�5�M�5�H�z�#�#�#�?�?�?�?����,?�?�?��H�&�&�&�
�N�N�N�N�NrrTc�^�eZdZdZdZeZdZdZdZ	d�Z
ed���Zed���Z
d	�Zd
S)�
McCabeCheckerz%McCabe cyclomatic complexity checker.�mccabe�C901zC901 %r is too complex (%d)���c��||_dSr
)r")rr"�filenames   rrzMcCabeChecker.__init__�s
����	�	�	rc�
�d}ddtddd�}t|dd��}t|t��r?|�d��|j|fi|��|j�d	��dS|j|fi|��dS)
Nz--max-complexityr��storezMcCabe complexity threshold�True)r�action�type�help�parse_from_config�config_optionsr�zmax-complexity)�intrrrr:�pop�
add_optionr�r=)�cls�parser�flag�kwargs�config_optss     r�add_optionszMcCabeChecker.add_options�s���!�����1�!'�
�
���f�&6��=�=���k�4�(�(�	.��J�J�*�+�+�+��F��d�-�-�f�-�-�-��!�(�(�)9�:�:�:�:�:��F��d�-�-�f�-�-�-�-�-rc�8�t|j��|_dSr
)r��max_complexity)r��optionss  r�
parse_optionszMcCabeChecker.parse_optionss�� ��!7�8�8����rc#�lK�|jdkrdSt��}|�|j|��|j���D]a}|���|jkrB|j|j|���fz}|j	|j
|t|��fV��bdS)Nr)r�rTr#r"rYrOrR�_error_tmplr7r8r9r�)rrr\�texts    r�runzMcCabeChecker.runs��������"�"��F�(�*�*�������G�,�,�,��^�*�*�,�,�	C�	C�E����!�!�D�$7�7�7��'�5�<��9I�9I�9K�9K�*L�L���l�E�L�$��T�
�
�B�B�B�B��	C�	CrN)rr$r%r&r,�__version__�version�_coder�r�r�classmethodr�r�r�r'rrr�r��s�������/�/��D��G��E�/�K��N�����.�.��[�.�$�9�9��[�9�C�C�C�C�Crr���stdinc��	t||dtj��}nP#t$rCt	j��d}tj�d|�d|�d���YdSwxYwg}|t_	t||���
��D]"\}}}}	|�d|||fz���#t|��dkrdStd�|����t|��S)N�exec�zUnable to parse z: �
rz%s:%d:1: %s)�compiler�
PyCF_ONLY_AST�SyntaxError�sys�exc_info�stderr�writer�r�r�r=rIr/�join)
�code�	thresholdr�r"�e�complxr8�offsetr��checks
          r�get_code_complexityr�s����t�X�v�s�/@�A�A���������L�N�N�1����
����x�x�x����C�D�D�D��q�q�����
�F�#,�M� �'4�T�8�'D�'D�'H�'H�'J�'J�@�@�#����e��
�
�m�x���&>�>�?�?�?�?�
�6�{�{�a����q�	�$�)�)�F�
�
�����v�;�;�s��A	A,�+A,c�D�t|��}t|||���S)z"Returns the complexity of a module)r�)�_readr�)�module_pathr�r�s   r�get_module_complexityr�$s$������D��t�Y��E�E�E�Erc��dtjcxkrdkrAnn>t|d��5}|���cddd��S#1swxYwYdSdtjcxkrdkr�ndS		t|d��5}t	j|j��\}}ddd��n#1swxYwYn\#tttf$rBt|d���5}|���cddd��cYS#1swxYwYYnwxYwt|d|���5}|���cddd��S#1swxYwYdSdS)	N)rM�)�r�rU)�r�rbzlatin-1)�encoding�r)
r��version_info�open�read�tokenize�detect_encoding�readline�LookupErrorr��UnicodeError)r��fr��_s    rr�r�*s���
�� �)�)�)�)�6�)�)�)�)�)�
�(�D�
!�
!�	�Q��6�6�8�8�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�3�#�	,�	,�	,�	,�f�	,�	,�	,�	,�	,�	,�#�	 ��h��%�%�
E�� (� 8��� D� D�
��1�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E�
E����
E�
E�
E�
E����[�,�7�	 �	 �	 ��h��3�3�3�
 �q��v�v�x�x�
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 �
 �
 �	 �����(�C�(�
3�
3�
3�	�q��6�6�8�8�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�
-�	,s}�A�A�A�6B;�B/�#B;�/B3�3B;�6B3�7B;�;(D�#D�7
D�D
	�
D�
D
	�D�D�)E
�
E�Ec�^�|�tjdd�}tj��}|�ddddd���|�dd	d
ddd�
��|�|��\}}t
|d��}t||ddtj	��}t��}|�||��|jrttd��|j���D]:}|jr|���|jkr|����;td��dS|j���D]F}|���|jkr't|j|������GdS)Nr�z-dz--dot�dotzoutput a graphviz dot file�
store_true)�destr�r�z-mz--minr�zminimum complexity for outputr�)r�r�r�rrr�zgraph {rC)r��argv�optparse�OptionParserr��
parse_argsr�r�rr�rTr#r�r/rYrOr�rRr1r,)r��oparr�rr�r"rr\s        r�mainr�;s����|��x����|��� �"�"�D��O�O�D�'��5�l��L�L�L��O�O�D�'��8�u�������O�O�D�)�)�M�G�T���a��>�>�D��4��a��&�#�*;�<�<�D�$�&�&�G����T�7�#�#�#��{�
6�
�i�����^�*�*�,�,�	�	�E��%�
��$�$�&�&�'�*;�;�;��������
�c�
�
�
�
�
��^�*�*�,�,�	6�	6�E����!�!�W�%6�6�6��e�j�%�"2�"2�"4�"4�5�5�5��	6�	6r�__main__r�)r�r�)r�r
)r&�
__future__rr�r�r��collectionsrrr�ImportError�flake8.utilr��objectrr)r5rTr�r�r�r�r�rr�r'rr�<module>r�s����
&�%�%�%�%�%�����
�
�
�
�����#�#�#�#�#�#�2��J�J�J�$�$�$�$�$�$�$���2�2�2�1�1�1�1�1�1�1�1�1�1�2������#�#�#�#�#��#�#�#�8
�
�
�
�
�v�
�
�
�)�)�)�)�)��)�)�)�>C�C�C�C�C�Z�C�C�C�L*C�*C�*C�*C�*C�F�*C�*C�*C�Z����&F�F�F�F����"6�6�6�6�<�z����D���!�"�"��������s�
'�
7�7

Hacked By AnonymousFox1.0, Coded By AnonymousFox