U e5d =&@s^dZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l Td d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/g&Z d0d1Zd2d Zd3d Zd4d Zd5dZd6dZe jje_d7d Zd8dZd9dZd:dZd;dZddZd?dZd@d Z dAd,Z!dBdCZ"e j#dDkZ$dGdEd.Z%dFd/Z&dS)HaCommon 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!/usr/lib64/python3.8/posixpath.py_get_sep)s r4cCs t|S)z6Normalize case of pathname. Has no effect under Posixosfspath)sr2r2r3r4scCst|}t|}||S)zTest whether a path is absolute)r6r7r4 startswith)r8r#r2r2r3r<s c Gst|}t|}|}z^|s,|dd|ttj|D]8}||rL|}q8|rZ||rd||7}q8|||7}q8Wn.tttfk rt j d|f|YnX|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    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  cCs6t|}t|trd}d}nd}d}t||d|S)Nr-.rr)r6r7r.r/r? _splitext)rBr#r'r2r2r3r us  cCst|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr5)rBr2r2r3r s cCs,t|}t|}||d}||dS)z)Returns the final component of a pathnamerDN)r6r7r4rF)rBr#rIr2r2r3r s cCsNt|}t|}||d}|d|}|rJ||t|krJ||}|S)z-Returns the directory component of a pathnamerDNrE)rBr#rIrJr2r2r3rs   c Cs8zt|}Wntttfk r*YdSXt|jS)z&Test whether a path is a symbolic linkF)r6lstatOSError ValueErrorr=statS_ISLNKst_mode)r1str2r2r3rs c Cs.zt|Wnttfk r(YdSXdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r6rNrOrPr0r2r2r3rs c Cszt|}Wnttfk r(YdSXt|jr:dSt|trPt |d}n t |d}t |}zt|}Wnttfk rYdSX|j }|j }||krdS|j }|j }||krdSdS)z$Test whether a path is a mount pointF..rT) r6rNrOrPrQrRrSr.r/r r)st_devst_ino)r1s1parents2dev1dev2ino1ino2r2r2r3rs.    c Cs<t|}t|trd}nd}||s,|St|}||d}|dkrPt|}|dkrdtjkrddl }z| t j }Wqt k r|YSXn tjd}nVddl }|d|}t|trt|d}z||}Wnt k r|YSX|j }t|trt|}d}nd }||}|||dp:|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.~~rDrHOMENASCIIr-r)r6r7r.r/r9r4findrGenvironpwdgetpwuidgetuidpw_dirKeyErrorstrgetpwnamfsencoderH) r1tilder#rIreuserhomenamepwentrootr2r2r3rsB              c CsZt|}t|trVd|kr |Sts:ddl}|d|jatj}d}d}t tdd}n:d|krb|St s|ddl}|d |ja t j}d }d }tj }d}|||}|sqV| d\}}| d } | |r| |r| d d } z.|dkrttj t| } n|| } Wntk r&|}YqX||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          c Cst|}t|tr&d}d}d}d}nd}d}d}d}||krB|S||}|rp||d rp||d spd }||}g}|D]J}|||fkrq||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            cCs@t|}t|s8t|tr&t}nt}t||}t|S)zReturn an absolute path.) r6r7rr.r/getcwdbgetcwdr r)r1cwdr2r2r3rts    cCs*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 c Cst|trd}d}d}n d}d}d}t|r<|dd}|}|r||\}}}|r<||kr`q<||kr|rt|\}}||krt|||}q<|}qszrelpath..cSsg|] }|r|qSr2r2rr2r2r3rsr+)rPr6r7r.r/rr rGrr r<r=r>DeprecationWarningr?r@) r1rr!r#r" start_list path_listrIrel_listr2r2r3r+s0    c s2|s tdtttj|}t|dtr4ddnddzƇfdd|D}ztfd d |D\}Wntk rtd d YnXfd d|D}t|}t |}|}t |D]$\}}|||kr|d |}qq|rn d d}| |WSt t fk r,tjd|YnXd S)zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr-rLrrcsg|]}|qSr2)r )rr1r#r2r3rszcommonpath..c3s|]}|ddkVqdS)NrDr2)rrBrr2r3 szcommonpath..z%Can't mix absolute and relative pathsNcsg|]}fdd|DqS)csg|]}|r|kr|qSr2r2)rcr!r2r3rsz)commonpath...r2)rr8rr2r3rsr,)r,)rPtupler:r6r7r.r/setminmax enumerater r<r=r?r@) paths split_pathsrrXrZcommonrIrprefixr2)r!r#r3r,s6  )N)'__doc__r!r"r'r#r$r%r&r(r6sysrQr?__all__r4rrr r r rMr r rrrrrrrzrrrr)rplatformr*r+r,r2r2r2r3s         *25& 3  )