grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B €3Ï_rÁþ!ã&@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 d0d1„Zd2d „Zd3d „Zd4d „Zd5d„Zd6d„Ze jje_d7d „Zd8d„Zd9d„Zd:d„Zd;d„Zdd„Zd?d„Zd@d „Z dAd,„Z!dBdC„Z"e j#dDkZ$dGdEd.„Z%dFd/„Z&dS)Haç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. Mac, Windows), os.path provides the same operations in a manner specific to that platform, and is an alias to another module (e.g. macpath, ntpath). Some of this can actually be useful on non-Posix systems too, e.g. for manipulation of the pathname component of URLs. Ú.z..ú/ú: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©r0ú./opt/alt/python37/lib64/python3.7/posixpath.pyÚ_get_sep)s r2cCs.t |¡}t|ttfƒs*td |jj¡ƒ‚|S)z6Normalize case of pathname. Has no effect under Posixz2normcase() argument must be str or bytes, not '{}') ÚosÚfspathr-r.ÚstrÚ TypeErrorÚformatÚ __class__Ú__name__)Úsr0r0r1r4s   cCst |¡}t|ƒ}| |¡S)zTest whether a path is absolute)r3r4r2Ú startswith)r:r"r0r0r1r@s c Gs¬t |¡}t|ƒ}|}yb|s,|dd…|xHttj|ƒD]8}| |¡rN|}q:|r\| |¡rf||7}q:|||7}q:WWn.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) r3r4r2Úmapr;Úendswithr6ÚAttributeErrorÚ BytesWarningÚ genericpathÚ_check_arg_types)ÚaÚpr"r/Úbr0r0r1rKs    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)r3r4r2ÚrfindÚlenÚrstrip)rCr"ÚiÚheadÚtailr0r0r1r hs  cCs6t |¡}t|tƒrd}d}nd}d}t ||d|¡S)Nr,ó.rr)r3r4r-r.r@Ú _splitext)rCr"r&r0r0r1r ys  cCst |¡}|dd…|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nr)r3r4)rCr0r0r1r ‡s cCs,t |¡}t|ƒ}| |¡d}||d…S)z)Returns the final component of a pathnamerEN)r3r4r2rF)rCr"rIr0r0r1r �s cCsNt |¡}t|ƒ}| |¡d}|d|…}|rJ||t|ƒkrJ| |¡}|S)z-Returns the directory component of a pathnamerEN)r3r4r2rFrGrH)rCr"rIrJr0r0r1r šs   c Cs4yt |¡}Wnttfk r&dSXt |j¡S)z&Test whether a path is a symbolic linkF)r3ÚlstatÚOSErrorr>ÚstatÚS_ISLNKÚst_mode)r/Ústr0r0r1r¨s cCs(yt |¡Wntk r"dSXdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)r3rNrO)r/r0r0r1r²s cCs´yt |¡}Wntk r"dSXt |j¡r4dSt|tƒrJt|dƒ}n t|dƒ}t |ƒ}yt |¡}Wntk r~dSX|j }|j }||kr˜dS|j }|j }||kr°dSdS)z$Test whether a path is a mount pointFs..z..T) r3rNrOrPrQrRr-r.rr(Úst_devÚst_ino)r/Ús1ÚparentÚs2Údev1Údev2Úino1Úino2r0r0r1r¾s.    c Cs4t |¡}t|tƒrd}nd}| |¡s,|St|ƒ}| |d¡}|dkrPt|ƒ}|dkr¢dtjkr–ddl }y|  t  ¡¡j }Wq t k r’|SXqôtjd}nRddl }|d|…}t|tƒrÊt|dƒ}y| |¡}Wnt k rì|SX|j }t|tƒ�rt |¡}d}nd }| |¡}|||d…�p2|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.ó~ú~rErÚHOMENÚASCIIr,r)r3r4r-r.r;r2ÚfindrGÚenvironÚpwdÚgetpwuidÚgetuidÚpw_dirÚKeyErrorr5ÚgetpwnamÚfsencoderH) r/Útilder"rIrcÚuserhomeÚnameÚpwentÚrootr0r0r1rèsB            c Cs\t |¡}t|tƒrVd|kr |Sts:ddl}| d|j¡atj}d}d}t tddƒ}n:d|krb|St s|ddl}| d |j¡a t j}d }d }tj }d}xÂ|||ƒ}|s¦P|  d¡\}}|  d ¡} |  |¡rÞ|  |¡rÞ| d d …} y.|dk�rt tj t | ¡¡} n|| } Wntk �r&|}Yq–X||d…} |d|…| }t|ƒ}|| 7}q–W|S)zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.ó$rNs\$(\w+|\{[^}]*\})ó{ó}Úenvironbú$z\$(\w+|\{[^}]*\})Ú{Ú}rEéÿÿÿÿ)r3r4r-r.Ú _varprogbÚreÚcompiler`ÚsearchÚgetattrÚ_varprogrbÚspanÚgroupr;r=riÚfsdecodergrG) r/rxrzÚstartÚendrbrIÚmÚjrlÚvaluerKr0r0r1rsP          c Csøt |¡}t|tƒr&d}d}d}d}nd}d}d}d}||krB|S| |¡}|rp| |d ¡rp| |d ¡spd }| |¡}g}xR|D]J}|||fkr–q„||ks¶|s¦|r¶|rÂ|d |krÂ| |¡q„|r„| ¡q„W|}| |¡}|rð|||}|pö|S) z0Normalize path, eliminating double slashes, etc.r,órLs..rÚrz..éérv) r3r4r-r.r;r ÚappendÚpopr) r/r"ÚemptyÚdotÚdotdotÚinitial_slashesÚcompsÚ new_compsÚcompr0r0r1rRs>          cCs@t |¡}t|ƒs8t|tƒr&t ¡}nt ¡}t||ƒ}t|ƒS)zReturn an absolute path.) r3r4rr-r.ÚgetcwdbÚgetcwdrr)r/Úcwdr0r0r1rxs    cCs*t |¡}t|dd…|iƒ\}}t|ƒS)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r3r4Ú _joinrealpathr)Úfilenamer/Úokr0r0r1r(‡s c Cst|tƒrd}d}d}n d}d}d}t|ƒr<|dd…}|}xÖ|�r| |¡\}}}|r>||krbq>||kr–|r�t|ƒ\}}||kr”t|||ƒ}q>|}q>t||ƒ}t|ƒs®|}q>||krÖ||}|dk rÈq>t||ƒdfSd||<t|t  |¡|ƒ\}} | �st||ƒdfS|||<q>W|d fS) Nr,rLs..rrz..rEFT) r-r.rÚ partitionr rrr•r3Úreadlink) r/ÚrestÚseenr"r r!rlÚ_Únewpathr—r0r0r1r•�sH      r•Údarwinc Csò|s tdƒ‚t |¡}t|tƒr.d}d}d}n d}d}d}|dkrH|}n t |¡}ynd d „t|ƒ |¡Dƒ}d d „t|ƒ |¡Dƒ}tt||gƒƒ}|gt|ƒ|||d…}|sº|St |ŽSt t t t fk rìt d ||¡‚YnXdS) z#Return a relative version of a pathzno path specifiedrLr,s..rrz..NcSsg|] }|r|‘qSr0r0)Ú.0Úxr0r0r1ú Ûszrelpath..cSsg|] }|r|‘qSr0r0)rŸr r0r0r1r¡Üsr*)Ú ValueErrorr3r4r-r.rr rGrrr6r>r?ÚDeprecationWarningr@rA) r/r€r r"r!Ú start_listÚ path_listrIÚrel_listr0r0r1r*Ås0   c s2|s tdƒ‚tttj|ƒƒ}t|dtƒr4d‰d‰nd‰d‰yƇfdd„|Dƒ}yt‡fd d „|Dƒƒ\}Wntk rŠtd ƒd ‚YnX‡fd d„|Dƒ}t|ƒ}t |ƒ}|}x.t |ƒD]"\}}|||kr¼|d |…}Pq¼W|rêˆn ˆd d…}|ˆ  |¡St 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|]}| ˆ¡‘qSr0)r )rŸr/)r"r0r1r¡ýszcommonpath..c3s|]}|dd…ˆkVqdS)NrEr0)rŸrC)r"r0r1ú szcommonpath..z%Can't mix absolute and relative pathsNcsg|]}‡fdd„|Dƒ‘qS)csg|]}|r|ˆkr|‘qSr0r0)rŸÚc)r r0r1r¡sz)commonpath...r0)rŸr:)r r0r1r¡sr+)r+)r¢Útupler<r3r4r-r.ÚsetÚminÚmaxÚ enumeraterr6r>r@rA) ÚpathsÚ split_pathsrrVrXÚcommonrIr¨Úprefixr0)r r"r1r+îs6  )N)'Ú__doc__r r!r&r"r#r$r%r'r3ÚsysrPr@Ú__all__r2rrrr r rMr r r rrrrr|rwrrrr(r•Úplatformr)r*r+r0r0r0r1Ú sZ           *25& 3  )