VcZBcsFdZdZdZdZdZdZdZdZdZddl 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:z /bin:/usr/binNz /dev/null)Z*)&normcaseisabsjoin splitdrivesplitsplitextbasenamedirname commonprefixZgetsizeZgetmtimeZgetatimeZgetctimeislinkZexistslexistsZisdirZisfileismount expanduser expandvarsnormpathabspathZsamefileZ sameopenfileZsamestatcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpath commonpathcs4t|trdSdS)N/r) isinstancebytespath "/usr/lib64/python3.11/posixpath.py_get_sepr')s$tscs*tj|S)z6Normalize case of pathname. Has no effect under Posixosfspath)sr%r&rr4s 9Q<<r(csrtj|}t|}||S)zTest whether a path is absolute)r*r+r' startswith)r,r r&rr<s, ! A 1++C <<  r(cstj|}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) r*r+r'mapr-endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)Zaprr$Zb r&rrGs ! A 1++C D   !HsNNRY""  A||C    T]]3//  a   ~| 4$VQ33333  Ks A)B,B=cstj|}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.Nr*r+r'rfindlenrstrip)r6riheadtailr7r&rrds ! A 1++C  qA2A2!""$D  CII % {{3 :r(cstj|}t|trd}d}nd}d}t j||d|S)Nr .rr)r*r+r!r"r4 _splitext)r6rr r&r r usN ! A!U  Cv 6 66r(csBtj|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr))r6r%r&rrs" ! A RaR5!8Or(cstj|}t|}||dz}||dS)z)Returns the final component of a pathnamer8N)r*r+r'r:)r6rr=rBr&r r s; ! A 1++C  qA QRR5Lr(cstj|}t|}||dz}|d|}|r+||t |zkr||}|S)z-Returns the directory component of a pathnamer8Nr9)r6rr=r> r&r r so ! A 1++C  qA RaR5D  CII % {{3 Kr(cs tj|}n#tttf$rYdSwxYwt j|jS)z&Test whether a path is a symbolic linkF)r*lstatOSError ValueErrorr2statS_ISLNKst_mode)r$str.r&r r sQ Xd^^ Z 0uu < # ##s 22csb tj|n#ttf$rYdSwxYwdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r*rDrErFr#r%r&rrsB  Z uu 4s ,,cs 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) r*rDrGrHrIrErFr!r"rrZst_devZst_ino)r$s1Zparents2Zdev1Zdev2Zino1Zino2s r&rrs  Xd^^ < # # 5  Z uu$"dE""dD!! f  F Xf   Z uu 9D 9D t|t 9D 9D t|t 5s!2AAB%%B:9B:cstj|}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.s~z~r8rZHOMENASCIIZvxworksr r)r*r+r!r"r-r'Zfindr;environpwd ImportErrorZgetpwuidZgetuidZpw_dirKeyErrorZstrZgetpwnamsysplatformfsencoder<) r$Ztilderr=rPZuserhomenameZpwentZroot r&rrs? 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+csvtj|}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.s$rNs\$(\w+|\{[^}]*\})s{s}Zenvironbz$z\$(\w+|\{[^}]*\})z{z}Tr8)r*r+r!r" _varprogbreZcompilerNsearchZgetattr_varprogrOZspanZgroupr-r0rUfsdecoder;rR) r$rZr[startZendrOr=ZmZjrVZvaluer?s r&rr$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_normpathcstj|}t|tr5tjt tj|pdSt |pdS)0Normalize path, eliminating double slashes, etc.r@r)r*r+r!r"rUr_r]r#r%r&rrs\y dE " " J;~bk$.?.?@@AAIT Id##*s*r(cs0tj|}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) r`r r(r@rKrZrriirX) r*r+r!r"r-rZappendZpopr) r$rZemptyZdotZdotdotZinitial_slashesZcompsZ new_compsZcomprWr&rr]sxy dE " " CECFFCECF 5= J//#..  OOCE " " +/??3q5+A+A O 3   Ds|#   y  )"  7   &&&&  xx  .&-D{sr(cstj|}t|sLt|trtj}ntj}t||}t|S)zReturn an absolute path.) r*r+rr!r"ZgetcwdbZgetcwdrr)r$Zcwdr.r&rrs` 9T??D ;; dE " " *,,CC)++CC D>>r(F)strictcstj|}t|dd||i\}}t|S)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r*r+ _joinrealpathr)Zfilenamerar$okrCr&rrs>y""HXbqb\8VR@@HD" 4==r(cst|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 r@rKrrrr8FT)r!r"rZ partitionrrr*rDrGrHrIrErbZreadlink) r$ZrestraZseenrrrrVZ_ZnewpathrJZis_linkrcs r&rbrbs$ 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)Zdarwincs||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 specifiedr@r rKrrrNcg|]}||Sre.0Zxr.r& relpath..s@@@Aa@a@@@r(crdrererfr.r&rhris>>>1A>Q>>>r(r)rFr*r+r!r"rrr;r rr1r2r3ZDeprecationWarningr4r5) r$r^rrrZ start_listZ path_listr=Zrel_listrWr&rrs] .,--- 9T??D$ ! %   @@!5!5c!:!:@@@ >> 3 3C 8 8>>>  j)455 6 68s:q01IabbMA MX ~|5G H$Ye<<< s"BD=D5D;cs |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 r@rrcs:g|]}|Sre)r)rgr$r r&rhcommonpath..s#9994tzz#999r(c3s4K|]}|ddkVdS)Nr8re)rgr6rrjr&z zcommonpath.. s/55!2A2#555555r(z%Can't mix absolute and relative pathsNcs,g|]}fd|DS)cs$g|] }||k | Srere)rgcrrjr&rhz)commonpath...$s':::a:a6k::::r(re)rgr,rrjr&rhrk$s.PPPq::::1:::PPPr(r)rFZtupler/r*r+r!r"ZsetZminZmaxZ enumeraterr1r2r4r5) ZpathsZ split_pathsrrLrMZcommonr=rlZprefixrrs @@r&rrs 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)*Z__doc__rrrrrrrrr*rSrGr4Z__all__r'rrrrr rArr r r rrrr\rYrZposixr_rrQrrrbrTrrrrer(r&rmsL              :   "777(0 $$$T6)6)6)z   ...j0+$$$$$$T++++Q%%%$$$$$%`   "'<<<~"lh6!!!!R#####s+A55B?B