a °x–a =ã@sdZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l Tgd ¢Z d d „Zd d„Zdd„Zdd„Zdd„Zdd„Ze jje_dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zdadad%d&„Zd'd(„Zd)d*„Z d+d,„Z!d-d.„Z"e j#d/kZ$d4d0d1„Z%d2d3„Z&dS)5aÙ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Ú commonpathcCst|tƒrdSdSdS)Nó/r)Ú isinstanceÚbytes©Úpath©r2ú/usr/lib/python3.9/posixpath.pyÚ_get_sep)s r4cCs t |¡S)z6Normalize case of pathname. Has no effect under Posix©ÚosÚfspath)Úsr2r2r3r4srcCst |¡}t|ƒ}| |¡S)zTest whether a path is absolute)r6r7r4Ú startswith)r8r#r2r2r3r<s rc Gs¨t |¡}t|ƒ}|}z^|s,|dd…|ttj|ƒD]8}| |¡rL|}q8|rZ| |¡rd||7}q8|||7}q8Wn.tttfy¢t j d|g|¢RŽ‚Yn0|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 ) r6r7r4Úmapr9ÚendswithÚ TypeErrorÚAttributeErrorÚ BytesWarningÚ genericpathÚ_check_arg_types)ÚaÚpr#r1Úbr2r2r3r Gs    r 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©r6r7r4ÚrfindÚlenÚrstrip)rBr#ÚiÚheadÚtailr2r2r3r ds  r cCs6t |¡}t|tƒrd}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}||d…S)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#rIrJr2r2r3r–s   rc Cs6zt |¡}Wntttfy(YdS0t |j¡S)z&Test whether a path is a symbolic linkF)r6ÚlstatÚOSErrorÚ ValueErrorr=ÚstatÚS_ISLNKÚst_mode)r1Ústr2r2r3r¤s rc Cs,zt |¡Wnttfy&YdS0dS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r6rNrOrPr0r2r2r3r®s rc Cs¼zt |¡}Wnttfy&YdS0t |j¡r8dSt|tƒrNt |dƒ}n t |dƒ}t |ƒ}zt |¡}Wnttfy†YdS0|j }|j }||kr dS|j }|j }||kr¸dSdS)z$Test whether a path is a mount pointFó..rT) r6rNrOrPrQrRrSr.r/r r)Úst_devÚst_ino)r1Ús1ÚparentÚs2Údev1Údev2Úino1Úino2r2r2r3rºs.    rc Cs8t |¡}t|tƒrd}nd}| |¡s,|St|ƒ}| |d¡}|dkrPt|ƒ}|dkr¤dtjvr˜ddl }z|  t  ¡¡j }Wq¢t y”|YS0n tjd}nTddl }|d|…}t|tƒrÌt|dƒ}z| |¡}Wnt yð|YS0|j }t|tƒrt |¡}d}nd }| |¡}|||d…p6|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.ó~ú~rDrÚHOMENÚASCIIr-r)r6r7r.r/r9r4ÚfindrGÚenvironÚpwdÚgetpwuidÚgetuidÚpw_dirÚKeyErrorÚstrÚgetpwnamÚfsencoderH) r1Útilder#rIreÚuserhomeÚnameÚpwentÚrootr2r2r3räsB                rc CsXt |¡}t|tƒrVd|vr |Sts:ddl}| d|j¡atj}d}d}t tddƒ}n:d|vrb|St s|ddl}| d |j¡a t j}d }d }tj }d}|||ƒ}|s¦qT|  d¡\}}|  d ¡} |  |¡rÞ|  |¡rÞ| d d …} z.|durt tj t | ¡¡} n|| } Wnty$|}Yq”0||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/Ú _varprogbÚreÚcompilerbÚsearchÚgetattrÚ_varprogrdÚspanÚgroupr9r;rlÚfsdecoderirG) r1r{r}ÚstartÚendrdrIÚmÚjroÚvaluerKr2r2r3rsN          rc Csôt |¡}t|tƒr&d}d}d}d}nd}d}d}d}||krB|S| |¡}|rp| |d ¡rp| |d ¡spd }| |¡}g}|D]J}|||fvr”q‚||ks´|s¤|r´|rÀ|d |krÀ| |¡q‚|r‚| ¡q‚|}| |¡}|rì|||}|pò|S) z0Normalize path, eliminating double slashes, etc.r-órLrUrÚrrééry) r6r7r.r/r9r ÚappendÚpopr ) r1r#ÚemptyÚdotÚdotdotÚinitial_slashesÚcompsÚ new_compsÚcompr2r2r3rNsJ    ÿ ÿ  ÿ ÿ    rcCs@t |¡}t|ƒs8t|tƒr&t ¡}nt ¡}t||ƒ}t|ƒS)zReturn an absolute path.) r6r7rr.r/ÚgetcwdbÚgetcwdr r)r1Úcwdr2r2r3rts    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)Úfilenamer1Úokr2r2r3r)ƒs r)c Cst|tƒrd}d}d}n d}d}d}t|ƒr<|dd…}|}|r| |¡\}}}|r<||kr`q<||kr”|rŽt|ƒ\}}||kr’t|||ƒ}q<|}q×rˆzrelpath..cSsg|] }|r|‘qSr2r2r¢r2r2r3r¥Ørˆr+)rPr6r7r.r/rr rGrr r<r=r>ÚDeprecationWarningr?r@) r1rƒr!r#r"Ú start_listÚ path_listrIÚrel_listr2r2r3r+Ás0    r+c s2|s tdƒ‚tttj|ƒƒ}t|dtƒr4d‰d‰nd‰d‰zćfdd„|Dƒ}zt‡fd d „|Dƒƒ\}Wntyˆtd ƒd ‚Yn0‡fd d„|Dƒ}t|ƒ}t |ƒ}|}t |ƒD]$\}}|||kr¸|d |…}qÞq¸|ræˆn ˆd d…}|ˆ  |¡WSt t fy,tjdg|¢RŽ‚Yn0d S)zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr-rLrrcsg|]}| ˆ¡‘qSr2)r )r£r1©r#r2r3r¥ùrˆzcommonpath..c3s|]}|dd…ˆkVqdS)NrDr2)r£rBrªr2r3Ú ürˆzcommonpath..z%Can't mix absolute and relative pathsNcsg|]}‡fdd„|Dƒ‘qS)csg|]}|r|ˆkr|‘qSr2r2)r£Úc©r!r2r3r¥rˆz)commonpath...r2)r£r8r­r2r3r¥rˆr,)rPÚtupler:r6r7r.r/ÚsetÚminÚmaxÚ enumerater r<r=r?r@) ÚpathsÚ split_pathsrrXrZÚcommonrIr¬Úprefixr2)r!r#r3r,ês6   r,)N)'Ú__doc__r!r"r'r#r$r%r&r(r6ÚsysrQr?Ú__all__r4rrr r r rMr r rrrrrrrzrrrr)r˜Úplatformr*r+r,r2r2r2r3ÚsL        *25& 3  )