o Ƌ|c_?@sdZdZdZdZdZdZdZdZdZddl Z ddl Z ddl Z ddl Z dd l Tgd Z d d Zd dZddZddZddZddZe jje_ddZddZddZddZdd Zd!d"Zd#d$Zdadad%d&Zd'd(Zd)d*Z d+d,d-d.Z!d/d0Z"e j#d1kZ$d6d2d3Z%d4d5Z&dS)7aCommon 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 commonprefixZgetsizeZgetmtimeZgetatimeZgetctimeislinkexistslexistsisdirisfileismount expanduser expandvarsnormpathabspathZsamefileZ sameopenfilesamestatcurdirpardirseppathsepdefpathaltsepextsepdevnullrealpathsupports_unicode_filenamesrelpath commonpathcCst|trdSdS)N/r) isinstancebytespathr,&/opt/conda/lib/python3.10/posixpath.py_get_sep)s r.cCs t|S)z6Normalize case of pathname. Has no effect under Posixosfspath)sr,r,r-r4s rcCst|}t|}||S)zTest whether a path is absolute)r0r1r. startswith)r2rr,r,r-r<s  rc Gst|}t|}|}z0|s|dd|ttj|D]}||r&|}q|r-||r2||7}q|||7}qW|StttfyPt j d|g|Rw)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 ) r0r1r.mapr3endswith TypeErrorAttributeError BytesWarning genericpath_check_arg_types)aprr+br,r,r-r Gs$    r cCs`t|}t|}||d}|d|||d}}|r,||t|kr,||}||fS)zSplit a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part may be empty.Nr0r1r.rfindlenrstrip)r<riheadtailr,r,r-r ds  r cCs6t|}t|trd}d}nd}d}t||d|S)Nr'.rr)r0r1r(r)r9 _splitext)r<rr!r,r,r-r us  r cCst|}|dd|fS)zJSplit a pathname into drive and path. On Posix, drive is always empty.Nrr/)r<r,r,r-r s r cCs,t|}t|}||d}||dS)z)Returns the final component of a pathnamer>N)r0r1r.r@)r<rrCr,r,r-r s  r cCsNt|}t|}||d}|d|}|r%||t|kr%||}|S)z-Returns the directory component of a pathnamer>Nr?)r<rrCrDr,r,r-rs   rc Cs6zt|}Wn tttfyYdSwt|jS)z&Test whether a path is a symbolic linkF)r0lstatOSError ValueErrorr7statS_ISLNKst_mode)r+str,r,r-rs  rc Cs*zt|WdSttfyYdSw)zCTest whether a path exists. Returns True for broken symbolic linksFT)r0rHrIrJr*r,r,r-rs  rc Cszt|}Wn ttfyYdSwt|jrdSt|tr't |d}nt |d}t |}zt|}Wn ttfyCYdSw|j }|j }||krPdS|j }|j }||kr\dSdS)z$Test whether a path is a mount pointF..rT) r0rHrIrJrKrLrMr(r)r r#st_devst_ino)r+s1parents2Zdev1Zdev2Zino1Zino2r,r,r-rs2    rc CsHt|}t|tr d}nd}||s|St|}||d}|dkr(t|}|dkrQdtjvrKddl }z | t j }Wn;t yJ|YSwtjd}n*ddl }|d|}t|tret|d}z||}Wn t yw|YSw|j }|durtjdkr|St|trt|}d }nd }||}|||dp|S) zOExpand ~ and ~user constructions. If user or $HOME is unknown, do nothing.~~r>rZHOMENASCIIvxworksr'r)r0r1r(r)r3r.findrAenvironpwdZgetpwuidgetuidZpw_dirKeyErrorstrZgetpwnamsysplatformfsencoderB) r+ZtilderrCr[ZuserhomenameZpwentZrootr,r,r-rsJ              rc CsTt|}t|tr+d|vr|Stsddl}|d|jatj}d}d}t tdd}nd|vr1|St s>ddl}|d |ja t j}d }d }tj }d} |||}|sU |S| d\}}| d } | |rq| |rq| d d} z|durttj t| } n|| } Wn ty|}Ynw||d} |d|| }t|}|| 7}qK)zZExpand shell variables of form $var and ${var}. Unknown variables are left unchanged.$rNs\$(\w+|\{[^}]*\}){}environb$z\$(\w+|\{[^}]*\}){}Tr>)r0r1r(r) _varprogbrecompilerWsearchgetattr_varprogrZZspanZgroupr3r5rafsdecoder]rA) r+rlrnstartendrZrCmjrbvaluerEr,r,r-rsV       rc Cst|}t|trd}d}d}d}nd}d}d}d}||kr!|S||}|r8||d r8||d s8d }||}g}|D]%}|||fvrJqA||ksZ|sR|rZ|r`|d |kr`||qA|rf|qA|}||}|rv|||}|py|S) z0Normalize path, eliminating double slashes, etc.r'rFrOrrrrj) r0r1r(r)r3r appendpopr ) r+rZemptydotZdotdotZinitial_slashesZcompsZ new_compsZcompr,r,r-rQsJ           rcCs@t|}t|st|trt}nt}t||}t|S)zReturn an absolute path.) r0r1rr(r)getcwdbgetcwdr r)r+Zcwdr,r,r-rxs    rF)strictcCs,t|}t|dd||i\}}t|S)zlReturn the canonical path of the specified filename, eliminating any symbolic links encountered in the path.Nr)r0r1 _joinrealpathr)filenamerr+okr,r,r-r#s r#c Cs\t|tr d}d}d}nd}d}d}t|r|dd}|}|r||\}}}|r.||kr/q||krI|rFt|\}}||krEt|||}n|}qt||} zt| } Wntyc|r_d} Ynwt | j } | so| }q| |vr|| }|dur|q|rt | nt| |dfSd|| <t |t | ||\}} | st||dfS||| <|s |d fS) Nr'rFrOrrrr>FT)r(r)r partitionr r r0rHrIrKrLrMrreadlink) r+restrseenrrrrb_ZnewpathrNZis_linkrr,r,r-rs`         .rdarwinc Cs|stdt|}t|trd}d}d}nd}d}d}|dur$|}nt|}z9d d t||D}d d t||D}tt||g}|gt||||d}|s^|WSt |WSt t t t fyutd ||w) z#Return a relative version of a pathzno path specifiedrFr'rOrrrNcSg|]}|r|qSr,r,.0xr,r,r- zrelpath..cSrr,r,rr,r,r-rrr%)rJr0r1r(r)rr rArr r6r7r8DeprecationWarningr9r:) r+rrrrrZ start_list path_listrCZrel_listr,r,r-r%s2    r%c s$|stdtttj|}t|dtrddnddz`fdd|D}ztfd d |D\}Wn tyBtd d wfd d|D}t|}t |}|}t |D]\}}|||krl|d |}nqZ|rqnd d}| |WSt t fytjdg|Rw)zDGiven a sequence of path names, returns the longest common sub-path.z%commonpath() arg is an empty sequencerr'rFrrcsg|]}|qSr,)r )rr+rr,r-r szcommonpath..c3s |] }|ddkVqdS)Nr>r,)rr<rr,r- szcommonpath..z%Can't mix absolute and relative pathsNcsg|] }fdd|DqS)csg|] }|r|kr|qSr,r,)rcrr,r-rsz)commonpath...r,)rr2rr,r-rsr&)rJtupler4r0r1r(r)setminmax enumerater r6r7r9r:) pathsZ split_pathsrrRrTZcommonrCrprefixr,)rrr-r&s<    r&)N)'__doc__rrr!rrrr r"r0r_rKr9__all__r.rrr r r rGr r rrrrrrprkrrrr#rr`r$r%r&r,r,r,r-sN        *55' ?  )