VcZBFdZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l Tgd Z d Zd Zd ZdZdZdZe jje_dZdZdZdZdZdZdZdadadZ ddlm Z dZ!n#e"$rdZ!YnwxYwdZ#dddZ$d Z%e j&d!kZ'd$d"Z(d#Z)dS)%aCommon operations on Posix pathnames. Instead of importing this module directly, import os and refer to this module as os.path. The "os.path" name is an alias for this module on Posix systems; on other systems (e.g. Windows), os.path provides the same operations in a manner specific to that platform, and is an alias to another module (e.g. ntpath). Some of this can actually be useful on non-Posix systems too, e.g. for manipulation of the pathname component of URLs. .../:z /bin:/usr/binNz /dev/null)*)&normcaseisabsjoin splitdrivesplitsplitextbasenamedirname commonprefixgetsizegetmtimegetatimegetctimeislinkexistslexistsisdirisfileismount expanduser expandvarsnormpathabspathsamefile sameopenfilesamestatcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpath commonpathc4t|trdSdS)N/r) isinstancebytespaths "/usr/lib64/python3.11/posixpath.py_get_sepr5)s$tsc*tj|S)z6Normalize case of pathname. Has no effect under Posixosfspath)ss r4rr4s 9Q<<r6crtj|}t|}||S)zTest whether a path is absolute)r9r:r5 startswith)r;r$s r4r r <s, ! A 1++C <<  r6ctj|}t|}|} |s |dd|zttj|D]?}||r|}|r||r||z }7|||zz }@n/#t ttf$rtj d|g|RwxYw|S)zJoin two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.Nrr ) r9r:r5mapr=endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)apr$r3bs r4r r Gs ! A 1++C D   !HsNNRY""  A||C    T]]3//  a   ~| 4$VQ33333  Ks A)B,B=ctj|}t|}||dz}|d|||d}}|r+||t |zkr||}||fS)zSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.Nr9r:r5rfindlenrstrip)rGr$iheadtails r4r r ds ! A 1++C  qA2A2!""$D  CII % {{3 :r6ctj|}t|trd}d}nd}d}t j||d|S)Nr/.rr)r9r:r0r1rD _splitext)rGr$r(s r4r r usN ! A!U  Cv 6 66r6cBtj|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr8)rGs r4r r s" ! A RaR5!8Or6ctj|}t|}||dz}||dS)z)Returns the final component of a pathnamerJN)r9r:r5rL)rGr$rOs r4rrs; ! A 1++C  qA QRR5Lr6ctj|}t|}||dz}|d|}|r+||t |zkr||}|S)z-Returns the directory component of a pathnamerJNrK)rGr$rOrPs r4rrso ! A 1++C  qA RaR5D  CII % {{3 Kr6c tj|}n#tttf$rYdSwxYwt j|jS)z&Test whether a path is a symbolic linkF)r9lstatOSError ValueErrorrBstatS_ISLNKst_mode)r3sts r4rrsQ Xd^^ Z 0uu < # ##s 22cb tj|n#ttf$rYdSwxYwdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r9rYrZr[r2s r4rrsB  Z uu 4s ,,c tj|}tj|jrdSn#t t f$rYdSwxYwt|trt|d}nt|d}t|} tj|}n#t t f$rYdSwxYw|j }|j }||krdS|j }|j }||krdSdS)z$Test whether a path is a mount pointF..rT) r9rYr\r]r^rZr[r0r1r r*st_devst_ino)r3s1parents2dev1dev2ino1ino2s r4rrs  Xd^^ < # # 5  Z uu$"dE""dD!! f  F Xf   Z uu 9D 9D t|t 9D 9D t|t 5s!2AAB%%B:9B:ctj|}t|trd}nd}||s|St |}||d}|dkrt|}|dkrxdtjvrW ddl }n#t$r|cYSwxYw | tj j }n#t$r|cYSwxYwtjd}nw ddl }n#t$r|cYSwxYw|d|}t|trt|d} ||}n#t$r|cYSwxYw|j }|t"jdkr|St|trtj|}d }nd }||}|||dzp|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.~~rJrHOMENASCIIvxworksr/r)r9r:r0r1r=r5findrMenvironpwd ImportErrorgetpwuidgetuidpw_dirKeyErrorstrgetpwnamsysplatformfsencoderN) r3tilder$rOrtuserhomenamepwentroots r4rrs? 9T??D$ ??5 ! ! 4..C #qA1u IIAv  # *        << 44;      z&)HH  JJJJ   KKK AaCy dE " " &tW%%D LL&&EE   KKK <CLI5 $;x((t$$H tABBx  (D(sHB B)(B)-+C C('C(?D DDE E+*E+cvtj|}t|trSd|vr|Stsddl}|d|jatj}d}d}ttdd}nHd|vr|Stsddl}|d |ja tj}d }d }tj }d} |||}|sn| d\}}| d } | |r| |r | d d} |7tjtj tj| } n|| } ||d} |d|| z}t%|}|| z }n#t&$r|}YnwxYw|S)zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.$rNs\$(\w+|\{[^}]*\}){}environb$z\$(\w+|\{[^}]*\}){}TrJ)r9r:r0r1 _varprogbrecompilerpsearchgetattr_varprogrsspangroupr=r@r~fsdecoderMry) r3rrstartendrsrOmjrvaluerQs r4rr$s 9T??D$ t  K D III #8"(CCI!"j$// d? K B IIIzz"6AAH* A F4OO  vvayy1wwqzz ??5 ! ! dmmC&8&8 ":D  & BJr{4/@/@$ABB 8D8e#DD A DLDD    AAA ( Ks9AF&& F54F5)_path_normpathctj|}t|tr5tjt tj|pdSt |pdS)0Normalize path, eliminating double slashes, etc.rSr)r9r:r0r1r~rrr2s r4rrs\y dE " " J;~bk$.?.?@@AAIT Id##*s*r6c0tj|}t|tr d}d}d}d}nd}d}d}d}||kr|S||}|r2||d zr||d zsd }||}g}|D]M}|||fvr ||ks|s|r|r"|d |kr||7|r|N|}||}|r||z|z}|p|S) rr/r6rSrbrrrr) r9r:r0r1r=r appendpopr ) r3r$emptydotdotdotinitial_slashescomps new_compscomps r4rr]sxy dE " " CECFFCECF 5= J//#..  OOCE " " +/??3q5+A+A O 3   Ds|#   y  )"  7   &&&&  xx  .&-D{sr6ctj|}t|sLt|trtj}ntj}t||}t|S)zReturn an absolute path.) r9r:r r0r1getcwdbgetcwdr r)r3cwds r4rrs` 9T??D ;; dE " " *,,CC)++CC D>>r6F)strictctj|}t|dd||i\}}t|S)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r9r: _joinrealpathr)filenamerr3oks r4r*r*s>y""HXbqb\8VR@@HD" 4==r6ct|trd}d}d}nd}d}d}t|r |dd}|}|r0||\}}}|r||kr%||kr/|r*t |\}}||krt |||}n|}Zt ||} t j| } tj | j } n#t$r|rd} YnwxYw| s| }| |vr4|| }||rt j| nt | |dfSd|| <t|t j | ||\}} | st ||dfS||| <|0|d fS) Nr/rSrbrrrrJFT)r0r1r partitionr r r9rYr\r]r^rZrreadlink) r3restrseenr$r"r#r_newpathr_is_linkrs r4rrs$ T{{ABBx ,s++ a tv~   6>  "4[[ d6>6ff55D tT"" /'""B l2:..GG     GGG   D  d? 2=D  2    GT**E11W  r{7';';VTJJb +d##U* *W Y ,\ :s)CC)(C)darwinc||stdtj|}t|trd}d}d}nd}d}d}||}ntj|} d t ||D}d t ||D}tt||g}|gt||z z||dz}|s|St|S#ttttf$rtjd ||wxYw) z#Return a relative version of a pathzno path specifiedrSr/rbrrrNcg|]}||Sr.0xs r4 zrelpath..s@@@Aa@a@@@r6cg|]}||Srrrs r4rzrelpath..s>>>1A>Q>>>r6r,)r[r9r:r0r1rr rMrr rArBrCDeprecationWarningrDrE) r3rr"r$r# start_list path_listrOrel_lists r4r,r,s] .,--- 9T??D$ ! %   @@!5!5c!:!:@@@ >> 3 3C 8 8>>>  j)455 6 68s:q01IabbMA MX ~|5G H$Ye<<< s"BD=D5D;c |stdtttj|}t |dt rd d nd d fd|D} t fd|D\}n#t$rtd d wxYw fd |D}t|}t|}|}t|D]\}}|||kr |d |}n|r n d d}| |zS#ttf$rtjd g|RwxYw) zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr/rSrrc:g|]}|Sr)r )rr3r$s r4rzcommonpath..s#9994tzz#999r6c34K|]}|ddkVdS)NrJr)rrGr$s r4 zcommonpath.. s/55!2A2#555555r6z%Can't mix absolute and relative pathsNc,g|]}fd|DS)c$g|] }||k | Srr)rcr"s r4rz)commonpath...$s':::a:a6k::::r6r)rr;r"s r4rzcommonpath..$s.PPPq::::1:::PPPr6r-)r[tupler?r9r:r0r1setminmax enumerater rArBrDrE) paths split_pathsr rergcommonrOrprefixr"r$s @@r4r-r-s B@AAA #bi'' ( (E%(E""99995999  P5555u55555FEE P P PDEE4 O PQPPPKPPP      bMM  DAqBqEz BQB *3rr7(((( ~ &$\:E:::: s% D,/B D, B((BD,,%E)N)*__doc__r"r#r(r$r%r&r'r)r9r|r\rD__all__r5rr r r r rTr rrrrrrrrrposixrrrurr*rr}r+r,r-rr6r4rsL              :   "777(0 $$$T6)6)6)z   ...j0+$$$$$$T++++Q%%%$$$$$%`   "'<<<~"lh6!!!!R#####s+A55B?B