QfC`dZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l gd Z d Zd Zd ZdZdZdZe j(je_dZdZdZdZdZdZdZdZdadadZ ddl m!Z"dZ$dddZ%d Z&e jNd!k(Z(d$d"Z)d#Z*y#e#$rdZ"Y-wxYw)%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 splitdrive splitrootsplitsplitextbasenamedirname commonprefixgetsizegetmtimegetatimegetctimeislinkexistslexistsisdirisfileismount expanduser expandvarsnormpathabspathsamefile sameopenfilesamestatcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpath commonpath isjunctionc&t|tryy)N/r) isinstancebytespaths 0/opt/alt/python312/lib64/python3.12/posixpath.py_get_sepr7)s$c,tj|S)z6Normalize case of pathname. Has no effect under Posixosfspath)ss r6rr4s 99Q<r8cdtj|}t|}|j|S)zTest whether a path is absolute)r;r<r7 startswith)r=r%s r6r r <s' ! A 1+C << r8cjtj|}t|}|} |s|dd|zttj|D]7}|j |r|}|r|j |r||z }0|||zz }9 |S#t ttf$rtjd|g|wxYw)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<r7mapr?endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)apr%r5bs r6r r Gs ! A 1+C D  !HsNRYY"A||C T]]3/ a # K ~| 4$$VQ33 s AB-B2ctj|}t|}|j|dz}|d|||d}}|r"||t |zk7r|j |}||fS)zSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.Nr;r<r7rfindlenrstrip)rIr%iheadtails r6r r dsk ! A 1+C  qA2A!"$D CI %{{3 :r8ctj|}t|trd}d}nd}d}t j ||d|S)Nr1.rr)r;r<r2r3rF _splitext)rIr%r)s r6rrusD ! A!U  Cv 66r8c:tj|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr:)rIs r6r r s  ! A Ra5!8Or8ctj|}t|trd}d}nd}d}|dd|k7r|||fS|dd|k7s|dd|k(r|||ddfS||dd|ddfS) aSplit a pathname into drive, root and tail. On Posix, drive is always empty; the root may be empty, a single slash, or two slashes. The tail contains anything after the root. For example: splitroot('foo/bar') == ('', '', 'foo/bar') splitroot('/foo/bar') == ('', '/', 'foo/bar') splitroot('//foo/bar') == ('', '//', 'foo/bar') splitroot('///foo/bar') == ('', '/', '//foo/bar') r1r8rNrL)r;r<r2r3)rIr%emptys r6r r s ! A!U!u|eQ 1Q3!Aa&C-c1QR5  aeQqrU""r8cttj|}t|}|j|dz}||dS)z)Returns the final component of a pathnamerLN)r;r<r7rN)rIr%rQs r6rrs5 ! A 1+C  qA QR5Lr8ctj|}t|}|j|dz}|d|}|r"||t |zk7r|j |}|S)z-Returns the directory component of a pathnamerLNrM)rIr%rQrRs r6rrsZ ! A 1+C  qA Ra5D CI %{{3 Kr8c.tj|y)zQTest whether a path is a junction Junctions are not a part of posix semanticsFr:r4s r6r/r/sIIdO r8cZ tj|y#ttf$rYywxYw)zCTest whether a path exists. Returns True for broken symbolic linksFT)r;lstatOSError ValueErrorr4s r6rrs0   Z s **c tj|}tj|jrytj|}t|tr t|d}n t|d}t|} tj|}|j}|j}||k7ry|j}|j}||k(ryy#t t f$rYywxYw#t t f$rYywxYw)z$Test whether a path is a mount pointF..rT)r;rastatS_ISLNKst_moderbrcr<r2r3r r+st_devst_ino)r5s1parents2dev1dev2ino1ino2s r6rrs XXd^ << # 99T?D$dE"dD! f F XXf  99D 99D t| 99D 99D t| 7 Z  Z s#CC(C%$C%(C:9C:crtj|}t|trd}nd}|j |s|St |}|j |d}|dkr t|}|dk(rZdtjvr4 ddl } |jtjj}natjd}nM ddl }|d|}t|trtj|} |j!|}|j}|t"j$dk(r|St|trtj&|}d}nd }|j)|}|||dzxs|S#t$r|cYSwxYw#t$r|cYSwxYw#t$r|cYSwxYw#t$r|cYSwxYw) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.~~rLrHOMENvxworksr1r)r;r<r2r3r?r7findrOenvironpwd ImportErrorgetpwuidgetuidpw_dirKeyErrorfsdecodegetpwnamsysplatformfsencoderP) r5tilder%rQryuserhomenamepwentroots r6rrs 99T?D$ ??5 ! 4.C #qA1u IAv  #  << 4;; zz&)H  Aay dE ";;t$D LL&E <<CLLI5 $;;x(t$H tABx  (D(I        K  K sHE5-F F:F(5 FF FF F%$F%( F65F6c,tj|}t|trRd|vr|Sts ddl}|j d|jatj}d}d}ttdd}nPd|vr|Sts ddl}|j d |ja tj}d }d }tj}d} |||}|s |S|jd\}}|jd } | j|r| j|r| d d } |:tj tjtj"| } n|| } ||d} |d|| z}t%|}|| z }#t&$r|}YwxYw)zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.$rNs\$(\w+|\{[^}]*\}){}environb$z\$(\w+|\{[^}]*\}){}rL)r;r<r2r3 _varprogbrecompileASCIIsearchgetattr_varprogrxspangroupr?rBrrrOr~) r5rrstartendrxrQmjrvaluerSs r6rr@s 99T?D$ t K  #8"((CI!!"j$/ d?K zz"6AH** A  4O " K!vvay1wwqz ??5 !dmmC&8":D  BJJr{{4/@$AB 8D8e#DD A DLD'  A s&AF FF)_path_normpathctj|}t|tr d}d}d}d}nd}d}d}d}||k(r|St |\}}}|j |}g}|D]A} | ||fvr | |k7s|s|r |r|d |k(r|j | /|s2|jC|}||j|z}|xs|S) z0Normalize path, eliminating double slashes, etc.r1r8rUrerrYrrr) r;r<r2r3r r appendpopr ) r5r%r\dotdotdot_initial_slashescomps new_compscomps r6rrysyy dE "CECFCECF 5=J#,T? ?D 3 Ds|#y "  7  & %0{sr8ctj|}t|sEt|trtj }ntj }t||}t|S)zReturn an absolute path.) r;r<r r2r3getcwdbgetcwdr r)r5cwds r6rrsK 99T?D ; dE "**,C))+CC D>r8F)strictcjtj|}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)filenamerr5oks r6r+r+s6yy"HXbq\8VR@HD" 4=r8ct|trd}d}d}nd}d}d}t|r|dd}|}|r|j|\}}}|r||k(r ||k(r&|r!t |\}}||k(rt |||}n|}Kt ||} t j| } tj| j} | s| }| |vr.|| }||rt j| nt | |dfSd|| <t|t j| ||\}} | st ||dfS||| <|r|d fS#t$r|rd} YwxYw) Nr1rUrerrrrLFT)r2r3r partitionr r r;rarfrgrhrbrreadlink) r5restrseenr%r#r$rrnewpathstis_linkrs r6rrs$ T{ABx s+ atv~  6>"4[ d6>ff5D tT" /'"B ll2::.GD  d?=D GT*E11W  r{{7';VTJbd#U* *W Y \ :; G sD99E  E darwincP|s tdtj|}t|trd}d}d}nd}d}d}||}ntj|} t |j |Dcgc]}|s| }}t |j |Dcgc]}|s| }}tt||g}|gt||z z||dz} | s|St| Scc}wcc}w#ttttf$rtjd ||wxYw) z#Return a relative version of a pathzno path specifiedrUr1rerrrNr-)rcr;r<r2r3rr rOrr rCrDrEDeprecationWarningrFrG) r5rr#r%r$x start_list path_listrQrel_lists r6r-r-s2 ,-- 99T?D$ } %  !(!5!5c!:@!:Aaa!: @ ' 3 3C 8> 81AQ 8 >  j)45 68s:q01IabMAMXA> ~|5G H$$Ye< s<C37C)?C)C3!C.)C.-3C3!C3) C332D%c  |s tdtttj|}t |dt rd d}nd d} |Dcgc]}|j }} t fd|D\}|Dcgc]}|Dcgc] }|s||k7s |c}}}}t|}t|}|} t|D]\} }||| k7s|d | } n|r n d d} | j| zScc}w#t$r tdd wxYwcc}wcc}}w#ttf$rtj d g|wxYw) zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr1rUrrc3.K|] }|ddk(yw)NrL).0rIr%s r6 zcommonpath..,s5u!2A#usz%Can't mix absolute and relative pathsNr.)rctuplerAr;r<r2r3r setminmax enumerater rCrDrFrG) pathsr#r5 split_pathsr r=crkrmcommonrQprefixr%s @r6r.r.su @AA #bii' (E%(E"38954tzz#5 9 P5u55FEEPPKq1:1aa6k1:K P    bMDAqBqEzBQ" 3r7(((#: PDE4 O P;P ~ &$$\:E: slD,D+D,.DD, D&D! D! D! $D&)4D,$D,D,DD,!D&&D,,'E)N)+__doc__r#r$r)r%r&r'r(r*r;rrfrF__all__r7rr r r rrVr r rrr/rrrrrrposixrrrzrr+rrr,r-r.rr8r6rs            ': "7((00 #>V6)z   .j 0D "'<~"llh6!R#Es9B""B-,B-