_in2ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z ddlmZmZddlmZe ej&efZeZdZedde edefd Zd ej&de efd Zej4d e edej&fd Zej8d edej&fdZej8d ddej&fdZdZd ej&fdZej@ dejBddZ"dZ#dede$fdZ%ej4dZ&e&j9ejNej@dZej@dejPfdZ)ej@dZ*dZ+y)N)UnionOptionalcast)ResourceReader Traversable) wrap_specc`ttjffd }|S)a Replace 'package' parameter as 'anchor' and warn about the change. Other errors should fall through. >>> files('a', 'b') Traceback (most recent call last): TypeError: files() takes from 0 to 1 positional arguments but 2 were given c|ur1|ur ||Stjdtd|S|urS|S)Nz/First parameter to files is renamed to 'anchor') stacklevel)warningswarnDeprecationWarning)anchorpackagefunc undefineds B/opt/alt/python312/lib64/python3.12/importlib/resources/_common.pywrapperz"package_to_anchor..wrapper!sZ ) #Y&FG,, MMA"  = y 6MF|)object functoolswraps)rrrs` @rpackage_to_anchorrs3I__T )   Nrrreturnc*tt|S)z3 Get a Traversable resource for an anchor. ) from_packageresolve)rs rfilesr 3s  ((rrcr|j}t|jdd}|y||jS)z? Return the package's loader if it's a ResourceReader. get_resource_readerN)__spec__getattrloadernamerspecreaders rr"r";s9   D T[["7 >F ~ $)) rcandc6ttj|SN)rtypes ModuleTyper*s rrrKs   $ ''rc,tj|Sr,) importlib import_moduler/s r_r3Ps  " "4 ((rcBttjdS)N__name__)r _infer_caller f_globalsr/s rr3r3Us =?,,Z8 99rcfd}d}tjtj|}tj||}t |j S)zS Walk the stack and find the frame of the first caller not in this module. c<|jdjk(S)Nr)filename) frame_infostacks r is_this_filez#_infer_caller..is_this_file_s""eAh&7&777rc |jdk(S)Nr)function)r;s r is_wrapperz!_infer_caller..is_wrapperbs""i//r)inspectr< itertools filterfalsenextframe)r=r@ not_this_filecallersr<s @rr6r6ZsN 80 MMOE)),>M##J >G =  rct|}|jj|j}|j S)z= Return a Traversable object for the given package. )r r%r"r&r r's rrrls2 W D [[ , ,TYY 7F <<>r) _os_removec#pKtj|\}} tj||tj|~t j | ||y#tj|wxYw#t$rYywxYw# ||w#t$rYwwxYwxYwwN)suffix)tempfilemkstemposwriteclosepathlibPathFileNotFoundError)r)rLrIfdraw_paths r _tempfilerWvs##62LB   HHR " HHRL ll8$$  x HHRL !     x     soB6A0-B'B /B60BB BB6BB6B3B$#B3$ B0-B3/B00B33B6cDt|j|jSrK)rW read_bytesr&paths r _temp_filer\s T__TYY 77rr[ctjt5|jcdddS#1swYyxYw)a Some Traversables implement ``is_dir()`` to raise an exception (i.e. ``FileNotFoundError``) when the directory doesn't exist. This function wraps that call to always return a boolean and only return True if there's a dir and it exists. NF) contextlibsuppressrTis_dirrZs r_is_present_dirras+   . /{{} 0 / / s4=cDt|r t|St|S)zu Given a Traversable object, return that object as a path on the local file system in a context manager. )ra _temp_dirr\rZs ras_filerds .d39T?ID9IIrc#K|yw)z7 Degenerate behavior for pathlib.Path objects. NrZs rr3r3s Jsdirc#hK|5}tj|dddy#1swYyxYww)zD Wrap tempfile.TemporyDirectory to return a pathlib object. N)rRrS)rgresults r _temp_pathrjs% ll6"" s2& 2/2c#K|jsJttj5}t ||dddy#1swYyxYww)zt Given a traversable dir, recursively replicate the whole tree to the file system in a context manager. N)r`rjrMTemporaryDirectory_write_contents)r[temp_dirs rrcrcsA ;;== H//1 2hh-- 3 2 2s0AA  A AAc|j|j}|jr3|j|j D]}t |||S|j |j|Sr,)joinpathr&r`mkdiriterdirrm write_bytesrY)targetsourcechilditems rrmrmsf OOFKK (E }} NN$D E4 (% L &++-. Lrr,)),rOrRrMrr^r-r1rArrBtypingrrrabcrr _adaptersr r.strPackageAnchorrr r"singledispatchrregisterr3r6rcontextmanagerremoverWr\boolrardrSrlrjrcrmrfrrrs  ((,   #% & <)(6")k)) !1!1 h~6N   ((6"(u'7'7(( )C)E$$)) :D:U%%::$%**   yy 48 + $  JJ ',,   #H//## ..r