[@sSddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejd krUddlZej dd d dfkrFdd lm!Z!n d ZdZ!ndZddddddgZ"ddZ#Gddde$Z%Gddde%Z&Gddde%Z'e&Z(e'Z)GdddZ*Gddde*Z+e+Z,e d d!Z-d"d#Z.e/ed$rGej0e.Z.nGd%d&d&Z1Gd'd(d(Z2Gd)d*d*e1Z3Gd+d,d,e1Z4Gd-d.d.e1Z5Gd/d0d0e Z6Gd1dde$Z7Gd2dde7Z8Gd3dde7Z9Gd4dde7Z:Gd5dde:e8Z;Gd6dde:e9Z<dS)7N)Sequence)contextmanager)EINVALENOENTENOTDIR) attrgetter)S_ISDIRS_ISLNKS_ISREGS_ISSOCKS_ISBLKS_ISCHRS_ISFIFO)quote_from_bytesTnt)_getfinalpathnameFPurePath PurePosixPathPureWindowsPathPath PosixPath WindowsPathcCs"d|kp!d|kp!d|kS)N*?[)patrr/usr/lib/python3.4/pathlib.py_is_wildcard_pattern&sr c@s:eZdZdZddZddZddZdS) _FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dS)N)sepjoin)selfrrr__init__0sz_Flavour.__init__c Csg}|j}|j}d}}t|}x|D]}|sGq5n|rb|j||}n|j|\}}} || krxvt| j|D]1} | r| dkr|jtj| qqWn+| r| dkr|jtj| n|s |r5|sBx.|D]#}|j|d}|rPqqWnPq5q5W|sV|rj|j||n|j |||fS)N.r) r"altsepreversedreplace splitrootsplitappendsysinternreverse) r$partsZparsedr"r(drvrootitpartZrelxrrr parse_parts3s8            z_Flavour.parse_partscCs|r8| r|r||||g|ddfSn_|r||ksh|j||j|kr||||ddfSn||||fS|||fS)z Join the two paths represented by the respective (drive, root, parts) tuples. Return a new (drive, root, parts) tuple. N)casefold)r$r2r3r1Zdrv2Zroot2Zparts2rrrjoin_parsed_partsUs %*z_Flavour.join_parsed_partsN)__name__ __module__ __qualname____doc__r%r7r:rrrrr!,s   "r!c@sKeZdZdZdZdZeZej dkZ e dde e de dd De d de e d e d d DBZd Zddddhdde d dDBdde d dDBZeddZddZddZddZeddZd d!Zd"d#Zd$d%Zd&S)'_WindowsFlavour\/Trccs|]}t|VqdS)N)chr).0r6rrr ssz_WindowsFlavour.azr8ccs|]}t|VqdS)N)rB)rCr6rrrrDtsAZz\\?\ZCONZPRNZAUXZNULcCsh|]}d|qS)zCOM%dr)rCirrr zs z_WindowsFlavour. cCsh|]}d|qS)zLPT%dr)rCrIrrrrJ{s c Cs|dd}|dd}||krp||krp|j|\}}|dd}|dd}nd}|dd}||krf||krf||krf|j|d}|dkrf|j||d}||dkrc|dkr t|}n|r8||d||||ddfS|d||||ddfSqcqfnd} } |dkr||jkr|dd} |dd}|}n||kr|} |j|}n|| | |fS) Nrr8rr&:rN)_split_extended_pathfindlen drive_letterslstrip) r$r5r"firstsecondprefixZthirdindexZindex2r2r3rrrr+s6$  ).   z_WindowsFlavour.splitrootcCs |jS)N)lower)r$srrrr9sz_WindowsFlavour.casefoldcCsdd|DS)NcSsg|]}|jqSr)rX)rCprrr s z2_WindowsFlavour.casefold_parts..r)r$r1rrrcasefold_partssz_WindowsFlavour.casefold_partscCs?t|}|stjStdk r;|jt|SdS)N)strosgetcwdr_ext_to_normal)r$pathrYrrrresolves    z_WindowsFlavour.resolvecCs|d}|j|rr|dd}|dd}|jdrr||dd7}d|dd}qrn||fS)Nr&zUNC\rLr@) startswith)r$rYZ ext_prefixrVrrrrOsz$_WindowsFlavour._split_extended_pathcCs|j|dS)Nr8)rO)r$rYrrrr`sz_WindowsFlavour._ext_to_normalcCsE|s dS|djdr!dS|djddj|jkS)NFrz\\r8r'rN)rd partitionupperreserved_names)r$r1rrr is_reserveds z_WindowsFlavour.is_reservedcCs|j}t|dkrg|ddkrg|jddjd}d|t|jdfSdt|jjdSdS)Nrr8rMrAz file:///%s/%szutf-8zfile:)driverQas_posixrSurlquote_from_bytesencode)r$rarirestrrrmake_uris  "z_WindowsFlavour.make_uriN)r;r<r=r"r(has_drvntpathpathmodr^name is_supportedsetrangeordrRZext_namespace_prefixrgr+r9r\rbrOr`rhrnrrrrr?gs$ /3) '     r?c@seZdZdZdZdZeZej dkZ eddZ ddZ d d Z d d Zd dZddZdS) _PosixFlavourrAr&FrcCss|rb|d|krb|j|}t|t|dkrRd|d|fSd||fSn dd|fSdS)Nrrr&)rSrQ)r$r5r"Z stripped_partrrrr+s z_PosixFlavour.splitrootcCs|S)Nr)r$rYrrrr9sz_PosixFlavour.casefoldcCs|S)Nr)r$r1rrrr\sz_PosixFlavour.casefold_partscsj|j|jifdd|jrEdn tj}|t|piS)Ncs;|jrd}nx|jD] }| s(|dkrGq(n|dkrq|j\}}}q(n||}|kr|}|dk rq(ntd|nyj|}Wn@tk r}z |jtkrn|}WYdd}~Xq(Xd|<||}||._resolver&)r" _accessor is_absoluter^r_r])r$rabaser)rrrr"rrbs   %z_PosixFlavour.resolvecCsdS)NFr)r$r1rrrrh*sz_PosixFlavour.is_reservedcCst|}dt|S)Nzfile://)bytesrk)r$raZbpathrrrrn-s z_PosixFlavour.make_uriN)r;r<r=r"r(ro posixpathrqr^rrrsr+r9r\rbrhrnrrrrrws    , rwc@seZdZdZdS) _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)r;r<r=r>rrrrr8s rc@sEeZdZddZddZeejZeejZeejZeej Z eej Z e edreej Z n ddZ eej Z eejZeejZeejZeejZerereejZq&dd Zned d ZeejZd d Zd S)_NormalAccessorcs+tjfdd}t|S)Ncst||S)N)r])pathobjargs)strfuncrrwrapped@sz._NormalAccessor._wrap_strfunc..wrapped) functoolswraps staticmethod)rrr)rr _wrap_strfunc?s!z_NormalAccessor._wrap_strfunccs+tjfdd}t|S)Ncst|t||S)N)r])ZpathobjAZpathobjBr)rrrrFsz5_NormalAccessor._wrap_binary_strfunc..wrapped)rrr)rrr)rr_wrap_binary_strfuncEs!z$_NormalAccessor._wrap_binary_strfunclchmodcCstddS)Nz%lchmod() not available on this system)NotImplementedError)r$rmoderrrrXsz_NormalAccessor.lchmodcCstddS)Nz&symlink() not available on this system)r)rEbtarget_is_directoryrrrsymlinkisz_NormalAccessor.symlinkcCstjt|t|S)N)r^rr])rErrrrrrmscCs tj|S)N)r^rz)r$rarrrrztsz_NormalAccessor.readlinkN)r;r<r=rrr^statlstatopenlistdirchmodhasattrrmkdirunlinkrmdirrenamer*rsupports_symlinksrrutimerzrrrrr=s,    rc#sdyjVWnMtk r_ifdd}d|_z |VWdjXYnXdS)Nc s=y |SWn*tk r8|}|<|SYnXdS)N)KeyError)rvalue)cachefuncrrwrappers   z_cached..wrapperT) __cached__AttributeErrorclear)rrr)rrr_cacheds    rcCsr|d}|dd}|dkr/t}n6d|krJtdnt|r_t}nt}|||S)Nrr8z**z:Invalid pattern: '**' can only be an entire path component)_RecursiveWildcardSelector ValueErrorr _WildcardSelector_PreciseSelector) pattern_partsr child_partsclsrrr_make_selectors      r lru_cachec@s.eZdZdZddZddZdS) _SelectorzYA selector matches a specific glob pattern part against the children of a given path.cCs1||_|r!t||_n t|_dS)N)rr successor_TerminatingSelector)r$rrrrr%s z_Selector.__init__cCs@t|}|j}|j}|jj}|j||||S)zuIterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.)typeis_direxistsrr _select_from)r$ parent_pathZpath_clsrrrrrr select_froms     z_Selector.select_fromN)r;r<r=r>r%rrrrrrs  rc@seZdZddZdS)rccs |VdS)Nr)r$rrrrrrrrsz!_TerminatingSelector._select_fromN)r;r<r=rrrrrrs rc@s(eZdZddZddZdS)rcCs||_tj||dS)N)rrrr%)r$rrrrrrr%s z_PreciseSelector.__init__ccs`||sdS|j|j}||r\x+|jj||||D] }|VqJWndS)N)_make_child_relpathrrrr)r$rrrrrarZrrrrs   "z_PreciseSelector._select_fromN)r;r<r=r%rrrrrrs  rc@s(eZdZddZddZdS)rcCs/tjtj||_tj||dS)N)recompilefnmatch translaterrr%)r$rrrrrr%sz_WildcardSelector.__init__c cs||sdS|jj}xo||D]a}||}|jj|r)|j|}x+|jj||||D] } | VqxWq)q)WdS)N)_flavourr9rmatchrrr) r$rrrrcfrrZ casefoldedrarZrrrrs   "z_WildcardSelector._select_fromN)r;r<r=r%rrrrrrs  rc@s4eZdZddZddZddZdS)rcCstj||dS)N)rr%)r$rrrrrr%sz#_RecursiveWildcardSelector.__init__ccsc|VxW||D]I}|j|}||rx%|j|||D] }|VqIWqqWdS)N)r_iterate_directories)r$rrrrrrarZrrrrs  z/_RecursiveWildcardSelector._iterate_directoriesc cs||sdSt|}t}zq|jj}x^|j|||D]G}x>|||||D]'}||kri|V|j|qiqiWqMWWd|jXWdQXdS)N)rrtrrraddr) r$rrrrZyieldedZsuccessor_selectZstarting_pointrZrrrrs    z'_RecursiveWildcardSelector._select_fromN)r;r<r=r%rrrrrrrs   rc@sLeZdZdZdZddZdd Zd d Zd d ZdS) _PathParentszvThis object provides sequence-like access to the logical ancestors of a path. Don't try to construct it yourself._pathcls_drv_root_partscCs7t||_|j|_|j|_|j|_dS)N)rrrrr)r$rarrrr%s  z_PathParents.__init__cCs4|js|jr#t|jdSt|jSdS)Nr8)rrrQr)r$rrr__len__ sz_PathParents.__len__cCs[|dks|t|kr-t|n|jj|j|j|jd| dS)Nrr8)rQ IndexErrorr_from_parsed_partsrrr)r$idxrrr __getitem__sz_PathParents.__getitem__cCsdj|jjS)Nz <{}.parents>)formatrr;)r$rrr__repr__sz_PathParents.__repr__N)z_pathclsz_drvz_rootz_parts) r;r<r=r> __slots__r%rrrrrrrrs    rc@s\eZdZdZdXZd d Zd d Zed dZedddZ edddZ eddZ ddZ ddZ ddZddZddZd d!Zd"d#Zed$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zeedd2d3Zeedd2d4Zed5d6Zed7d8Zed9d:Z ed;d<Z!ed=d>Z"d?d@Z#dAdBZ$dCdDZ%edEdFZ&dGdHZ'dIdJZ(dKdLZ)edMdNZ*edOdPZ+dQdRZ,dSdTZ-dUdVZ.dWS)YraHPurePath represents a filesystem path and offers operations which don't imply any actual filesystem I/O. Depending on your system, instantiating a PurePath will return either a PurePosixPath or a PureWindowsPath object. You can also instantiate either of these classes directly, regardless of your system. rrr_str_hash_pparts_cached_cpartscGs7|tkr*tjdkr!tnt}n|j|S)zConstruct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object. r)rr^rrrr _from_parts)rrrrr__new__(s zPurePath.__new__cCs|jt|jfS)N) __class__tupler)r$rrr __reduce__2szPurePath.__reduce__cCsg}xh|D]`}t|tr2||j7}q t|trW|jt|q tdt|q W|jj|S)Nz/argument should be a path or str object, not %r) isinstancerrr]r- TypeErrorrrr7)rrr1rErrr _parse_args7s zPurePath._parse_argsTcCsYtj|}|j|\}}}||_||_||_|rU|jn|S)N)objectrrrrr_init)rrinitr$r2r3r1rrrrHs    zPurePath._from_partscCsAtj|}||_||_||_|r=|jn|S)N)rrrrrr)rr2r3r1rr$rrrrUs    zPurePath._from_parsed_partscCsB|s |r.|||jj|ddS|jj|SdS)Nr8)rr#)rr2r3r1rrr_format_parsed_parts_s "zPurePath._format_parsed_partscCsdS)Nr)r$rrrrfszPurePath._initcCs^|j|\}}}|jj|j|j|j|||\}}}|j|||S)N)rrr:rrrr)r$rr2r3r1rrr _make_childjs *zPurePath._make_childc CsRy |jSWn@tk rM|j|j|j|jp<d|_|jSYnXdS)z[Return the string representation of the path, suitable for passing to system calls.r'N)rrrrrr)r$rrr__str__ps   zPurePath.__str__cCs"|j}t|j|jdS)zNReturn the string representation of the path with forward (/) slashes.rA)rr]r*r")r$frrrrjzs zPurePath.as_posixcCstjt|S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)r^fsencoder])r$rrr __bytes__szPurePath.__bytes__cCsdj|jj|jS)Nz{}({!r}))rrr;rj)r$rrrrszPurePath.__repr__cCs+|jstdn|jj|S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)rrrrn)r$rrras_uris zPurePath.as_uric CsCy |jSWn1tk r>|jj|j|_|jSYnXdS)N)rrrr\r)r$rrr_cpartss   zPurePath._cpartscCs5t|tstS|j|jko4|j|jkS)N)rrNotImplementedrr)r$otherrrr__eq__szPurePath.__eq__c CsCy |jSWn1tk r>tt|j|_|jSYnXdS)N)rrhashrr)r$rrr__hash__s   zPurePath.__hash__cCs6t|t s"|j|jk r&tS|j|jkS)N)rrrrr)r$rrrr__lt__s"zPurePath.__lt__cCs6t|t s"|j|jk r&tS|j|jkS)N)rrrrr)r$rrrr__le__s"zPurePath.__le__cCs6t|t s"|j|jk r&tS|j|jkS)N)rrrrr)r$rrrr__gt__s"zPurePath.__gt__cCs6t|t s"|j|jk r&tS|j|jkS)N)rrrrr)r$rrrr__ge__s"zPurePath.__ge__docz.The drive prefix (letter or UNC path), if any.zThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)rr)r$anchorrrrrszPurePath.anchorcCs?|j}t||js$|jr*dndkr7dS|dS)z!The final path component, if any.r8rr&rN)rrQrr)r$r1rrrrrs *z PurePath.namecCsT|j}|jd}d|ko9t|dknrL||dSdSdS)z*The final component's last suffix, if any.r'rr8Nr&)rrrfindrQ)r$rrrIrrrsuffixs  &zPurePath.suffixcCsO|j}|jdrgS|jd}dd|jdddDS)z1A list of the final component's suffixes, if any.r'cSsg|]}d|qS)r'r)rCrrrrr[s z%PurePath.suffixes..r8N)rrendswithrSr,)r$rrrrrsuffixess  zPurePath.suffixescCsT|j}|jd}d|ko9t|dknrL|d|S|SdS)z0The final path component, minus its last suffix.r'rr8N)rrrrQ)r$rrrIrrrstems  &z PurePath.stemcCs|jstd|fn|jj|f\}}}| s|d|jj|jjgks|s|st|dkrtd|n|j|j|j |j dd|gS)z-Return a new path with the file name changed.z%r has an empty namer8zInvalid name %rNrNrN) rrrrr7r"r(rQrrrr)r$rrr2r3r1rrr with_names )zPurePath.with_namecCs|j}|j|ks0|jrC|j|krCtd|n|rY|jd se|dkrxtd|n|j}|std|fn|j}|s||}n|dt| |}|j|j |j |j dd|gS)zCReturn a new path with the file suffix changed (or added, if none).zInvalid suffix %rr'z%r has an empty nameNr8rN) rr"r(rrdrrrrQrrrr)r$rrrrZ old_suffixrrr with_suffixs '"   zPurePath.with_suffixc GsW|stdn|j}|j}|j}|rS||g|dd}n|}|j|\}}}|r||g|dd} n|} t| } |jj} | dkr|p|n| |d| | | kr(|j|||} t dj t |t | n|j d| dkrC|nd|| dS)zReturn the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError. zneed at least one argumentr8Nrz{!r} does not start with {!r}r&) rrrrrrQrr\rrrr]r) r$rr1r2r3Z abs_partsZto_drvZto_rootZto_partsZ to_abs_partsnrZ formattedrrr relative_tos(      : zPurePath.relative_toc Cs=y |jSWn+tk r8t|j|_|jSYnXdS)zZAn object providing sequence-like access to the components in the filesystem path.N)rrrr)r$rrrr1&s   zPurePath.partscGs |j|S)zCombine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored). )r)r$rrrrjoinpath2szPurePath.joinpathcCs|j|fS)N)r)r$keyrrr __truediv__:szPurePath.__truediv__cCs|j|g|jS)N)rr)r$rrrr __rtruediv__=szPurePath.__rtruediv__cCsZ|j}|j}|j}t|dkr=|s9|r=|S|j|||ddS)zThe logical parent of the path.r8NrN)rrrrQr)r$r2r3r1rrrparent@s    zPurePath.parentcCs t|S)z*A sequence of this path's logical parents.)r)r$rrrparentsJszPurePath.parentscCs'|js dS|jj p&t|jS)zSTrue if the path is absolute (has both a root and, if applicable, a drive).F)rrroboolr)r$rrrrOs zPurePath.is_absolutecCs|jj|jS)zaReturn True if the path contains one of the special names reserved by the system, if any.)rrhr)r$rrrrhVszPurePath.is_reservedc Cs/|jj}||}|jj|f\}}}|sKtdn|rj|||jkrjdS|r|||jkrdS|j}|s|rt|t|krdS|dd}nt|t|krdSx?tt |t |D]"\}}t j ||sdSqWdS)zE Return True if this path matches the given pattern. z empty patternFr8NT) rr9r7rrrrrQzipr)rZ fnmatchcase) r$Z path_patternrr2r3Z pat_partsr1r5rrrrr[s(    (zPurePath.matchN)z_drvz_rootz_partsz_strz_hashz_ppartsz_cached_cparts)/r;r<r=r>rrr classmethodrrrrrrrrjrrrpropertyrrrrrrrrrir3rrrrrrrrrr1rrrrrrrhrrrrrrs\                            c@seZdZeZfZdS)rN)r;r<r=_posix_flavourrrrrrrrus c@seZdZeZfZdS)rN)r;r<r=_windows_flavourrrrrrrrzs c@seZdZdRZddZdddZdd Zd d Zd d ZddZ dddZ dddZ e ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(dSdddd*d+Zdd,d-d.Zdd/d0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zd<d=Zd>d?Zd/d@dAZ dBdCZ!dDdEZ"dFdGZ#dHdIZ$dJdKZ%dLdMZ&dNdOZ'dPdQZ(dS)Trr_closedcOsr|tkr*tjdkr!tnt}n|j|dd}|jjsdtd|j fn|j |S)NrrFz$cannot instantiate %r on your system) rr^rrrrrrrsrr;r)rrkwargsr$rrrrs   z Path.__new__NcCs1d|_|dk r$|j|_n t|_dS)NF)rr_normal_accessor)r$templaterrrrs  z Path._initcCs)|j|g}|j|j|j|S)N)rrrr)r$r5r1rrrrszPath._make_child_relpathcCs|jr|jn|S)N)r _raise_closed)r$rrr __enter__s  zPath.__enter__cCs d|_dS)NT)r)r$tvtbrrr__exit__sz Path.__exit__cCstddS)NzI/O operation on closed path)r)r$rrrrszPath._raise_closedicCs|jj|||S)N)rr)r$rrflagsrrrr_openersz Path._openericCs,|jr|jn|jj|||S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. )rrrr)r$rrrrr _raw_opens  zPath._raw_opencCs|tjS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )r^r_)rrrrcwdszPath.cwdccsm|jr|jnxP|jj|D]<}|dkrAq)n|j|V|jr)|jq)q)WdS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. r'..N>rr')rrrrr)r$rrrrriterdirs    z Path.iterdirccs|jj|}|jj|f\}}}|s<|rKtdntt|}x|j|D] }|VqmWdS)zIterate over this subtree and yield all existing files (of any kind, including directories) matching the given pattern. z%Non-relative patterns are unsupportedN)rr9r7rrrr)r$patternr2r3rselectorrZrrrglobs z Path.globccs|jj|}|jj|f\}}}|s<|rKtdntdt|}x|j|D] }|VqqWdS)zRecursively yield all existing files (of any kind, including directories) matching the given pattern, anywhere in this subtree. z%Non-relative patterns are unsupported**N)r")rr9r7rrrr)r$rr2r3rr rZrrrrglobs z Path.rglobcCs_|jr|jn|jr&|S|jtjg|jdd}|jd||S)aReturn an absolute version of this path. This function works even if the path doesn't point to anything. No normalization is done, i.e. all '.' and '..' will be kept along. Use resolve() to get the canonical path to a file. rFr)rrrrr^r_rr)r$objrrrabsolutes   %z Path.absolutecCs|jr|jn|jj|}|dkrS|jt|j}n|jjj|}|j |fdd}|j d||S)z Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). NrFr) rrrrbrr]r%rqnormpathrr)r$rYZnormedr$rrrrbs    z Path.resolvecCs|jj|S)zh Return the result of the stat() system call on this path, like os.stat() does. )rr)r$rrrrsz Path.statcCs%ddl}|j|jjjS)z: Return the login name of the file owner. rN)pwdgetpwuidrst_uidZpw_name)r$r'rrrowners z Path.ownercCs%ddl}|j|jjjS)z8 Return the group name of the file gid. rN)grpZgetgrgidrst_gidZgr_name)r$r+rrrgroups z Path.grouprr8c CsA|jr|jntjt||||||d|jS)z| Open the file pointed by this path and return a file object, as the built-in open() function does. Zopener)rriorr]r)r$r bufferingencodingerrorsnewlinerrrr$s  !z Path.openTc Cs|jr|jn|rOy|jj|dWntk rGYqOXdSntjtjB}|su|tjO}n|j ||}tj |dS)zS Create this file with the given access mode, if it doesn't exist. N) rrrrr{r^O_CREATO_WRONLYO_EXCLrclose)r$rexist_okrfdrrrtouch/s   z Path.touchFcCs|jr|jn|s2|jj||nzy|jj||Wn`tk r}z@|jtkrsn|jjdd|jj||WYdd}~XnXdS)NrT)rrrrr{r|rr)r$rrrrrrrFs  z Path.mkdircCs-|jr|jn|jj||dS)zF Change the permissions of the path, like os.chmod(). N)rrrr)r$rrrrrTs  z Path.chmodcCs-|jr|jn|jj||dS)z Like chmod(), except if the path points to a symlink, the symlink's permissions are changed, rather than its target's. N)rrrr)r$rrrrr\s  z Path.lchmodcCs*|jr|jn|jj|dS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)rrrr)r$rrrres  z Path.unlinkcCs*|jr|jn|jj|dS)zF Remove this directory. The directory must be empty. N)rrrr)r$rrrrns  z Path.rmdircCs&|jr|jn|jj|S)z Like stat(), except if the path points to a symlink, the symlink's status information is returned, rather than its target's. )rrrr)r$rrrrvs  z Path.lstatcCs-|jr|jn|jj||dS)z5 Rename this path to the given path. N)rrrr)r$rrrrrs  z Path.renamecCs-|jr|jn|jj||dS)zo Rename this path to the given path, clobbering the existing destination if it exists. N)rrrr*)r$rrrrr*s  z Path.replacecCs0|jr|jn|jj|||dS)z Make this path a symlink pointing to the given path. Note the order of arguments (self, target) is the reverse of os.symlink's. N)rrrr)r$rrrrr symlink_tos  zPath.symlink_tocCsYy|jWnDtk rT}z$|jttfkr>ndSWYdd}~XnXdS)z+ Whether this path exists. FNT)rr{r|rr)r$rrrrrsz Path.existscCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)z3 Whether this path is a directory. FN)rrst_moder{r|rr)r$rrrrrs z Path.is_dircCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). FN)r rr<r{r|rr)r$rrrris_files z Path.is_filecCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)z7 Whether this path is a symbolic link. FN)r rr<r{r|rr)r$rrrr is_symlinks zPath.is_symlinkcCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)z6 Whether this path is a block device. FN)r rr<r{r|rr)r$rrrris_block_devices zPath.is_block_devicecCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)z: Whether this path is a character device. FN)r rr<r{r|rr)r$rrrris_char_devices zPath.is_char_devicecCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)z. Whether this path is a FIFO. FN)rrr<r{r|rr)r$rrrris_fifos z Path.is_fifocCsbyt|jjSWnDtk r]}z$|jttfkrGndSWYdd}~XnXdS)z0 Whether this path is a socket. FN)r rr<r{r|rr)r$rrrr is_sockets zPath.is_socket)z _accessorz_closedrN))r;r<r=rrrrrrrrrr rrr!r#r%rbrr*r-rr:rrrrrrrr*r;rrr=r>r?r@rArBrrrrrsN                     c@seZdZfZdS)rN)r;r<r=rrrrrrs c@seZdZfZdS)rN)r;r<r=rrrrrrs )=rrr/rpr^rrr. collectionsr contextlibrr|rrroperatorrrrr r r r r rZ urllib.parserrkrrrrZgetwindowsversionr__all__r rr!r?rwrr rrrrrrrrrrrrrrrrrrrrrrrsd        4 "   ;zS  ;  !Z