OZ:`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 isjunction ALLOW_MISSINGc&t|tryy)N/r) isinstancebytespaths 0/opt/alt/python312/lib64/python3.12/posixpath.py_get_sepr8)s$c,tj|S)z6Normalize case of pathname. Has no effect under Posixosfspath)ss r7rr4s 99Q<r9cdtj|}t|}|j|S)zTest whether a path is absolute)r<r=r8 startswith)r>r%s r7r r <s' ! A 1+C << r9cjtj|}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=r8mapr@endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)apr%r6bs r7r 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=r8rfindlenrstrip)rJr%iheadtails r7r r dsk ! A 1+C  qA2A!"$D CI %{{3 :r9ctj|}t|trd}d}nd}d}t j ||d|S)Nr2.rr)r<r=r3r4rG _splitext)rJr%r)s r7rrusD ! A!U  Cv 66r9c:tj|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr;)rJs r7r r s  ! A Ra5!8Or9ctj|}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') r2r9rNrM)r<r=r3r4)rJr%emptys r7r r s ! A!U!u|eQ 1Q3!Aa&C-c1QR5  aeQqrU""r9cttj|}t|}|j|dz}||dS)z)Returns the final component of a pathnamerMN)r<r=r8rO)rJr%rRs r7rrs5 ! A 1+C  qA QR5Lr9ctj|}t|}|j|dz}|d|}|r"||t |zk7r|j |}|S)z-Returns the directory component of a pathnamerMNrN)rJr%rRrSs r7rrsZ ! A 1+C  qA Ra5D CI %{{3 Kr9c.tj|y)zQTest whether a path is a junction Junctions are not a part of posix semanticsFr;r5s r7r/r/sIIdO r9cZ tj|y#ttf$rYywxYw)zCTest whether a path exists. Returns True for broken symbolic linksFT)r<lstatOSError ValueErrorr5s r7rrs0   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<rbstatS_ISLNKst_modercrdr=r3r4r r+st_devst_ino)r6s1parents2dev1dev2ino1ino2s r7rrs 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.~~rMrHOMENvxworksr2r)r<r=r3r4r@r8findrPenvironpwd ImportErrorgetpwuidgetuidpw_dirKeyErrorfsdecodegetpwnamsysplatformfsencoderQ) r6tilder%rRrzuserhomenamepwentroots r7rrs 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+|\{[^}]*\}){}rM)r<r=r3r4 _varprogbrecompileASCIIsearchgetattr_varprogryspangroupr@rCrrrPr) r6rrstartendryrRmjrvaluerTs r7rr@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.r2r9rVrfrrZrrr) r<r=r3r4r r appendpopr ) r6r%r]dotdotdot_initial_slashescomps new_compscomps r7rrysyy dE "CECFCECF 5=J#,T? ?D 3 Ds|#y "  7  & %0{sr9ctj|}t|sEt|trtj }ntj }t||}t|S)zReturn an absolute path.) r<r=r r3r4getcwdbgetcwdr r)r6cwds r7rrsK 99T?D ; dE "**,C))+CC D>r9F)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)filenamerr6oks r7r+r+s6yy"HXbq\8VR@HD" 4=r9ct|trd}d}d}nd}d}d}tj}|turt }n |rd}nt }d} t|r|dd}|}|r|j|\} } }| r| |k(r | |k(r&|r!t|\}} | |k(rt|||}n|}Kt|| } tj| } tj| j}|s| }| |vr.|| }||rtj| nt| |d fSd|| <t|tj | ||\}}|st||d fS||| <|r|d fS#|$rd }YwxYw) Nr2rVrfrrrrMFT)r3r4r<rr0FileNotFoundErrorrcr partitionr r rbrgrhrirreadlink)r6restrseenr%r#r$r ignored_errormaxlinksrrnewpathstis_linkrs r7rrs$ )   H T{ABx s+ atv~  6>"4[ d6>ff5D tT" /'"Bll2::.GD  d?=D GT*E11W  r{{7';VTJbd#U* *W U X :7 G s4E%%E/.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 specifiedrVr2rfrrrNr-)rdr<r=r3r4rr rPrr rDrErFDeprecationWarningrGrH) r6rr#r%r$x start_list path_listrRrel_lists r7r-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 sequencerr2rVrrc3.K|] }|ddk(yw)NrMr).0rJr%s r7 zcommonpath..3s5u!2A#usz%Can't mix absolute and relative pathsNr.)rdtuplerBr<r=r3r4r setminmax enumerater rDrErGrH) pathsr#r6 split_pathsr r>crlrncommonrRprefixr%s @r7r.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<rrgrG__all__r8rr r r rrWr r rrr/rrrrrrposixrrr{rr+rrr,r-r.rr9r7rs            8: "7((00 #>V6)z   .j 0D "'CL"llh6!R#Ss9B""B-,B-