7f^$UddlZddlZddlZddlZddlZddlZddlmZm Z ddl m Z ddl m Z mZmZmZmZmZmZmZddlmZmZejeZeddZed d d Zdaeeed <e dedfdZGddZ da!ee ed<e dee ddffdZ"GddZ#e#Z$GddZ%Gdde%Z&dS)N) ExitStackcontextmanager)Path)AnyCallableDict GeneratorListOptionalTypeVarUnion)enumrmtree_T TempDirectory)boundz build-envzephem-wheel-cachez req-build) BUILD_ENVEPHEM_WHEEL_CACHE REQ_BUILD_tempdir_managerreturn)NNNc#Kt5}t|c}a dV|an#|awxYw ddddS#1swxYwYdSN)rr)stackold_tempdir_managers |/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/utils/temp_dir.pyglobal_tempdir_managerr's 30@%-- 3 EEE2  2  2 2 2 2  333333333333333333s 9$9(9==c>eZdZdZd dZdededdfdZdedefdZdS) TempDirectoryTypeRegistryzManages temp directory behaviorrNci|_dSr_should_deleteselfs r__init__z"TempDirectoryTypeRegistry.__init__5s/1kindvaluec||j|<dS)z[Indicate whether a TempDirectory of the given kind should be auto-deleted. Nr!)r$r'r(s r set_deletez$TempDirectoryTypeRegistry.set_delete8s%*D!!!r&c8|j|dS)z^Get configured auto-delete flag for a given TempDirectory type, default True. T)r"get)r$r's r get_deletez$TempDirectoryTypeRegistry.get_delete>s"&&tT222r&rN) __name__ __module__ __qualname____doc__r%strboolr*r-r&rrr2sy))2222*s*4*D**** 3s3t333333r&r_tempdir_registryc#ZKt}ta tV|adS#|awxYw)zuProvides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. N)r6r)old_tempdir_registrys rtempdir_registryr9HsJ -1331000000s &*ceZdZdS)_DefaultN)r/r0r1r5r&rr;r;VsDr&r;c eZdZdZdedddfdeedeede fded ed ef fd Z e d efd Z d efdZ ded efdZdededed dfdZded efdZddZxZS)raMHelper class that owns and cleans up a temporary directory. This class can be used as a context manager or as an OO representation of a temporary directory. Attributes: path Location to the created temporary directory delete Whether the directory should be deleted when exiting (when used as a contextmanager) Methods: cleanup() Deletes the temporary directory When used as a context manager, if the delete attribute is True, on exiting the context the temporary directory is deleted. NtempFTpathdeleter'globally_managedignore_cleanup_errorsc*t|tur|d}nd}|||}||_d|_||_||_||_|r%tJt |dSdS)NF) superr%_default_create_path_deletedr?r'rAr enter_context)r$r>r?r'r@rA __class__s rr%zTempDirectory.__init__rs  X   <<<%%D    %:"  1#///  * *4 0 0 0 0 0 1 1r&rcB|jrJd|j|jS)Nz"Attempted to access deleted path: )rGrFr#s rr>zTempDirectory.paths+=SS"Stz"S"SSS zr&c2d|jjd|jdS)N< >)rIr/r>r#s r__repr__zTempDirectory.__repr__s";4>*;;TY;;;;r&r$c|Srr5r#s r __enter__zTempDirectory.__enter__s r&excr(tbc|j|j}n)tr t|j}nd}|r|dSdS)NT)r?r6r-r'cleanup)r$rRr(rSr?s r__exit__zTempDirectory.__exit__sZ ; "[FF  &11$)<realpathtempfilemkdtemploggerdebug)r$r'r>s rrEzTempDirectory._createsI w 0t G G GHH 6=== r&cd|_tj|jsdSgdt dt fdtdtddffd }|j rd t|jd n&#t$rt|j| YnwxYwr"t d |jdSdSt|jdS) z6Remove the temporary directory created and reset stateTNfunc.r>exc_valrcdtjt||}|}|t jt jt jfvrt d||n!t d|j | |dS)z/Log a warning for a `rmtree` error and continue z2Failed to remove a temporary file '%s' due to %s. z%s failed with %s.N) join tracebackformat_exception_onlytyperstripr]unlinkremovermdirrarbr1append)rdr>re formatted_excerrorss ronerrorz&TempDirectory.cleanup..onerrors !II/W wGGM*0022M 29bh777 I!  143DmTTT MM' " " " " "r&F) ignore_errors)onexcz[Failed to remove contents in a temporary directory '%s'. You can safely remove it manually.)rGr]r>existsrFrrr BaseExceptionrArOSErrorrawarning)r$rsrrs @rrUzTempDirectory.cleanups- w~~dj))  F&( #38$ # ## #  # # # # # #(  %  2tz77777 2 2 2tz111111 2 9J   4:     s#A:: BBr.)r/r0r1r2rDr r3r r4r;r%propertyr>rOrrQrrVrErU __classcell__rIs@rrr]sh,#.6!&&* !1!1sm!1dD(*+!1 !1  !1 $ !1!1!1!1!1!1FcX<#<<<<r C       CC********r&ceZdZdZdZd dedeeddffd Ze dede eddffd Z d edefd Z xZ S) AdjacentTempDirectoryaHelper class that creates a temporary directory adjacent to a real one. Attributes: original The original directory to create a temp directory for. path After calling create() or entering, contains the full path to the temporary directory. delete Whether the directory should be deleted when exiting (when used as a contextmanager) z-~.=%0123456789Noriginalr?rc|d|_t|dS)Nz/\)r?)rlrrCr%)r$rr?rIs rr%zAdjacentTempDirectory.__init__s7 ..  '''''r&namec#Ktdt|D]O}tj|j|dz D]/}dd|z||dz}||kr|V0Ptt|jD]D}tj|j|D]'}dd|z|z}||kr|V(EdS)a Generates a series of temporary names. The algorithm replaces the leading characters in the name with ones that are valid filesystem characters, but are not valid package names (for both Python and pip definitions of package). ~N)rangelen itertoolscombinations_with_replacement LEADING_CHARSrh)clsri candidatenew_names r_generate_namesz%AdjacentTempDirectory._generate_namessq#d))$$ # #A&D!1q5 # # !3!33d122h>t##"NNN  #s3,--.. # #A&D!1 # # !3!33d:t##"NNN  # # #r&r'c*tj|j\}}||D]}tj||} tj|tj|}nc#t$r }|j tj krYd}~}d}~wwxYwtjtj d|d}td||S)NrXrYrZr\)r]r>splitrrrhmkdirr^rxerrnoEEXISTr_r`rarb)r$r'rootrrr>exs rrEzAdjacentTempDirectory._createsW]]4=11 d--d33 M MI7<<i00D  w''--    8u|++,++++ 7##H$4N4NNN$K$K$KLLD 6=== s B B?B::B?r)r/r0r1r2rr3r r4r% classmethodr rrEr{r|s@rr~r~s  &&M(((htn(((((((#3#9S$_+E###[#2CCr&r~)'rrloggingos.pathr]r_ri contextlibrrpathlibrtypingrrrr r r r r pip._internal.utils.miscrr getLoggerr/rar tempdir_kindsr__annotations__rrr6r9r;rDrr~r5r&rrs 00000000                    21111111  8 $ $ WT))) ) )-(9%,,,3 *: ;333333333333&:>856=== 1)$=tT$IJ 1 1 1 1         8::BBBBBBBBJFFFFFMFFFFFr&