L i,*UdZddlmZddlZddlZddlZddlZddlZddlZddl Zddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZmZmZmZddlmZddlmZmZmZddlddlmZdd lmZiZd ed <d&d Z e e Z Gd dZ!ejDd'dZ#d(dZ$d)dZ%d*dZ&d+dZ'd,dZ(d-dZ)d,dZ*GddZ+d.dZ,GddZ-d/dZ.d0dZ/d1d2dZ0ejbd3dZ2d4d Z3ed!ee"Z4 d5 d6d#Z5d7d8d$Z6d9d%Z7y):z$Miscellaneous stuff for coverage.py.) annotationsN)IterableIteratorMappingSequence) ModuleType)AnyNoReturnTypeVar)*)CoverageException)TArczdict[ModuleType, ModuleType]ISOLATED_MODULESc|tvrvtj|j}|t|<t |D]@}t ||}t |tjr t|}t|||Bt|S)aJCopy a module so that we are isolated from aggressive mocking. If a test suite mocks os.path.exists (for example), and then we need to use it during the test, everything will get tangled up if we use their mock. Making a copy of the module when we import it will isolate coverage.py from those complications. ) rtypesr__name__dirgetattr isinstanceisolate_modulesetattr)modnew_modnamevalues S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/misc.pyrr#s~ """"3<<0 'H *DC&E%!1!12&u- GT5 )  * C  c eZdZdZddZddZy)SysModuleSaverzASaves the contents of sys.modules, and removes new modules later.c@ttj|_yNsetsysmodules old_modulesselfs r__init__zSysModuleSaver.__init__<ss{{+rcttj|jz }|D]}tj|=y)z6Remove any modules imported since this object started.Nr")r( new_modulesms rrestorezSysModuleSaver.restore?s5#++&)9)99  A A rNreturnNone)r __module__ __qualname____doc__r)r-rrrr9sK,rrc#tKt} d|jy#|jwxYww)z@A context manager to remove any modules imported during a block.N)rr-)savers rsys_modules_savedr7Fs*  E   s 8#858ct5 tj|dfcdddS#t$rtdfcYcdddSwxYw#1swYyxYw)aImport a third-party module we need, but might not be installed. This also cleans out the module after the import, so that coverage won't appear to have imported it. This lets the third party use coverage for their own tests. Arguments: modname (str): the name of the module to import. Returns: The imported module, and a boolean indicating if the module could be imported. If the boolean is False, the module returned is not the one you want: don't use it. TNF)r7 importlib import_module ImportErrorr$)modnames rimport_third_partyr=Psa   **73T9 :   s%A -A A  A  A  Ac*|\}}||k(r|S|d|S)zMake a nice string representation of a pair of numbers. If the numbers are equal, just return the number, otherwise return the pair with a dash between them, indicating the range. -r4)pairstartends r nice_pairrCgs-JE3 |#rc|yt|S)z"Return bool(b), but preserve None.N)bool)bs r bool_or_nonerGusyAwrcnt|}t|dk(r|dSdjd|DS)zDCombine a series of regex strings into one that matches any of them.r|c3(K|] }d|d yw)z(?:)Nr4).0rs r zjoin_regex..s4q#aS 4s)listlenjoin)regexess r join_regexrT}s67mG 7|qqzxx4G444rc tj|y#t$r(}|jtjk7rYd}~yd}~wwxYw)z9Remove a file, and don't get annoyed if it doesn't exist.N)osremoveOSErrorerrnoENOENT)pathes r file_be_goner]s: $  77ell "  #s A AA c8|rtj|dyy)zVMake sure the directory exists. If `directory` is None or empty, do nothing. T)exist_okN)rVmakedirs) directorys r ensure_dirrbs  I-rcTttjj|y)z,Make sure the directory for the path exists.N)rbrVr[dirname)r[s rensure_dir_for_fileresrwwt$%rc(eZdZdZddZddZddZy) Hasherz&Hashes Python data for fingerprinting.c<tjdd|_y)Nsha3_256F)usedforsecurity)hashlibnewhashr's rr)zHasher.__init__sKK EB rc|jjtt|j d|xnxtdx/\|jj|j dntxt dx \|jj|nIxxt dx\nxtdx\nn6|jjt|j dnxxtdx\nxtdx\nn|D]}|j|ntdxH\|j}t|D]'}|j||j||)nh t|D]X}|jdrt||}t!j"|r7|j||j|Z|jjdy)z+Add `v` to the hash, recursively if needed.zutf-8Nr4__.)rmupdatestrtypeencodebytesintfloattuplerPdictkeyssortedr startswithrinspect isroutine)r(vr\rzkas rrqz Hasher.updates T!W,,W56   '!23   #    Qw!78!646!#AKKN#vvx&AKKNKK!%& Q#A||D) 1 A((+ KKNKKN# rc<|jjddS)z$Retrieve the hex digest of the hash.N )rm hexdigestr's rrzHasher.hexdigestsyy""$Sb))rNr.)rr r/r0r/rr)rr1r2r3r)rqrr4rrrgrgs0C>*rrgct|drd}|j}n)d}|j}|jd|j}t |d|d|d)z7Helper to raise NotImplementedError in interface stubs._coverage_plugin_namePluginClass. z needs to implement z())hasattrr __class__r1rNotImplementedError)that func_namethingrklasss r_needs_to_implementrskt,-))""#1U^^$45  '4(.yk< rc eZdZdZddZddZy) DefaultValuezA sentinel object to use for unusual default-value needs. Construct with a string that will be used as the repr, for display in help and Sphinx output. c||_yr! display_as)r(rs rr)zDefaultValue.__init__s $rc|jSr!rr's r__repr__zDefaultValue.__repr__s rN)rrrr/r0r)rr1r2r3r)rr4rrrrs%rrcRd}ddfd }tj||S)aSubstitute ``${VAR}`` variables in `text` with their values. Variables in the text can take a number of shell-inspired forms:: $VAR ${VAR} ${VAR?} strict: an error if VAR isn't defined. ${VAR-missing} defaulted: "missing" if VAR isn't defined. $$ just a dollar sign. `variables` is a dictionary of variable values. Returns the resulting text with values substituted. aV(?x) # Use extended regex syntax \$ # A dollar sign, (?: # then (?P \$ ) | # a dollar sign, or (?P \w+ ) | # a plain word, or \{ # a {-wrapped (?P \w+ ) # word, (?: # either (?P \? ) | # with a strict marker -(?P [^}]* ) # or a default value )? # maybe. } ) )dollarword1word2ctd|jD}|dk(ry|vr|S|drd|d}t||dS)zCalled for each $replacement.c3&K|] }|s| ywr!r4)rMgs rrOz?substitute_variables..dollar_replace.. s@!aA@s$strictz Variable z is undefined: defval)nextgroupr )matchwordmsg dollar_groupstext variabless rdollar_replacez,substitute_variables..dollar_replacesj@{u{{M:@@ 3; Y T? " 8_dV?4(;C#C( (? "r)rz re.Match[str]r/rr)resub)rrdollar_patternrrs`` @rsubstitute_variablesrs/  N1M # 66..$ 7D Krc@|jjdS)z:Return a string with local timezone representing the date.z%Y-%m-%d %H:%M %z) astimezonestrftime)dts rformat_local_datetimers ==? # #$7 88rc||dz}tjj||}|Jtjj|}|tj |<|j J|j j||S)zImport a local file as a module. Opens a file in the current directory named `modname`.py, imports it as `modname`, and returns the module object. `modfile` is the file to import if it isn't in the current directory. z.py)r9utilspec_from_file_locationmodule_from_specr$r%loader exec_module)r<modfilespecrs rimport_local_filers}E/ >> 1 1'7 CD    .. ) )$ /CCKK ;; "" "KKC Jrcldd}tjd|Dcgc] }|| c}|fScc}w)zTurn a string into a list of string and number chunks. "z23a" -> (["z", 23, "a"], "z23a") The original string is appended as a last value to ensure the key is unique enough so that "x1y" and "x001y" can be distinguished. c< t|S#t$r|cYSwxYw)z6If `s` is a number, return an int, else `s` unchanged.)rv ValueError)ss rtryintz_human_key..tryint;s$ q6M H s z(\d+))rrrr/z str | int)rsplit)rrcs r _human_keyr1s1!#1 5 61VAY 6 :: 6s1c$t|tS)zSort the given iterable of strings the way that humans expect. Numeric components in the strings are sorted as numbers. Returns the sorted list. )key)r{r)stringss r human_sortedrEs 'z **r SortableItem)boundc t|d|S)zSort (string, ...) items the way humans expect. The elements of `items` can be any tuple/list. They'll be sorted by the first element (a string), with ties broken by the remaining elements. Returns the sorted list of items. c,t|dg|ddS)NrrI)r)items rz$human_sorted_items..^s:d1g+>*Jab*Jr)rreverse)r{)itemsrs rhuman_sorted_itemsrSs %JT[ \\rc"|dk(r|S|xs|dzS)zZPluralize a word. If n is 1, return thing. Otherwise return things, or thing+s. rIrr4)nrthingss rpluralras  Av &%#+&rcttjdr'tjjr d|d|dS|S)zFormat text+url as a clickable link for stdout. If attached to a terminal, use escape sequences. Otherwise, just return the text. isattyz]8;;z]8;;)rr$stdoutr)rurls r stdout_linkrls; szz8$):):)<#bj11 r)rrr/r)r/zIterator[None])r<rrr/ztuple[ModuleType, bool])r@rr/rr)rFr r/z bool | None)rS Iterable[str]r/rr)r[rrr/r0)rarrr/r0)rr rrrr/r )rrrrzMapping[str, str]r/rr)rzdatetime.datetimer/rrr!)r<rrrz str | Noner/r)rrrr/ztuple[list[str | int], str])rrr/z list[str])F)rzIterable[SortableItem]rrEr/zlist[SortableItem])r)rrvrrrrrrr/rr)rrrrrrr/rr)8r3 __future__r contextlibdatetimerY functoolsrkr9importlib.utilr}rVos.pathrr$rcollections.abcrrrrrtypingr r r coverage.exceptionsr coverage.typesrr__annotations__rrcontextmanagerr7r=rCrGrTr]rbrergrrrrrcacherrrrrrr4rrrs=+"   AA)) "113.3!&B   .  5.& '*'*T   0f9 ( ;;&+~Xc];  ] ! ]  ] ]' r