grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 ”qc?:ã&@s dZddlZddlZddlZddlZddlTdddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)g&Zd*Zd+Zd*Zd,Z d-Z d.Z dZ d/Z d0d1„Zd2d„Zd3d„Zd4d„Zd5d„Zd6d „Zejje_d7d„Zd8d „Zd9d „Zd:d„Zd;d„Zd<d„Zd=d„Zdadad>d„Zd?d„Zd@d„Z dAd&„Z!dBdC„Z"ej#dDkZ$ddEd(„Z%dFd)„Z&dS)Gaç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. éN)Ú*Ú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Ú.z..ú/ú:z:/bin:/usr/binz /dev/nullcCst|tƒrdSdSdS)Nó/r*)Ú isinstanceÚbytes)Úpath©r0ú./opt/alt/python35/lib64/python3.5/posixpath.pyÚ_get_sep'sr2cCs4t|ttfƒs0tdj|jjƒƒ‚|S)z6Normalize case of pathname. Has no effect under Posixz2normcase() argument must be str or bytes, not '{}')r-r.ÚstrÚ TypeErrorÚformatÚ __class__Ú__name__)Úsr0r0r1r2s cCst|ƒ}|j|ƒS)zTest whether a path is absolute)r2Ú startswith)r8rr0r0r1r=s c GsÀt|ƒ}|}yv|s-|dd…|xW|D]O}|j|ƒrR|}q4| sh|j|ƒru||7}q4|||7}q4WWn1tttfk r»tjd||Œ‚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)r2r9Úendswithr4ÚAttributeErrorÚ BytesWarningÚ genericpathÚ_check_arg_types)ÚaÚprr/Úbr0r0r1rGs    cCsut|ƒ}|j|ƒd}|d|…||d…}}|rk||t|ƒkrk|j|ƒ}||fS)z€Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.éN)r2ÚrfindÚlenÚrstrip)r@rÚiÚheadÚtailr0r0r1rcs  !cCs@t|tƒrd}d}n d}d}tj||d|ƒS)Nr,ó.r*r))r-r.r=Ú _splitext)r@rr#r0r0r1rss  cCs|dd…|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr0)r@r0r0r1r€scCs-t|ƒ}|j|ƒd}||d…S)z)Returns the final component of a pathnamerBN)r2rC)r@rrFr0r0r1r ˆs cCs^t|ƒ}|j|ƒd}|d|…}|rZ||t|ƒkrZ|j|ƒ}|S)z-Returns the directory component of a pathnamerBN)r2rCrDrE)r@rrFrGr0r0r1r ‘s  c CsBytj|ƒ}Wnttfk r1dSYnXtj|jƒS)z&Test whether a path is a symbolic linkF)ÚosÚlstatÚOSErrorr;ÚstatÚS_ISLNKÚst_mode)r/Ústr0r0r1ržs  c Cs.ytj|ƒWntk r)dSYnXdS)zCTest whether a path exists. Returns True for broken symbolic linksFT)rKrLrM)r/r0r0r1r¨s   cCsòytj|ƒ}Wntk r+dSYnXtj|jƒrBdSt|tƒrct|dƒ}nt|dƒ}t |ƒ}ytj|ƒ}Wntk r©dSYnX|j }|j }||krÌdS|j }|j }||krîdSdS)z$Test whether a path is a mount pointFs..z..T) rKrLrMrNrOrPr-r.rr%Úst_devÚst_ino)r/Ús1ÚparentÚs2Údev1Údev2Úino1Úino2r0r0r1r´s.           c Cs|t|tƒrd}nd}|j|ƒs1|St|ƒ}|j|dƒ}|dkrgt|ƒ}|dkr¹dtjkr©ddl}|j tj ƒƒj }q(tjd}noddl}|d|…}t|tƒrót |dƒ}y|j |ƒ}Wntk r|SYnX|j }t|tƒrOtj|ƒ}d}nd }|j|ƒ}|||d…p{|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.ó~ú~rBrÚHOMENÚASCIIr,r*)r-r.r9r2ÚfindrDrKÚenvironÚpwdÚgetpwuidÚgetuidÚpw_dirr3ÚgetpwnamÚKeyErrorÚfsencoderE) r/ÚtilderrFraÚuserhomeÚnameÚpwentÚrootr0r0r1rÞs:           c CsÏt|tƒrpd|kr|StsFddl}|jd|jƒatj}d}d}ttddƒ}nUd|kr€|St s§ddl}|jd |jƒa t j}d }d }tj }d}xý|||ƒ}|säP|j dƒ\}}|j d ƒ} | j |ƒr6| j|ƒr6| d d …} y<|dkrgtjtj tj| ƒƒ} 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+|\{[^}]*\})ú{ú}rBéÿÿÿÿ)r-r.Ú _varprogbÚreÚcompiler^ÚsearchÚgetattrrKÚ_varprogr`ÚspanÚgroupr9r:rgÚfsdecoderfrD) r/rvrxÚstartÚendr`rFÚmÚjrjÚvaluerHr0r0r1r sN        "   c CsRt|tƒr*d}d}d}d}nd}d}d}d}||krR|S|j|ƒ}|r”|j|d ƒr”|j|d ƒ r”d }|j|ƒ}g}xs|D]k}|||fkrËq°||ksû| rå| sû|r |d |kr |j|ƒq°|r°|jƒq°W|}|j|ƒ}|rH|||}|pQ|S) z0Normalize path, eliminating double slashes, etc.r,órIs..r*Úr)z..éérBrt)r-r.r9rÚappendÚpopr) r/rÚemptyÚdotÚdotdotÚinitial_slashesÚcompsÚ new_compsÚcompr0r0r1r?s<  ' cCsOt|ƒsEt|tƒr*tjƒ}n tjƒ}t||ƒ}t|ƒS)zReturn an absolute path.)rr-r.rKÚgetcwdbÚgetcwdrr)r/Úcwdr0r0r1rds   cCs,t|dd…|iƒ\}}t|ƒS)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)Ú _joinrealpathr)Úfilenamer/Úokr0r0r1r%rs"c Cs•t|tƒr$d}d}d}nd}d}d}t|ƒrX|dd…}|}x0|rŠ|j|ƒ\}}}| s[||kr�q[||krÝ|rÔt|ƒ\}}||krÚt|||ƒ}q[|}q[t||ƒ}t|ƒs|}q[||kr9||}|dk r&q[t||ƒdfSd||Âs zrelpath..cSsg|]}|r|‘qSr0r0)r�ržr0r0r1rŸÃs r')Ú ValueErrorr-r.rrrDr rr4r;r<ÚDeprecationWarningr=r>) r/r~rrrÚ start_listÚ path_listrFÚrel_listr0r0r1r'¯s,   ""%c s{|stdƒ‚t|dtƒr4d‰d‰n d‰d‰y ‡fdd†|Dƒ}y&t‡fd d †|Dƒƒ\}Wn!tk r¥td ƒd ‚YnX‡fd d†|Dƒ}t|ƒ}t|ƒ}|}x;t|ƒD]-\}}|||krê|d |…}PqêW|r'ˆn ˆd d…}|ˆj|ƒSWn+tt fk rvt j d|Œ‚YnXd S)zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr,rIr*r)csg|]}|jˆƒ‘qSr0)r)r�r/)rr0r1rŸãs zcommonpath..c3s%|]}|dd…ˆkVqdS)NrBr0)r�r@)rr0r1ú æszcommonpath..z%Can't mix absolute and relative pathsNcs)g|]}‡fdd†|Dƒ‘qS)cs(g|]}|r|ˆkr|‘qSr0r0)r�Úc)rr0r1rŸês z)commonpath...r0)r�r8)rr0r1rŸês r() r r-r.ÚsetÚminÚmaxÚ enumeraterr4r;r=r>) ÚpathsÚ split_pathsrrTrVÚcommonrFr¦Úprefixr0)rrr1r(Õs4  &   )'Ú__doc__rKÚsysrNr=Ú__all__rrr#rr r!r"r$r2rrrrrrJrr r rrrrrzrurrrr%r“Úplatformr&r'r(r0r0r0r1Ú sZ             * * 4 %   3&