K`~.FdZdZdZdZdZdZdZdZdZddl 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 commonpath ALLOW_MISSINGc4t|trdSdS)N/r) isinstancebytespaths 0/opt/alt/python311/lib64/python3.11/posixpath.py_get_sepr6)s$tsc*tj|S)z6Normalize case of pathname. Has no effect under Posixosfspath)ss r5rr4s 9Q<<r7crtj|}t|}||S)zTest whether a path is absolute)r:r;r6 startswith)r<r$s r5r r <s, ! A 1++C <<  r7ctj|}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;r6mapr>endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)apr$r4bs r5r 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.Nr:r;r6rfindlenrstrip)rHr$iheadtails r5r r ds ! A 1++C  qA2A2!""$D  CII %%{{3 :r7ctj|}t|trd}d}nd}d}t j||d|S)Nr0.rr)r:r;r1r2rE _splitext)rHr$r(s r5r r usN ! A!U  Cv 6 66r7cBtj|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr9)rHs r5r r s" ! A RaR5!8Or7ctj|}t|}||dz}||dS)z)Returns the final component of a pathnamerKN)r:r;r6rM)rHr$rPs r5rrs; ! A 1++C  qA QRR5Lr7ctj|}t|}||dz}|d|}|r+||t |zkr||}|S)z-Returns the directory component of a pathnamerKNrL)rHr$rPrQs r5rrsm ! A 1++C  qA RaR5D  CII %%{{3 Kr7c tj|}n#tttf$rYdSwxYwt j|jS)z&Test whether a path is a symbolic linkF)r:lstatOSError ValueErrorrCstatS_ISLNKst_mode)r4sts r5rrsQ Xd^^ Z 0uu < # ##s 22cb tj|n#ttf$rYdSwxYwdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r:rZr[r\r3s r5rrsB  Z uu 4s ,,c tj|}tj|jrdSn#t t f$rYdSwxYwtj|}t|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:rZr]r^r_r[r\r;r1r2r r*st_devst_ino)r4s1parents2dev1dev2ino1ino2s r5rrs' Xd^^ < # # 5  Z uu 9T??D$"dE""dD!! f  F Xf   Z uu 9D 9D t||t 9D 9D t||t 5s!2AA$B99C Cctj|}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.~~rKrHOMENASCIIvxworksr0r)r:r;r1r2r>r6findrNenvironpwd ImportErrorgetpwuidgetuidpw_dirKeyErrorstrgetpwnamsysplatformfsencoderO) r4tilder$rPruuserhomenamepwentroots r5rrs3 9T??D$ ??5 ! ! 4..C #qA1uu IIAvv  # #        << 44;      z&)HH  JJJJ   KKK AaCy dE " " &tW%%D LL&&EE   KKK <CLI55 $;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+|\{[^}]*\}){}TrK)r:r;r1r2 _varprogbrecompilerqsearchgetattr_varprogrtspangroupr>rArfsdecoderNrz) r4rrstartendrtrPmjrvaluerRs r5rr%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.rTr)r:r;r1r2rrrr3s r5rrs\y dE " " J;~bk$.?.?@@AAIT Id##*s*r7c0tj|}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) rr0r7rTrcrrrr) r:r;r1r2r>r appendpopr ) r4r$emptydotdotdotinitial_slashescomps new_compscomps r5rr^shy dE " " CECFFCECF 5==J//#..  OOCE " " +/??3q5+A+A O 3   Ds|##y )"  7 7  &&&&  xx  .&-D{sr7ctj|}t|sLt|trtj}ntj}t||}t|S)zReturn an absolute path.) r:r;r r1r2getcwdbgetcwdr r)r4cwds r5rrs` 9T??D ;; dE " " *,,CC)++CC D>>r7F)strictctj|}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)filenamerr4oks r5r*r*s>y""HXbqb\8VR@@HD" 4==r7c0t|trd}d}d}nd}d}d}tj}|turt }n |rd}nt }d} t|r |dd}|}|r(||\} } }| r| |kr%| |kr/|r*t|\}} | |krt|||}n|}Zt|| } tj | } tj | j}n #|$rd }YnwxYw|s| }| |vr4|| }||rtj | nt| |d fSd|| <t|tj| ||\}}|st||d fS||| <|(|d fS) Nr0rTrcrrrrKFT)r1r2r:rr.FileNotFoundErrorr[r partitionr r rZr]r^r_rreadlink)r4restrseenr$r"r#r ignored_errormaxlinksr_newpathr`is_linkrs r5rrs $ )    H T{{ABBx *s++ a tv~~  6>> "4[[ d6>>ff55D tT"" /'""Bl2:..GG   GGG  D  d??=D 2    GT**E11W  r{7';';VTJJb +d##U* *W U *X :sDD  D 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 specifiedrTr0rcrrrNcg|]}||Srr.0xs r5 zrelpath..s@@@Aa@a@@@r7cg|]}||Srrrs r5rzrelpath..s>>>1A>Q>>>r7r,)r\r:r;r1r2rr rNrr rBrCrDDeprecationWarningrErF) r4rr"r$r# start_list path_listrPrel_lists r5r,r,sZ .,--- 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 sequencerr0rTrrc:g|]}|Sr)r )rr4r$s r5rzcommonpath..%s#9994tzz#999r7c34K|]}|ddkVdS)NrKr)rrHr$s r5 zcommonpath..(s/55!2A2#555555r7z%Can't mix absolute and relative pathsNc,g|]}fd|DS)c$g|] }||k | Srr)rcr"s r5rz)commonpath...,s#:::a:a6kkkkkr7r)rr<r"s r5rzcommonpath..,s.PPPq::::1:::PPPr7r-)r\tupler@r:r;r1r2setminmax enumerater rBrCrErF) paths split_pathsr rfrhcommonrPrprefixr"r$s @@r5r-r-s B@AAA #bi'' ( (E%(E""99995999  P5555u55555FEE P P PDEE4 O PQPPPKPPP      bMM  DAqBqEzzBQB*3rr7(((( ~ &$\:E:::: s% D,/B D, B((BD,,%E)N)*__doc__r"r#r(r$r%r&r'r)r:r}r]rE__all__r6rr r r r rUr rrrrrrrrrposixrrrvrr*rr~r+r,r-rr7r5rsO            * * *:   "777(0 $$$V6)6)6)z   ...j0+$$$$$$T++++Q%%%$$$$$%`   "'CCCL"lh6!!!!R#####s+A55B?B