U "»ßj„>ã'@sjdZdZdZdZdZdZdZdZdZddl 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/d0g'Z d1d2„Zd3d „Zd4d „Zd5d „Zd6d„Zd7d„Ze jje_d8d „Zd9d„Zd:d„Zd;d„Zdd„Zd?Zdadad@d„ZdAd„Z dBd „Z!dCdDœdEd,„Z"dFdG„Z#e j$dHkZ%dKdId.„Z&dJd/„Z'dS)LaÙCommon 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é)Ú*ÚnormcaseÚisabsÚjoinÚ splitdriveÚsplitÚsplitextÚbasenameÚdirnameÚ commonprefixÚgetsizeÚgetmtimeÚgetatimeÚgetctimeÚislinkÚexistsÚlexistsÚisdirÚisfileÚismountÚ expanduserÚ expandvarsÚnormpathÚabspathÚsamefileÚ sameopenfileÚsamestatÚcurdirÚpardirÚsepÚpathsepÚdefpathÚaltsepÚextsepÚdevnullÚrealpathÚsupports_unicode_filenamesÚrelpathÚ commonpathÚ ALLOW_MISSINGcCst|tƒrdSdSdS)Nó/r)Ú isinstanceÚbytes©Úpath©r3ú./opt/alt/python38/lib64/python3.8/posixpath.pyÚ_get_sep)s r5cCs t |¡S)z6Normalize case of pathname. Has no effect under Posix©ÚosÚfspath)Úsr3r3r4r4scCst |¡}t|ƒ}| |¡S)zTest whether a path is absolute)r7r8r5Ú startswith)r9r#r3r3r4r<s c Gs¨t |¡}t|ƒ}|}z^|s,|dd…|ttj|ƒD]8}| |¡rL|}q8|rZ| |¡rd||7}q8|||7}q8Wn.tttfk r¢t j d|f|žŽ‚YnX|S)zæJoin 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 ) r7r8r5Úmapr:ÚendswithÚ TypeErrorÚAttributeErrorÚ BytesWarningÚ genericpathÚ_check_arg_types)ÚaÚpr#r2Úbr3r3r4r Gs    cCs`t |¡}t|ƒ}| |¡d}|d|…||d…}}|rX||t|ƒkrX| |¡}||fS)z€Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.éN©r7r8r5ÚrfindÚlenÚrstrip)rCr#ÚiÚheadÚtailr3r3r4r ds  cCs6t |¡}t|tƒrd}d}nd}d}t ||d|¡S)Nr.ó.rr)r7r8r/r0r@Ú _splitext)rCr#r'r3r3r4r us  cCst |¡}|dd…|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr6)rCr3r3r4r ƒs cCs,t |¡}t|ƒ}| |¡d}||d…S)z)Returns the final component of a pathnamerEN)r7r8r5rG)rCr#rJr3r3r4r Œs cCsNt |¡}t|ƒ}| |¡d}|d|…}|rJ||t|ƒkrJ| |¡}|S)z-Returns the directory component of a pathnamerENrF)rCr#rJrKr3r3r4r–s   c Cs8zt |¡}Wntttfk r*YdSXt |j¡S)z&Test whether a path is a symbolic linkF)r7ÚlstatÚOSErrorÚ ValueErrorr>ÚstatÚS_ISLNKÚst_mode)r2Ústr3r3r4r¤s c Cs.zt |¡Wnttfk r(YdSXdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r7rOrPrQr1r3r3r4r®s c CsÀzt |¡}Wnttfk r(YdSXt |j¡r:dSt|tƒrPt |dƒ}n t |dƒ}t |ƒ}zt |¡}Wnttfk rŠYdSX|j }|j }||kr¤dS|j }|j }||kr¼dSdS)z$Test whether a path is a mount pointFó..rT) r7rOrPrQrRrSrTr/r0r r)Úst_devÚst_ino)r2Ús1ÚparentÚs2Údev1Údev2Úino1Úino2r3r3r4rºs.    c Cs<t |¡}t|tƒrd}nd}| |¡s,|St|ƒ}| |d¡}|dkrPt|ƒ}|dkr¦dtjkršddl }z|  t  ¡¡j }Wq¤t k r–|YSXn tjd}nVddl }|d|…}t|tƒrÎt|dƒ}z| |¡}Wnt k rô|YSX|j }t|tƒ�rt |¡}d}nd }| |¡}|||d…�p:|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.ó~ú~rErÚHOMENÚASCIIr.r)r7r8r/r0r:r5ÚfindrHÚenvironÚpwdÚgetpwuidÚgetuidÚpw_dirÚKeyErrorÚstrÚgetpwnamÚfsencoderI) r2Útilder#rJrfÚuserhomeÚnameÚpwentÚrootr3r3r4räsB              z\$(\w+|\{[^}]*\}?)cs®t |¡}t|tƒrZd|kr |Sts@ddl}| t ¡|j ¡j at}d‰d‰t tddƒ‰n:d|krf|St s‚ddl}| t|j ¡j a t }d‰d ‰tj ‰‡‡‡fd d „}|||ƒS) zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.ó$rNó{ó}Úenvironbú$Ú{Ú}cs‚|d}| ˆ¡r0| ˆ¡s$|dS|dd…}z,ˆdkrRt tjt |¡¡}nˆ|}Wntk rx|dYSX|SdS)NrEréÿÿÿÿ)r:r<r7rmreÚfsdecoderj)ÚmrpÚvalue©ÚendreÚstartr3r4Úrepl4s    zexpandvars..repl)r7r8r/r0Ú_varsubbÚreÚcompileÚ _varpatternÚencodercÚsubÚgetattrÚ_varsubre)r2rƒr‡r�r3r~r4rs,  c Csôt |¡}t|tƒr&d}d}d}d}nd}d}d}d}||krB|S| |¡}|rp| |d ¡rp| |d ¡spd }| |¡}g}|D]J}|||fkr”q‚||ks´|s¤|r´|rÀ|d |krÀ| |¡q‚|r‚| ¡q‚|}| |¡}|rì|||}|pò|S) z0Normalize path, eliminating double slashes, etc.r.órMrVrÚrréérz) r7r8r/r0r:r ÚappendÚpopr ) r2r#ÚemptyÚdotÚdotdotÚinitial_slashesÚcompsÚ new_compsÚcompr3r3r4rKsJ    ÿ ÿ  ÿ ÿ    cCs@t |¡}t|ƒs8t|tƒr&t ¡}nt ¡}t||ƒ}t|ƒS)zReturn an absolute path.) r7r8rr/r0ÚgetcwdbÚgetcwdr r)r2Úcwdr3r3r4rqs    F)ÚstrictcCs,t |¡}t|dd…||iƒ\}}t|ƒS)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r7r8Ú _joinrealpathr)Úfilenameršr2Úokr3r3r4r)€s cCs|t|tƒrd}d}d}n d}d}d}|tkr2t}n|räszrelpath..cSsg|] }|r|‘qSr3r3r¨r3r3r4r«åsr+)rQr7r8r/r0rr rHrr r=r>r?ÚDeprecationWarningr@rA) r2r€r!r#r"Ú start_listÚ path_listrJÚrel_listr3r3r4r+Îs0    c s2|s tdƒ‚tttj|ƒƒ}t|dtƒr4d‰d‰nd‰d‰zƇfdd„|Dƒ}zt‡fd d „|Dƒƒ\}Wntk rŠtd ƒd ‚YnX‡fd d„|Dƒ}t|ƒ}t |ƒ}|}t |ƒD]$\}}|||krº|d |…}qàqº|rèˆn ˆ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.rMrrcsg|]}| ˆ¡‘qSr3)r )r©r2©r#r3r4r«szcommonpath..c3s|]}|dd…ˆkVqdS)NrEr3)r©rCr°r3r4Ú szcommonpath..z%Can't mix absolute and relative pathsNcsg|]}‡fdd„|Dƒ‘qS)csg|]}|r|ˆkr|‘qSr3r3)r©Úc©r!r3r4r« sz)commonpath...r3)r©r9r³r3r4r« sr,)r,)rQÚtupler;r7r8r/r0ÚsetÚminÚmaxÚ enumerater r=r>r@rA) ÚpathsÚ split_pathsrrYr[ÚcommonrJr²Úprefixr3)r!r#r4r,÷s6  )N)(Ú__doc__r!r"r'r#r$r%r&r(r7ÚsysrRr@Ú__all__r5rrr r r rNr r rrrrrr…r‰r‚rrrr)r›Úplatformr*r+r,r3r3r3r4Ús’ ù        *21& C  )