VL idZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlmZddl mZddlmZddlmZe j*dZe j*d Ze j*d Zef d"d ZGd d eZd\ZZZZZdZ e j*defe j*defe j*defe j*defe j*defgZ!d#dZ" d$dZ#ejHf d%dZ%ejHfd&dZ&ejNdd'dZ(d(dZ)d)dZ*d*dZ d+dZ+d'd Z,d,d!Z-y)-zUtility methods for flake8.) annotationsN)Sequence)Pattern) NamedTuple) exceptionsz[,\s]z [,\t\n\r\f\v]z[-_.]+ct|tsJ||j|}d|D}|Dcgc]}|s| c}Scc}w)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. c3<K|]}|jywN)strip).0items R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/flake8/utils.py z-parse_comma_separated_list..)s3 3s) isinstancestrsplit)valueregexp separateditem_genr s rparse_comma_separated_listrsG eS !(5( ! U#I33H% .TD .. .s AAc"eZdZUded<ded<y)_TokenrtpsrcN)__name__ __module__ __qualname____annotations__rrr-s  G Hr!r)codefilecoloncommawseofz[A-Z]+[0-9]*(?=$|\s|,)z[^\s:,]+z\s*:\s*z\s*,\s*z\s+cvg}d}|t|krtD]b\}}|j||}|s|jt ||j j |j}ntd|||t|kr|jt td|S)Nr unreachable) len_FILE_LIST_TOKEN_TYPESmatchappendrgroupr endAssertionError_EOF)rtokensitoken_re token_namer-s r _tokenize_files_to_codes_mappingr7=s F A c%j.$: : HjNN5!,E fZ1D1D1FGHIIK  :!q9 9 c%j. MM&r"# Mr!ct|tsdj|n|gjsSGdddfd }d fd }t D]e}|j t thvrd_$jsu|j tk(rd_ d_Rjr@|j tk(r-jj|jd_||j tk(r|jrA|j t k(r.j"j|jd_ jrH|j tk(r5|jj|jd_a|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.  c2eZdZUdZdZgZded<gZded<y)+parse_files_to_codes_mapping..StateTF list[str] filenamescodesN)rrrseen_sep seen_colonr=rr>r r!rStater;bs  ! 9!yr!rAcjr.jD]}j|jf!d_d_g_g_y)NTF)r>r=r.r?r@)filenamerArets r_resetz,parse_files_to_codes_mapping.._resethsO ;;!OO 4 Hekk23 4  r!cxtjdtjj dS)NzExpected `per-file-ignores` to be a mapping from file exclude patterns to ignore codes. Configured `per-file-ignores` setting: z )rExecutionErrortextwrapindentr )rsr_unexpected_tokenz7parse_files_to_codes_mapping.._unexpected_tokenqs9((9u{{}f56 8  r!TF)returnNone)rKzexceptions.ExecutionError)rrjoinr r7r_COMMA_WSr?r@_COLON_FILEr=r.rr2_CODEr>)value_rErJtokenrArDrs @@@rparse_files_to_codes_mappingrUNsX fc " &!')C ;;=   2%8* 88} $!EN!!xx6!#' !%EHH$5&&uyy1!&'))xx4EHH$5 ""599-!&EHH$5&&uyy1!&'))5*8 Jr!cnt|tsJ||Dcgc]}t||c}Scc}w)zkNormalize a list of paths relative to a parent directory. :returns: The normalized paths. )rlistnormalize_path)pathsparentps rnormalize_pathsr\s4 eT ")E) "/4 5!N1f % 55 5s2c2tjj}tjjxsd}|dk(s ||vs|rA||vr=tjj tjj ||}|j ||zS)zINormalize a single-path. :returns: The normalized path. r*.)ospathsepaltsepabspathrMrstrip)r`rZ separatoralternate_separators rrXrXst I''...B    $74$?wwrww||FD9: ;;y#66 77r!)maxsizectjjj}t j |} t j|j\}}|jdt j||jS#tttf$r|jdcYSwxYw)z'Get and cache it so plugins can use it.rzutf-8)sysstdinbufferreadioBytesIOtokenizedetect_encodingreadlineseek TextIOWrapper LookupError SyntaxError UnicodeErrordecode) stdin_valuefdcoding_s rstdin_get_valuer}s))""'')K K B+,,R[[9   F+0022 l 3+!!'**+sAB%B>=B>cNttjtS)z8Return lines of stdin split according to file splitting.)rWrnStringIOr}r r!rstdin_get_linesrs  O-. //r!c d|vS)zDetermine 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 )rYs ris_using_stdinrs %<r!c2|sytfd|DS)aWrap :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. Tc3JK|]}tj|ywr )_fnmatchfnmatch)r patternrCs rrzfnmatch..sKwx'2Ks #)any)rCpatternss` rrrs  K(K KKr!c|sytjj|}|dvr"t||r|j ||ddytjj |}t||}|j |||rdndd|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`basenamerdebugrc)r`r log_messageloggerr absolute_pathr-s rmatches_filenamers" ww%H{"wx'B [8"CDGGOOD)M M8 ,E LL2FC Lr!cdjtjtjtjS)zFind and format the python implementation and version. :returns: Implementation name, version, and platform as a string. z {} {} on {})formatplatformpython_implementationpython_versionsystemr r!rget_python_versionr s9   &&(! r!cJtjd|jS)z3Normalize a distribution name according to PEP 503.r)NORMALIZE_PACKAGE_NAME_REsublower)ss rnormalize_pypi_namers $ ( (a 0 6 6 88r!)rrrz Pattern[str]rKr<)rrrKz list[_Token])rSzSequence[str] | strrKzlist[tuple[str, list[str]]])rY Sequence[str]rZrrKr<)r`rrZrrKr)rKr)rKr<)rYr<rKbool)rCrrrrKr) r`rrrrrrzlogging.LoggerrKr)rrrKr).__doc__ __future__rrr functoolsrnloggingr_rrerjrHrpcollections.abcrrtypingrflake8rcompileCOMMA_SEPARATED_LIST_RELOCAL_PLUGIN_LIST_RErrrrRrQrPrNrOr2r,r7rUcurdirr\rX lru_cacher}rrrrrr r!rrs!"   $$"**X.!rzz"23&BJJy1(?/ /$//( Z %K!uffc RZZ)*E2RZZ e$RZZ V$RZZ V$RZZ "G G GV)+  6  6"% 6 6-/II8*Q +  +0 L$     B 9r!