HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib64/python3.10/site-packages/flake8/__pycache__/utils.cpython-310.pyc
o

%we��@s�dZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZddlmZddlmZe
�d�Ze
�d	�Ze
�d
�ZefdCdd�ZGdd�de�Zd\ZZZZZdZe
�d�efe
�d�efe
�d�efe
�d�efe
�d�efgZ dDdd�Z!dEd"d#�Z"ej#fdFd'd(�Z$ej#fdGd*d+�Z%ej&d,d-�dHd.d/��Z'dId0d1�Z(dJd3d4�Z)dKd7d8�ZdLd<d=�Z*dHd>d?�Z+dMdAdB�Z,dS)NzUtility methods for flake8.�)�annotationsN)�
NamedTuple)�Pattern)�Sequence)�
exceptionsz[,\s]z
[,\t\n\r\f\v]z[-_.]+�value�str�regexp�Pattern[str]�return�	list[str]cCs8t|t�s	J|��|�|�}dd�|D�}dd�|D�S)aParse a comma-separated list.

    :param value:
        String to be parsed and normalized.
    :param regexp:
        Compiled regular expression used to split the value when it is a
        string.
    :returns:
        List of values with whitespace stripped.
    css�|]}|��VqdS�N)�strip��.0�item�r�E/home/arjun/projects/env/lib/python3.10/site-packages/flake8/utils.py�	<genexpr>)s�z-parse_comma_separated_list.<locals>.<genexpr>cSsg|]}|r|�qSrrrrrr�
<listcomp>*sz.parse_comma_separated_list.<locals>.<listcomp>)�
isinstancer�split)rr	�	separated�item_genrrr�parse_comma_separated_lists
rc@seZdZUded<ded<dS)�_Tokenr�tp�srcN)�__name__�
__module__�__qualname__�__annotations__rrrrr-s
r)�code�file�colon�comma�ws�eofz[A-Z]+[0-9]*(?=$|\s|,)z[^\s:,]+z\s*:\s*z\s*,\s*z\s+�list[_Token]cCs�g}d}|t|�kr7tD]\}}|�||�}|r*|�t||������|��}nqtd||��|t|�ks
|�tt	d��|S)Nr�unreachable�)
�len�_FILE_LIST_TOKEN_TYPES�match�appendr�groupr�end�AssertionError�_EOF)r�tokens�i�token_re�
token_namer-rrr� _tokenize_files_to_codes_mapping=s��	r7�value_�Sequence[str] | str�list[tuple[str, list[str]]]cs0t|t�sd�|��n|�g����s�SGdd�d��d��fdd�}d�fd	d
�}t��D]f}|jtthvr<d�_q/�j	sa|jt
krKd�_	d�_q/�jr^|jtkr^�j�
|j�d�_q/|��|jtkrj|�q/�jr}|jtkr}�j�
|j�d�_q/�jr�|jtkr�|��j�
|j�d�_q/|���S)aParse a files-to-codes mapping.

    A files-to-codes mapping a sequence of values specified as
    `filenames list:codes list ...`.  Each of the lists may be separated by
    either comma or whitespace tokens.

    :param value: String to be parsed and normalized.
    �
c@s.eZdZUdZdZgZded<gZded<dS)z+parse_files_to_codes_mapping.<locals>.StateTFr�	filenames�codesN)rrr �seen_sep�
seen_colonr<r!r=rrrr�Statebs

r@r�Nonecs>�jr�jD]
}��|�jf�qd�_d�_g�_g�_dS)NTF)r=r<r.r>r?��filename)r@�retrr�_reseths

z,parse_files_to_codes_mapping.<locals>._reset�exceptions.ExecutionErrorcst�dt����d����S)Nz�Expected `per-file-ignores` to be a mapping from file exclude patterns to ignore codes.

Configured `per-file-ignores` setting:

z    )r�ExecutionError�textwrap�indentrr)rrr�_unexpected_tokenqs
��z7parse_files_to_codes_mapping.<locals>._unexpected_tokenTFN)rrA)rrF)rr�joinrr7r�_COMMA�_WSr>r?�_COLON�_FILEr<r.rr2�_CODEr=)r8rErJ�tokenr)r@rDrr�parse_files_to_codes_mappingNs>
	

rR�paths�
Sequence[str]�parentcs$t|t�s	J|���fdd�|D�S)zkNormalize a list of paths relative to a parent directory.

    :returns:
        The normalized paths.
    csg|]}t|���qSr)�normalize_path)r�p�rUrrr�sz#normalize_paths.<locals>.<listcomp>)r�list)rSrUrrXr�normalize_paths�srZ�pathcCsTtjj}tjjp	d}|dks||vs|r#||vr#tj�tj�||��}|�||�S)zINormalize a single-path.

    :returns:
        The normalized path.
    r*�.)�osr[�sep�altsep�abspathrK�rstrip)r[rU�	separator�alternate_separatorrrrrV�s	�rV�)�maxsizec
Csftjj��}t�|�}zt�|j�\}}|�	d�t�
||���WSttt
fy2|�d�YSw)z'Get and cache it so plugins can use it.rzutf-8)�sys�stdin�buffer�read�io�BytesIO�tokenize�detect_encoding�readline�seek�
TextIOWrapper�LookupError�SyntaxError�UnicodeError�decode)�stdin_value�fd�coding�_rrr�stdin_get_value�s

�rycCstt�t���S)z8Return lines of stdin split according to file splitting.)rYrj�StringIOryrrrr�stdin_get_lines��r{�boolcCsd|vS)z�Determine if we're going to read from stdin.

    :param paths:
        The paths that we're going to check.
    :returns:
        True if stdin (-) is in the path, otherwise False
    �-r)rSrrr�is_using_stdin�srrC�patternscs|sdSt�fdd�|D��S)a�Wrap :func:`fnmatch.fnmatch` to add some functionality.

    :param filename:
        Name of the file we're trying to match.
    :param patterns:
        Patterns we're using to try to match the filename.
    :param default:
        The default value if patterns is empty
    :returns:
        True if a pattern matches the filename, False if it doesn't.
        ``True`` if patterns is empty.
    Tc3s�|]	}t��|�VqdSr
)�_fnmatch�fnmatch)r�patternrBrrr�s�zfnmatch.<locals>.<genexpr>)�any)rCr�rrBrr��s
r��log_message�logger�logging.LoggercCsp|sdStj�|�}|dvrt||�r|�||dd��dStj�|�}t||�}|�|||r1dndd��|S)aHUse fnmatch to discern if a path exists in patterns.

    :param path:
        The path to the file under question
    :param patterns:
        The patterns to match the path against.
    :param log_message:
        The message used for logging purposes.
    :returns:
        True if path matches patterns, False otherwise
    F>�..r\r*)r[�whetherTznot )r]r[�basenamer��debugr`)r[r�r�r�r��
absolute_pathr-rrr�matches_filename�s
�r�cCsd�t��t��t���S)z�Find and format the python implementation and version.

    :returns:
        Implementation name, version, and platform as a string.
    z{} {} on {})�format�platform�python_implementation�python_version�systemrrrr�get_python_version	s
�r��scCst�d|���S)z3Normalize a distribution name according to PEP 503.r~)�NORMALIZE_PACKAGE_NAME_RE�sub�lower)r�rrr�normalize_pypi_namer|r�)rrr	r
rr)rrrr()r8r9rr:)rSrTrUrrr)r[rrUrrr)rr)rr)rSrrr})rCrr�rTrr})
r[rr�rTr�rr�r�rr})r�rrr)-�__doc__�
__future__rr�r��	functoolsrj�loggingr]r��rerfrHrl�typingrrr�flake8r�compile�COMMA_SEPARATED_LIST_RE�LOCAL_PLUGIN_LIST_REr�rrrPrOrNrLrMr2r,r7rR�curdirrZrV�	lru_cacheryr{rr�r�r�rrrr�<module>sV


��
	
K�





!