OwlCyberSecurity - MANAGER
Edit File: style_guide.cpython-311.pyc
� ������hi=���������������������������d�Z�ddlZddlZddlZddlZddlZddlZddlZddlm Z �ddlm Z �ddlmZ�ddlmZ�ddlm Z �ddlmZ�dd lmZ�dd lmZ�ddlmZ�ddlmZ�dd lmZ�ddlmZ�ddlmZ�dZ�ej��������e������������Z�G�d��dej��������������������Z�G�d��dej��������������������Z �G�d��dej��������������������Z!deee"������������������deee"������������������dee"df���������fd�Z#deee"������������������dee"df���������dee"���������deee"������������������dee"df���������f d�Z$�G�d��d ������������Z%�G�d!��d"������������Z&�G�d#��d$������������Z'dS�)%z0Implementation of the StyleGuide used by Flake8.�����N)�Dict)� Generator)�List)�Optional)�Sequence)�Set)�Tuple)�Union)�defaults)� statistics)�utils)�base)� Violation)� StyleGuidec�������������������������e�Zd�ZdZdZdZdS�)�Selectedz<Enum representing an explicitly or implicitly selected code.zexplicitly selectedzimplicitly selectedN��__name__� __module__�__qualname__�__doc__� Explicitly� Implicitly��������c/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/flake8/style_guide.pyr���r������s��������������F�F�&�J�&�J�J�Jr���r���c�������������������������e�Zd�ZdZdZdZdS�)�Ignoredz;Enum representing an explicitly or implicitly ignored code.zexplicitly ignoredzimplicitly ignoredNr���r���r���r���r���r���$���s��������������E�E�%�J�%�J�J�Jr���r���c�������������������������e�Zd�ZdZdZdZdS�)�Decisionz?Enum representing whether a code should be ignored or selected.z ignored errorzselected errorN)r���r���r���r���r���r���r���r���r���r ���r ���+���s��������������I�I��G��H�H�Hr���r ����option�extend�return.c������������������R�����g�|�pg��|pg��}t����������t����������|d�������������������������S��NT)�reverse��tuple�sorted)r!���r"����rets��� r����_explicitly_chosenr+���2���s6������ �-�V�\�r� ,�f�l�� ,�C����T�*�*�*�+�+�+r����default�extended_defaultc������������������h�����|�� g�|��|pg��}n g�|�|�|pg��}t����������t����������|d�������������������������S�r%���r'���)r!���r,���r-���r"���r*���s��� r����_select_ignorer/���;���sS���������(��(�&�,�B�(���<��<�*�<�f�l��<�����T�*�*�*�+�+�+r���c�������������������������e�Zd�ZdZdej��������ddfd�Zdedee e f���������fd�Zdedee e f���������fd�Zdede fd �Zdede fd �ZdS�)�DecisionEnginez�A class for managing the decision process around violations. This contains the logic for whether a violation should be reported or ignored. �optionsr#���Nc������������������X����i�|�_���������t����������|j��������|j���������������������|�_��������t����������|j��������|j���������������������|�_��������t����������|j��������t����������j ��������|j��������|j���������������������|�_��������t����������|j��������t����������j ��������|j��������|j���������������������|�_��������dS�)zInitialize the engine.)r!���r"���)r!���r,���r-���r"���N)�cacher+����select� extend_select�selected_explicitly�ignore� extend_ignore�ignored_explicitlyr/���r����SELECT�extended_default_select�selected�IGNORE�extended_default_ignore�ignored)�selfr2���s��� r����__init__zDecisionEngine.__init__Q���s�������*,�� �#5��>��(�$ ��$ ��$ �� ��#5��>��(�# ��# ��# ��� �'��>��O�$�<��(� �� �� �� ��&��>��O�$�<��(� �� �� ����r����codec�����������������������|����������������������|�j��������������������rt����������j��������S�|����������������������|�j��������������������rt����������j��������S�t����������j��������S�)a���Determine if the code has been selected by the user. :param code: The code for the check that has been run. :returns: Selected.Implicitly if the selected list is empty, Selected.Explicitly if the selected list is not empty and a match was found, Ignored.Implicitly if the selected list is not empty but no match was found. )� startswithr7���r���r���r=���r���r����rA���rC���s��� r����was_selectedzDecisionEngine.was_selectedk���sL��������?�?�4�3�4�4�� &��&�&� �_�_�T�]� +� +�� &��&�&��%�%r���c�����������������������|����������������������|�j��������������������rt����������j��������S�|����������������������|�j��������������������rt����������j��������S�t����������j��������S�)a���Determine if the code has been ignored by the user. :param code: The code for the check that has been run. :returns: Selected.Implicitly if the ignored list is empty, Ignored.Explicitly if the ignored list is not empty and a match was found, Selected.Implicitly if the ignored list is not empty but no match was found. )rE���r:���r���r���r@���r���r���rF���s��� r����was_ignoredzDecisionEngine.was_ignored}���sL��������?�?�4�2�3�3�� '��%�%� �_�_�T�\� *� *�� '��%�%��&�&r���c������������������������|������������������������������������}|�����������������������������������}t�������������������������������d�||�������������t ����������|t ����������������������r!t ����������|t ����������������������rt����������j��������S�t ����������|t����������������������r!t ����������|t����������������������rt����������j��������S�|t ����������j��������u�r|t����������j��������urt����������j��������S�|t ����������j��������ur|t����������j��������u�rt����������j��������S�|t����������j ��������u�r|t ����������j ��������u�rt����������j��������S�|t ����������j��������u�r|t����������j��������u�s|t ����������j ��������u�r�|t����������j ��������u�rxt�����������fd�|�j��������D���������������������������}t�����������fd�|�j��������D���������������������������}t����������|������������t����������|������������k����rt����������j��������S�t����������j��������S�t����������d���d|��d|����������������)z-Decide if code should be ignored or selected.z#The user configured %r to be %r, %rc��������������3����F����K����|�]}�����������������������|�������������|V����d�S��N�rE�����.0�srC���s��� �r���� <genexpr>z/DecisionEngine.make_decision.<locals>.<genexpr>����s4�����������I�I��d�o�o�a�6H�6H�I�!�I�I�I�I�I�Ir���c��������������3����F����K����|�]}�����������������������|�������������|V����d�S�rL���rM���rN���s��� �r���rQ���z/DecisionEngine.make_decision.<locals>.<genexpr>����s4�����������H�H��T�_�_�Q�5G�5G�H�!�H�H�H�H�H�Hr���zunreachable � )rG���rI����LOG�debug� isinstancer���r ���r���r���r����nextr=���r@����len�AssertionError)rA���rC���r=���r@���r5���r8���s��� ` r���� make_decisionzDecisionEngine.make_decision����s��������$�$�T�*�*���"�"�4�(�(��� � �1���� �� �� ���h��)�)�� M�j��(�.K�.K�� M��$�$� ��'� *� *�� M�z�'�7�/K�/K�� M��#�#���+�+�+��w�1�1�1��$�$��H�/�/�/��7�-�-�-��#�#� ��+� +� +��8�;N�0N�0N��#�#���+�+�+��7�;M�0M�0M���+�+�+��7�;M�0M�0M���I�I�I�I�T�]�I�I�I�I�I�F��H�H�H�H�T�\�H�H�H�H�H�F��6�{�{�S��[�[�(�(��(�(��'�'� �!K��!K�!K�x�!K�!K�'�!K�!K�L�L�Lr���c�����������������������|�j������������������������������|������������}|�;|����������������������|������������}||�j���������|<���t�������������������������������d||�������������|S�)a���Return the decision for a specific code. This method caches the decisions for codes to avoid retracing the same logic over and over again. We only care about the select and ignore rules as specified by the user in their configuration files and command-line flags. This method does not look at whether the specific line is being ignored in the file itself. :param code: The code for the check that has been run. Nz"%s" will be "%s")r4����getrZ���rT���rU���)rA���rC����decisions��� r����decision_forzDecisionEngine.decision_for����sX��������:�>�>�$�'�'�����)�)�$�/�/�H�'�D�J�t���I�I�)�4��:�:�:��r���)r���r���r���r����argparse� NamespacerB����strr ���r���r���rG���rI���r ���rZ���r^���r���r���r���r1���r1���J���s������������������ �� 2�� �t�� �� �� �� �4&���&��x��/@�)A��&��&��&��&�$'���'��h��.?�(@��'��'��'��'�&(M�#��(M�(��(M��(M��(M��(M�T����������������r���r1���c������������������������e�Zd�ZdZ �ddej��������dej��������dee ���������ddfd�Z dej��������ded���������fd �Zd e ddfd�Zej��������d e ded���������fd ���������������Z �dde d e dedede dee ���������defd�Zdee ee���������f���������ddfd�ZdS�)�StyleGuideManagerz.Manage multiple style guides for a single run.Nr2���� formatter�deciderr#���c����������������������||�_���������||�_��������t����������j����������������������|�_��������|pt����������|������������|�_��������g�|�_��������t����������|||�j��������|�������������|�_ ��������t����������t����������j��������|�j ��������g|�� ��������������������|������������������������������������|�_���������t����������j��������d�������������|�j��������������������|�_��������dS�)�SInitialize our StyleGuide. .. todo:: Add parameter documentation. )re���N)�maxsize)r2���rd���r���� Statistics�statsr1���re����style_guidesr����default_style_guide�list� itertools�chain�populate_style_guides_with� functools� lru_cache�_style_guide_for�style_guide_for)rA���r2���rd���re���s��� r���rB���zStyleGuideManager.__init__����s�����������"����*�,�,�� ��9�.��"9�"9���.0���#-��Y�� �G�$ ��$ ��$ �� ��!��O��)�*��/�/��8�8� �� � �� ���� A�y�2�4�@�@�@��!� �� ����r����r���NNc��������������#�������K����t����������j��������|j��������������������}|D�]#\��}}|�j�����������������������������||�������������V����$dS�)z�Generate style guides from the per-file-ignores option. :param options: The original options parsed from the CLI and config file. :returns: A copy of the default style guide with overridden values. )�filename�extend_ignore_withN)r ����parse_files_to_codes_mapping�per_file_ignoresrl����copy)rA���r2����per_filerw���� violationss��� r���rp���z,StyleGuideManager.populate_style_guides_with����sm������������5�g�6N�O�O��$,�� �� � �H�j��*�/�/�!�j��0������ �� �� �� � �� r���rw���r���c������������������J������t�����������fd�|�j��������D���������������d���������������S�)z3Find the StyleGuide for the filename in particular.c��������������3����F����K����|�]}|������������������������������������|V����d�S�rL���)� applies_to)rO����grw���s��� �r���rQ���z5StyleGuideManager._style_guide_for.<locals>.<genexpr>��s4�����������D�D�1�Q�\�\�(�-C�-C�D�Q�D�D�D�D�D�Dr���c������������������.�����t����������|�j��������pd������������S�)N��)rX���rw���)r����s��� r����<lambda>z4StyleGuideManager._style_guide_for.<locals>.<lambda>��s������#�a�j�.�B�/�/��r���)�key)�maxrk����rA���rw���s��� `r���rs���z"StyleGuideManager._style_guide_for����s:��������D�D�D�D��)�D�D�D�/�/� �� �� �� r���c��������������#�������K����|�����������������������|������������}|���������������������|������������5��|V���ddd�������������dS�#�1�swxY�w�Y���dS��z9Record the fact that we're processing the file's results.N)rt����processing_file)rA���rw����guides��� r���r����z!StyleGuideManager.processing_file��s����������� ��$�$�X�.�.�� � "� "�8� ,� ,�� �� ��K�K�K� �� �� �� �� �� �� �� �� �� �� �� ����� �� �� �� �� �� s����?�A�ArC����line_number� column_number�text� physical_linec������������������`�����|�����������������������|������������}|���������������������||||||������������S�)���Handle an error reported by a check. :param code: The error code found, e.g., E123. :param filename: The file in which the error was found. :param line_number: The line number (where counting starts at 1) at which the error occurs. :param column_number: The column number (where counting starts at 1) at which the error occurs. :param text: The text of the error message. :param physical_line: The actual physical line causing the error. :returns: 1 if the error was reported. 0 if it was ignored. This is to allow for counting of the number of errors found that were not ignored. )rt����handle_error)rA���rC���rw���r����r����r����r����r����s��� r���r����zStyleGuideManager.handle_error��s<������:��$�$�X�.�.���!�!��(�K���m� �� �� r����diffinfoc������������������D�����|�j���������D�]}|���������������������|��������������dS�)a5��Update the StyleGuides to filter out information not in the diff. This provides information to the underlying StyleGuides so that only the errors in the line number ranges are reported. :param diffinfo: Dictionary mapping filenames to sets of line number ranges. N)rk����add_diff_ranges)rA���r����r����s��� r���r����z!StyleGuideManager.add_diff_ranges1��s7��������&�� ,�� ,�E��!�!�(�+�+�+�+� ,�� ,r���rL���)r���r���r���r���r_���r`����base_formatter� BaseFormatterr���r1���rB���r���rp���ra���rs���� contextlib�contextmanagerr�����intr����r���r���r����r���r���r���rc���rc�������s��������������8�8��-1� �� ��#� ��"�/� ���.�)� � � � �� �� �� �:��)�� �+� ,�������� ��� ��� �� �� �� ������� �+� ,�����������(,� �� �� ��� ��� � �� ��� �� ��}� �� � �� �� �� �D ,��S�#�c�(�]�(;�� ,��� ,�� ,�� ,�� ,�� ,�� ,r���rc���c��������������������j����e�Zd�ZdZ � �ddej��������dej��������dej ��������de e���������de e���������f d�Z d efd �Z � �dde e���������de ee������������������d d�fd�Zej��������ded ed ���������fd���������������Zded efd�Zded efd�Z �ddededededede e���������d efd�Zdeeee���������f���������d dfd�ZdS�)r���z#Manage a Flake8 user's style guide.Nr2���rd���rj���rw���re���c������������������������||�_���������||�_��������||�_��������|pt����������|������������|�_��������||�_��������|�j��������rt ����������j��������|�j��������������������|�_��������i�|�_��������dS�)rg���N) r2���rd���rj���r1���re���rw���r ����normalize_path�_parsed_diff)rA���r2���rd���rj���rw���re���s��� r���rB���zStyleGuide.__init__A��sa����������"����� ��9�.��"9�"9��� �� ��=�� @�!�0���?�?�D�M�13����r���r#���c�����������������������d|�j�����������d�S�)z5Make it easier to debug which StyleGuide we're using.z <StyleGuide [z]>�rw���)rA���s��� r����__repr__zStyleGuide.__repr__V��s������0�t�}�0�0�0�0r���rx���c������������������������|p|�j���������}t����������j��������|�j��������������������}|j��������pg�|_��������|j�����������������������������|pg��������������t ����������||�j��������|�j��������|�������������S�)z8Create a copy of this style guide with different values.r����) rw���r{����deepcopyr2���r9���r"���r���rd���rj���)rA���rw���rx���r2���s��� r���r{���zStyleGuide.copyZ��sr��������,�t�}���-���-�-�� '� 5� ;������$�$�%7�%=�2�>�>�>���T�^�T�Z�(� �� �� �� r���ru���c��������������#����z���K����|�j������������������������������|�������������|�V���|�j������������������������������|�������������dS�r����)rd���� beginning�finishedr����s��� r���r����zStyleGuide.processing_fileh��sC���������� � �� � ��*�*�*�� � � ������)�)�)�)�)r���c������������������`�����|�j����������dS�t����������j��������||�j���������g|��d�t�����������������������S�)a��Check if this StyleGuide applies to the file. :param filename: The name of the file with violations that we're potentially applying this StyleGuide to. :returns: True if this applies, False otherwise NTz! does %(whether)smatch "%(path)s")�patterns�log_message�logger)rw���r ����matches_filenamerT���r����s��� r���r����zStyleGuide.applies_toq��sD��������=� ��4��%���m�_��D�D�D�� �� �� �� r���rC���c������������������6�����|�j������������������������������|������������S�)a���Determine if the error code should be reported or ignored. This method only cares about the select and ignore rules as specified by the user in their configuration files and command-line flags. This method does not look at whether the specific line is being ignored in the file itself. :param code: The code for the check that has been run. )re���r^���rF���s��� r����should_report_errorzStyleGuide.should_report_error���s��������|�(�(��.�.�.r���r����r����r����r����c������������������z����|�j���������j��������}|sd}t����������||||dz���||������������}|����������������������|j��������������������t ����������j��������u�} |���������������������|������������du�} |���������������������|�j ��������������������}| r:| r8|r6|�j �����������������������������|�������������|�j��������� ��������������������|�������������dS�dS�)r����r�������F)r2����disable_noqar���r����rC���r ���r����is_inline_ignored�is_inr����rd����handlerj����record)rA���rC���rw���r����r����r����r����r�����error�error_is_selected�is_not_inline_ignored�is_included_in_diffs��� r���r����zStyleGuide.handle_error���s�������:��|�0����� ��M������A���� �� ��� �$�$�U�Z�0�0�H�4E�E�� ��!&� 7� 7�� E� E�� N��#�k�k�$�*;�<�<���� �!6�� �;N�� ��N�!�!�%�(�(�(��J���e�$�$�$��1��qr���r����c�����������������������||�_���������dS�)a(��Update the StyleGuide to filter out information not in the diff. This provides information to the StyleGuide so that only the errors in the line number ranges are reported. :param diffinfo: Dictionary mapping filenames to sets of line number ranges. N)r����)rA���r����s��� r���r����zStyleGuide.add_diff_ranges���s�������%����r���)NNrL���)r���r���r���r���r_���r`���r����r����r���ri���r���ra���r1���rB���r����r���r{���r����r����r���r�����boolr����r ���r����r����r����r���r���r����r���r���r���r���r���>��s��������������-�-��#'�,0� 4��4��#�4��"�/�4���$� 4� ��3�-�4���.�)� 4��4��4��4�*1�#��1��1��1��1��#'�6:� �� ��3�-� ��%�X�c�]�3� �� � �� �� �� ����*��*� �+� ,�*��*��*����*� �3�� �4�� �� �� �� �$/���/���/��/��/��/�*�(,�3��3��3���3��� 3� ��3��� 3�� ��}�3�� �3��3��3��3�j %��S�#�c�(�]�(;�� %��� %�� %�� %�� %�� %�� %r���r���)(r���r_���r����r{����enumrq���rn����logging�typingr���r���r���r���r���r���r ���r ����flake8r���r���r ����flake8.formattingr���r�����flake8.violationr����__all__� getLoggerr���rT����Enumr���r���r ���ra���r+���r/���r1���rc���r���r���r���r����<module>r�������s*�����6��6����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������4��4��4��4��4��4��&��&��&��&��&��&� ���g���!�!��'��'��'��'��'�t�y��'��'��'�&��&��&��&��&�d�i��&��&��&� �� �� �� �� �t�y�� �� �� �,��T�#�Y��,�� �T�#�Y��,���3��8�_� ,��,��,��,�,��T�#�Y��,���3��8�_�,���3�i� ,� � �T�#�Y��,���3��8�_� ,��,��,��,�B��B��B��B��B��B��B��B�Jl,��l,��l,��l,��l,��l,��l,��l,�^Q%��Q%��Q%��Q%��Q%��Q%��Q%��Q%��Q%��Q%r���