h6ȸ[ј JdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd lmZe jd Ze jdZe jdZe jdZefdedeedeefdZGddeZ d\Z!Z"Z#Z$Z%dZ&e jde!fe jde"fe jde#fe jde$fe jde%fgZ'dedee fdZ(deeeefdeeeeeffd Z)ej*fd!eed"edeefd#Z+ej*fd$ed"edefd%Z,ej-d&'defd(Z.deefd)Z/d6d*eedeeee0ffd+Z1d!eede2fd,Z3d-ed.eede2fd/Zd$ed.eed0ed1ej4de2f d2Z5defd3Z6d4edefd5Z7dS)7zUtility methods for flake8.N)Dict)List) NamedTuple)Optional)Pattern)Sequence)Set)Tuple)Union) exceptionsz*^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$z[,\s]z [,\t\n\r\f\v]z[-_.]+valueregexpreturnct|ts J|||}d|D}d|DS)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|]}|VdSN)strip.0items /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/flake8/utils.py z-parse_comma_separated_list../s*33 333333cg|]}||Srrs r z.parse_comma_separated_list..0s . . .T .D . . .r) isinstancestrsplit)r r separateditem_gens rparse_comma_separated_listr"sZ eS ! !((5(( ! U##I33333H . .X . . ..rc$eZdZUeed<eed<dS)_TokentpsrcN)__name__ __module__ __qualname__r__annotations__rrrr$r$3s" GGG HHHHHrr$)codefilecoloncommawseofz[A-Z]+[0-9]*(?=$|\s|,)z[^\s:,]+z\s*:\s*z\s*,\s*z\s+cg}d}|t|krtD]z\}}|||}|r]|t |||}n{td|||t|k|t td|S)Nr unreachable) len_FILE_LIST_TOKEN_TYPESmatchappendr$grouprendAssertionError_EOF)r tokensitoken_re token_namer6s r _tokenize_files_to_codes_mappingr@Cs F A c%jj..$: : : HjNN5!,,E  fZ1D1D1F1FGGHHHIIKK  !q99 9 c%jj.. MM&r""### Mrvalue_ctt|tsd|n|gsSGddd fd }dtjffd }t D]8}|jtthvrd_ j sg|jtkrd_ d_ Fj r7|jtkr'j|jd _ ||jt"kr |j r7|jt$kr'j|jd _ j rB|jtkr2|j|jd _ 0|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.  cLeZdZUdZdZgZeeed<gZ eeed<dS)+parse_files_to_codes_mapping..StateTF filenamescodesN) r'r(r)seen_sep seen_colonrFrrr*rGrrrStaterEhsD ! 49!!!tCyrrJrNcjr&jD]}|jfd_d_g_g_dS)NTF)rGrFr7rHrI)filenamerJrets r_resetz,parse_files_to_codes_mapping.._resetns[ ; 4!O 4 4 Hek23333  rc|tjdtjdS)NzExpected `per-file-ignores` to be a mapping from file exclude patterns to ignore codes. Configured `per-file-ignores` setting: z )r ExecutionErrortextwrapindentr)r sr_unexpected_tokenz7parse_files_to_codes_mapping.._unexpected_tokenws@( 8u{{}}f55 8 8   rTF)rN)rrjoinrr rPr@r%_COMMA_WSrHrI_COLON_FILErFr7r&r;_CODErG)rArNrStokenrJrMr s @@@rparse_files_to_codes_mappingr[Ts  fc " " &!!')C ;;==   z8      2%88** 8} $ $!ENN! *x6!!#' !% *EH$5$5&&uy111!&'')))x4 *EH$5$5 ""59---!& *EH$5$5&&uy111!&''))) Jrpathsparentc^t|ts J|fd|DS)zkNormalize a list of paths relative to a parent directory. :returns: The normalized paths. c0g|]}t|Sr)normalize_path)rpr]s rrz#normalize_paths..s# 5 5 5!N1f % % 5 5 5r)rlist)r\r]s `rnormalize_pathsrcs= eT " "))E)) " 5 5 5 5u 5 5 55rpathctjj}tjjpd}|dks ||vs|rA||vr=tjtj||}|||zS)zINormalize a single-path. :returns: The normalized path. r3.)osrdsepaltsepabspathrTrstrip)rdr] separatoralternate_separators rr`r`s~ I'..B      $74$?$?wrw||FD99:: ;;y#66 7 77r)maxsizectjj}t j|} t j|j\}}| dt j ||S#tttf$r|dcYSwxYw)z'Get and cache it so plugins can use it.rzutf-8)sysstdinbufferreadioBytesIOtokenizedetect_encodingreadlineseek TextIOWrapper LookupError SyntaxError UnicodeErrordecode) stdin_valuefdcoding_s rstdin_get_valuers)"''))K K B+,R[99   F++00222 l 3+++!!'*****+sAB,C?Cc\ttjtS)z8Return lines of stdin split according to file splitting.)rbruStringIOrrrrstdin_get_linesrs  O--.. / //rdiffc*|t}d}d}tjt}|D]}|r|r |ddkr|dz}|dddkr=|ddddd}|dd d kr |d d}ct |}|rQd |D\}}|J|| t|||z|S) zyParse the unified diff passed on stdin. :returns: dictionary mapping file names to sets of line numbers Nr-rnz+++ zb/c3<K|]}|sdnt|VdS)rnN)int)rr8s rrz%parse_unified_diff..sB%%38.CJJ%%%%%%r) r collections defaultdictset splitlinesrDIFF_HUNK_REGEXPr6groupsupdaterange)rnumber_of_rows current_path parsed_pathsline hunk_matchrows rparse_unified_diffrs\ |  NL(3(?(D(DL!!-P-P   $47c>>!#  8u  8>>$2215LBQB4''+ABB/ %++D11  P%%.,s0KKwx'22KKKKKKr)any)rLrs` rrrs5 t KKKK(KKK K KKr log_messageloggercB|sdStj|}|dvr+t||r|||dddStj|}t||}||||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>..rfr3)rdwhetherTznot )rgrdbasenamerdebugrj)rdrrrr absolute_pathr6s rmatches_filenamer/s" uw%%H{""wx'B'B" [8"C"CDDDtGOOD))M M8 , ,E LL+B22FCC LrcdtjtjtjS)zFind and format the python implementation and version. :returns: Implementation name, version, and platform as a string. z {} {} on {})formatplatformpython_implementationpython_versionsystemrrrget_python_versionrPs?   &((!!  rsc\td|S)z3Normalize a distribution name according to PEP 503.r)NORMALIZE_PACKAGE_NAME_REsublower)rs rnormalize_pypi_namer]s$ $ ( (a 0 0 6 6 8 88rr)8__doc__rrr functoolsruloggingrgrrerqrQrwtypingrrrrrrr r r flake8r compilerCOMMA_SEPARATED_LIST_RELOCAL_PLUGIN_LIST_RErrr"r$rYrXrWrUrVr;r5r@r[curdirrcr` lru_cacherrrrboolrLoggerrrrrrrrs!!   2:KLL$"*X..!rz"233&BJy11(?// / / #Y////(     Z   %K!uffc RZ)**E2RZ e$RZ V$RZ V$RZ CDL"G (3-$ %G %T#Y  GGGGV)+  6 6 C= 6"% 6 #Y 6 6 6 6-/I888c8#8888*Q + + + +  +0c0000 >>Xc]>d3C=6I>>>>B$s)LcLXc]LtLLLL$ sm N   B C    9393999999r