a DOgi=@sdZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l Tgd Z d d Zd dZddZddZddZddZe jje_ddZddZddZddZdd Zd!d"Zd#d$Zdadad%d&Zd'd(Zd)d*Z d+d,Z!d-d.Z"e j#d/kZ$d4d0d1Z%d2d3Z&dS)5aCommon 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 commonpathcCst|trdSdSdS)N/r) isinstancebytespathr2./opt/alt/python39/lib64/python3.9/posixpath.py_get_sep)s r4cCs t|S)z6Normalize case of pathname. Has no effect under Posixosfspath)sr2r2r3r4srcCst|}t|}||S)zTest whether a path is absolute)r6r7r4 startswith)r8r#r2r2r3r<s rc Gst|}t|}|}z^|s,|dd|ttj|D]8}||rL|}q8|rZ||rd||7}q8|||7}q8Wn.tttfyt j d|g|RYn0|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 ) r6r7r4mapr9endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)apr#r1br2r2r3r Gs    r cCs`t|}t|}||d}|d|||d}}|rX||t|krX||}||fS)zSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.Nr6r7r4rfindlenrstrip)rBr#iheadtailr2r2r3r ds  r cCs6t|}t|trd}d}nd}d}t||d|S)Nr-.rr)r6r7r.r/r? _splitext)rBr#r'r2r2r3r us  r cCst|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr5)rBr2r2r3r s r cCs,t|}t|}||d}||dS)z)Returns the final component of a pathnamerDN)r6r7r4rF)rBr#rIr2r2r3r s r cCsNt|}t|}||d}|d|}|rJ||t|krJ||}|S)z-Returns the directory component of a pathnamerDNrE)rBr#rIrJr2r2r3rs   rc Cs6zt|}Wntttfy(YdS0t|jS)z&Test whether a path is a symbolic linkF)r6lstatOSError ValueErrorr=statS_ISLNKst_mode)r1str2r2r3rs rc Cs,zt|Wnttfy&YdS0dS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r6rNrOrPr0r2r2r3rs rc Cszt|}Wnttfy&YdS0t|jr8dSt|trNt |d}n t |d}t |}zt|}WnttfyYdS0|j }|j }||krdS|j }|j }||krdSdS)z$Test whether a path is a mount pointF..rT) r6rNrOrPrQrRrSr.r/r r)st_devst_ino)r1s1parents2dev1dev2ino1ino2r2r2r3rs.    rc Cs8t|}t|trd}nd}||s,|St|}||d}|dkrPt|}|dkrdtjvrddl }z| t j }Wqt y|YS0n tjd}nTddl }|d|}t|trt|d}z||}Wnt y|YS0|j }t|trt|}d}nd }||}|||dp6|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.~~rDrHOMENASCIIr-r)r6r7r.r/r9r4findrGenvironpwdgetpwuidgetuidpw_dirKeyErrorstrgetpwnamfsencoderH) r1tilder#rIreuserhomenamepwentrootr2r2r3rsB                rc CsXt|}t|trVd|vr |Sts:ddl}|d|jatj}d}d}t tdd}n:d|vrb|St s|ddl}|d |ja t j}d }d }tj }d}|||}|sqT| d\}}| d } | |r| |r| d d } z.|durttj t| } n|| } Wnty$|}Yq0||d} |d|| }t|}|| 7}q|S)zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.$rNs\$(\w+|\{[^}]*\}){}environb$z\$(\w+|\{[^}]*\}){}rD)r6r7r.r/ _varprogbrecompilerbsearchgetattr_varprogrdspangroupr9r;rlfsdecoderirG) r1r{r}startendrdrImjrovaluerKr2r2r3rsN          rc Cst|}t|tr&d}d}d}d}nd}d}d}d}||krB|S||}|rp||d rp||d spd }||}g}|D]J}|||fvrq||ks|s|r|r|d |kr||q|r|q|}||}|r|||}|p|S) z0Normalize path, eliminating double slashes, etc.r-rLrUrrrry) r6r7r.r/r9r appendpopr ) r1r#emptydotdotdotinitial_slashescomps new_compscompr2r2r3rNsJ            rcCs@t|}t|s8t|tr&t}nt}t||}t|S)zReturn an absolute path.) r6r7rr.r/getcwdbgetcwdr r)r1cwdr2r2r3rus    rcCs*t|}t|dd|i\}}t|S)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r6r7 _joinrealpathr)filenamer1okr2r2r3r)s r)c Cst|trd}d}d}n d}d}d}t|r<|dd}|}|r||\}}}|r<||kr`q<||kr|rt|\}}||krt|||}q<|}qrzrelpath..cSsg|] }|r|qSr2r2rr2r2r3rrr+)rPr6r7r.r/rr rGrr r<r=r>DeprecationWarningr?r@) r1rr!r#r" start_list path_listrIrel_listr2r2r3r+s0    r+c s2|s tdtttj|}t|dtr4ddnddzćfdd|D}ztfd d |D\}Wntytd d Yn0fd d|D}t|}t |}|}t |D]$\}}|||kr|d |}qq|rn d d}| |WSt t fy,tjdg|RYn0d S)zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr-rLrrcsg|]}|qSr2)r )rr1r#r2r3rrzcommonpath..c3s|]}|ddkVqdS)NrDr2)rrBrr2r3 rzcommonpath..z%Can't mix absolute and relative pathsNcsg|]}fdd|DqS)csg|]}|r|kr|qSr2r2)rcr!r2r3rrz)commonpath...r2)rr8rr2r3rrr,)rPtupler:r6r7r.r/setminmax enumerater r<r=r?r@) paths split_pathsrrXrZcommonrIrprefixr2)r!r#r3r,s6   r,)N)'__doc__r!r"r'r#r$r%r&r(r6sysrQr?__all__r4rrr r r rMr r rrrrrrrzrrrr)rplatformr*r+r,r2r2r2r3sL        *25' 3  )