VcucsZdZdZdZdZdZdZdZdZdZdd l Z dd l Z dd l Z dd l Z dd l Tgd Z d Z dd lmZmZmZdZn#e$rdZYnwxYwdZdZdZdZdZe jje_dZdZdZ dZ! ddl"m#Z#n #e$rd Z#YnwxYwdZ$dZ%dZ& ddl"m'Z'dZ(n#e$rdZ(YnwxYwd Z) dd!l"m*Z*d"Z+n #e$re)Z+YnwxYw dd#l"m,Z,m-Z.d$Z/d%Z0d&d'd(Z1n #e$re+Z1YnwxYwe2e d)oe j3d*d+kZ4d/d,Z5d-Z6 dd.l"m7Z8d S#e$rYd SwxYw)0zCommon pathname manipulations, WindowsNT/95 version. Instead of importing this module directly, import os and refer to this module as os.path. ...\z;/z.;C:\binZnulN)Z*)&normcaseisabsjoin splitdrivesplitsplitextbasenamedirnameZ commonprefixZgetsizeZgetmtimeZgetatimeZgetctimeislinkZexistslexistsisdirZisfileismount expanduser expandvarsnormpathabspathcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpathZsamefileZ sameopenfileZsamestat commonpathcs4t|trdSdS)N\/\/) isinstancebytespath /usr/lib64/python3.11/ntpath.py _get_bothsepsr)#s$vu) LCMapStringExLOCALE_NAME_INVARIANTLCMAP_LOWERCASEcstj|}|s|St|trnt j}||ddd}ttt|}| |dSttt|ddS)nNormalize case of pathname. Makes all characters lowercase and all slashes into backslashes. Zsurrogateescaperr) osfspathr#r$sysZgetfilesystemencodingZdecodereplace_LCMapStringEx_LOCALE_NAME_INVARIANT_LCMAP_LOWERCASEZencode)sZencoding r(rr3s IaLL H a   8022H#455==c4HHA5/44A88H&788 8!"8"2"#))C"6"688 8r*cs<tj|}t|trLtjtj|ddS|ddS)r.rr)r/r0r#r$fsencodefsdecoder2lowerr6r'r(rrFsx IaLL a   J;r{1~~55c4@@FFHHII Iyyd##))+++r*cstj|}t|tr,|dddrdSn+|dddrdSt |d}t|d ko|d o|d t|vS) zTest whether a path is absolute/\\\?\Trr\\?\r) r/r0r#r$r2 startswithrlenr)r;r'r(rrWs ! A!U 99T5 ! ! , ,Z 8 8 4  99S$   * *9 5 5 41 aA q66A: ;!A$ ;1Q4=+;+;#;;r*cstj|}t|trd}d}d}nd}d}d} |s |dd|zt |\}}t tj|D]x}t |\}} | r| d|vr |s|s|}| })|r7||kr1||kr|}| }`|}|r|d|vr||z}|| z}y|r"|d|vr|r|dd|kr||z|zS||zS#tttf$rtj d |g|RwxYw) Nr=r!:rr":rr) r/r0r#r$rmapr: TypeErrorAttributeError BytesWarning genericpath_check_arg_types) r&pathsrsepscolonZ result_driveZ result_pathpZp_driveZp_path r(rrgs 9T??D$  !HsNN$.t$4$4! kRY&& / /A(mmOGV '&)t+ '+,+#*L$  'W 4 '==??l&8&8&:&::#*L"(K&  0{2d: 0)C/ %.KK  4KN$6 4  4)"##.%7 4#% 3 3k)) ~| 4$VT:E:::: sCDD,EcsXtj|}t|dkrt|trd}d}d}nd}d}d}|||}|dd|dzkr|dd |kr||d}|d kr |d d|fS|||d z}||d zkr |d d|fS|d krt|}|d |||d fS|d d|kr|d d|dd fS|d d|fS) aSplit a pathname into drive/UNC sharepoint and relative path specifiers. Returns a 2-tuple (drive_or_unc, path); either part may be empty. If you assign result = splitdrive(p) It is always true that: result[0] + result[1] == p If the path contained a drive letter, drive_or_unc will contain everything up to and including the colon. e.g. splitdrive("c:/dir") returns ("c:", "/dir") If the path contained a UNC path, the drive_or_unc will contain the host name and share up to but not including the fourth directory separator character. e.g. splitdrive("//host/computer/dir") returns ("//host/computer", "/dir") Paths cannot contain both a drive letter and a UNC path. r=r<rCrrrDrrENr@)r/r0rBr#r$r2Zfind)rOrrrNZnormpindexZindex2s r(rrst& ! A 1vv{ a   CFEECFE &#&& !A#J#a%  *eAaCjC&7 * JJsA&&E{ !uaxZZUQY//F" !uax| QWfW:qz) ) 1:  RaR5!ABB%<  RaR5!8Or*cs4tj|}t|}t|\}}t |}|r!||dz |vr|dz}|r ||dz |v|d|||d}}||p|}||z|fS)z~Split a pathname. Return tuple (head, tail) where tail is everything after the final slash. Either part may be empty.r@N)r/r0r)rrBrstrip)rOrMdiZheadtail r(r r s ! A   D a==DAq AA !A#d" Q !A#d"2A2!""$D ;;t   $D t8T>r*cstj|}t|trt j|dddSt j|dddS)Nr=r<.rrr)r/r0r#r$rJ _splitextrOr'r(r r sO ! A!U8$QtT:::$Qc3777r*c,t|dS)z)Returns the final component of a pathnamer@r r[r'r(r r  88A;r*cr\)z-Returns the directory component of a pathnamerr]r[r'r(r r r^r*cs tj|}n#tttf$rYdSwxYwt j|jS)zhTest whether a path is a symbolic link. This will always return false for Windows prior to 6.0. F)r/lstatOSError ValueErrorrHstatZS_ISLNKZst_moder&Zstr7r(r r sQ Xd^^ Z 0uu < # ##s 22csb tj|}n#ttf$rYdSwxYwdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r/r_r`rarcr7r(rr sB Xd^^ Z uu 4s ,,)_getvolumepathnamecstj|}t|}t|}t |\}}|r|d|vr| p||vS|r||vrdSt ra||}t ||}||kSdS)zaTest whether a path is a mount point (a drive root, the root of a share, or a mounted volume)rTF)r/r0r)rrrdrTZcasefold)r&rMZrootZrestxZyrXr(rr s 9T??D   D 4==DD!!JD$ ,Q4,+ddl+  t KK   d # # * *4 0 0zz||qzz||++ur*cstj|}t|trd}nd}||s|Sdt |}}||kr9||t |vr"|dz }||kr||t |v"dtjvrtjd}nVdtjvr|S tjd}n#t$rd}YnwxYwt|tjd}|dkr|d|}t|trtj |}tj d}||kr2|t|kr|Stt||}t|trtj|}|||d zS) zLExpand ~ and ~user constructs. If user or $HOME is unknown, do nothing.s~z~r@Z USERPROFILEZHOMEPATHZ HOMEDRIVEZUSERNAMEN)r/r0r#r$rArBr)environKeyErrorrr9Zgetr r r8)r&ZtilderVZnZuserhomedriveZ target_userZ current_users r(rr=s 9T??D$ ??5 ! ! c$iiqA a%DG=#6#66 Q a%DG=#6#66 " 7:m, 2: %7  J{+EE   EEE rz*566Av<1Q3i k5 ) ) 3+k22Kz~~j11 , & < x111  GH--{;;H$);x(( d122h sC C*)C*cstj|}t|trOd|vrd|vr|Sddl}t|j|jzdzd}d}d}d}d }d}ttd d}n6d |vrd |vr|Sddl}|j|jzdz}d }d }d}d}d }tj}|dd} d} t|} | | kr || | dz} | |kre|| dzd}t|} | | } | | |d| dzzz } n#t$r| | |zz } | dz } YnwxYw| |kr|| dz| dz|kr | | z } | dz } n`|| dzd}t|} | |} |d| } |7tj tjtj | }n|| }n#t$r || z|z}YnwxYw| |z } n#t$r| ||zz } | dz } YnwxYw| |kr|| dz| dz|kr | | z } | dz } n}|| dz| dz|kr|| dzd}t|} | |} |d| } |7tj tjtj | }n|| }n#t$r||z| z|z}YnwxYw| |z } n#t$r| ||z|zz } | dz } YnwxYw|dd} | dz } || | dz} | r!| |vr| | z } | dz } || | dz} | r| |v |7tj tjtj | }n|| }n#t$r|| z}YnwxYw| |z } | r| dz} n| | z } | dz } | | k | S)zfExpand shell variables of the forms $var, ${var} and %var%. Unknown variables are left unchanged.s$s%rNz_-Zasciis's{s}Zenvironbz$z%z'z{z}r@rQ)r/r0r#r$stringZ ascii_lettersZdigitsZgetattrrgrBrSrar8r9rh)r&rjZvarcharsZquoteZpercentZbraceZrbraceZdollarrgZresrSZpathlencZvarZvalues r(rrzsU 9T??D$ t  D 0 K - =DgNN"j$// d? s$ K '&-7$>* rr(C E$iiG '/K uQw  :H  #D$iiG $ 1 q4  +++ $ $ $q4x!  $'\? EAIeai'(G3 !q E!GHH~d))! JJw//E vv,C8"1$&K 2;s;K;K0L$M$MEE$+CLE#888 '#  785LCC"(((7T>)C#aKEEE(&[) EAIeai'(F2& q eai )*e3# E!GHH~d))! JJv..E vv,C>"1$&K 2;s;K;K0L$M$MEE$+CLE#>>> & 4v =>5LCC"(((6E>D00C#aKEEE(2A2h uqy).AM.1HCQJEU519_-A.AM.)- " BJr{37G7G,H I I ' )))"SLEEE)u QJE 1HC  W '/KX Jso(D++EE H ,AG..HH H('H(L#AK%%K=<K=L#"L#&AN((N:9N:)_path_normpathcstj|}t|tr5tjt tj|pdSt |pdS)0Normalize path, eliminating double slashes, etc.rYr)r/r0r#r$r8rlr9r%r'r(rr!s\y dE " " J;~bk$.?.?@@AAIT Id##*s*r*cstj|}t|tr d}d}d}d}d}n d}d}d}d }d }||r|S|||}t |\}}||r||z }||}||}d }|t|kr||r |||kr||=n\|||krK|d kr ||d z |kr||d z |d z=|d z}n*|d kr| |r||=n |d z }n|d z }|t|k|s|s| ||| |zS) rmr=r<rY..)s\\.\r>rrrr)z\\.\r?rr@) r/r0r#r$rAr2rZlstripr rBZendswithZappendr) r&rrrrZspecial_prefixesprefixZcompsrVs r(rrsy dE " " 6CFFF7  CFFF5  ??+ , ,  K||FC((!$''  ??3   $ cMF;;s##D 3 #e**n 8 uQx61 !HHqV# q5U1Q3Z61ac!A#gFAA!V 4 4aFAAQ#e**n  !e ! LL ''r*cstj|}t|sLt|trtj}ntj}t||}t|S)zReturn the absolute version of a path as a fallback function in case `nt._getfullpathname` is not available or raises OSError. See bpo-31047 for more. ) r/r0rr#r$getcwdbgetcwdrr)r&cwdr7r(_abspath_fallbackrs)sb 9T??D ;; dE " " *,,CC)++CC D>>r*)_getfullpathnamecs tt|S#ttf$rt |cYSwxYw)z&Return the absolute version of a path.)rtrr`rarsr%r'r(rrAsO +#HTNN33 3$ + + +$T** * * * +s AA)_getfinalpathnamereadlinkcsd}t}t||vr|t| |}t|}t |ss\\?\UNC\s\\s\\.\NULr?z\\?\UNC\z\\z\\.\NULr)rr#r$r/rprr8rrqrArrrur`rrrB) r&rroZ unc_prefixZnew_unc_prefixrrZ had_prefixZinitial_winerrorrZspathrPr(rrs~~ dE " " $F(J$N*,,C~~"+g*>*>!?!?? %$} %F'J#N)++C~~'!2!22 $#|__V,,  #%++ #T??D 5$T**D   5 5 5 !{ .t44DDDDDD  5 !doof55 !z** +&c*oo.>.>)??S[[\\* !$U++t3! D ! ! !;"22! D  !  s0/D D. D))D.F&& G0 GGgetwindowsversionrRrQcstj|}t|trd}d}d}nd}d}d}||}|st dtj|} t t |}t t |}t|\}}t|\} } t|t| krt d | d |d | |D} d | |D} d } t| | D],\}}t|t|krn| dz } -|gt| | z z| | dz}|s|St|S#ttttt f$rt#jd||wxYw)z#Return a relative version of a pathr=rYrnrrrNzno path specifiedzpath is on mount z, start on mount cg|]}||Sr.0rer7r( relpath..s<<>**",Y"7"7 Z *8 4 4 I K HZ$8$8 8 ** KK)** *=<!1!1#!6!6<<< ::  4 4::: *i00  FB||x||+  FAA8s:q01IabbMA MX z>.&s;QQQaz!))FC"8"8">">"@"@AAQQQr*cs@g|]\}}|Srr]rrUrOr r(rr's'<<<1qwws||<<commonpath..*s3>>$!Q2A2#>>>>>>r*z%Can't mix absolute and relative pathsNc3s K|] \}}|V dSNr)rrUrOs r(rr1s&--A1------r*r@zPaths don't have the same drivec$g|] }||k | Srrrrkr r(rr6s'999q9Q&[9!999r*cs,g|]}fd|DS)crrrrrr(rz)commonpath...8s':::a:a6k::::r*r)rr6rrr(rr8s.PPPq::::1:::PPPr*r )raZtuplerFr/r0r#r$r}rBrr2r ZminZmaxZ enumeraterrGrHrJrK)rLZ drivesplitsZ split_pathsrrir&ZcommonZs1Zs2rVrkrorrrs @@@r(r r s} B@AAA #bi'' ( (E%(E""!QQQQQ5QQQ <<<< <<<  P>>>>+>>>>>FEE P P PDEE4 O P s------- . .! 3 @>?? ? q!1!1&#!>!>?? tC9999V999PPPPKPPP      bMM & &DAqBqEz  HSWWH%F %05(((( ~ &$\:E:::: s%%GB! G!B<rs          A A A!,---------- 8888$ , , ,,,,,, ,$ < < < )))^000p.888 (0 $$$$%%%%%%%:---zjjj`<+!!!!!!l++++i1(1(1(0(0(0(0(0(1(x" +###### ++++    GGG N>>>>>>>> (((T,,,\"'000000yHHH`&gc+>??>3c355a8A=++++p111h #"""""""   DD si =AA8A??B B B B+*B+2B<<CC CC)(C)D!!D*)D*