3 \dh@s$ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZmZmZddlmZddlmZmZmZmZmZmZmZddlmZdZd d d d d dgZdZ dZ!dZ"ddZ#Gddde$Z%Gddde%Z&Gddde%Z'e&Z(e'Z)GdddZ*Gddde*Z+e+Z,ddZ-e.ed rTej/e-Z-Gd!d"d"Z0Gd#d$d$Z1Gd%d&d&e0Z2Gd'd(d(e0Z3Gd)d*d*e0Z4Gd+d,d,e Z5Gd-d d e$Z6ej7j8e6Gd.d d e6Z9Gd/d d e6Z:Gd0d d e6Z;Gd1d d e;e9Zssz_WindowsFlavour.azr7ccs|]}t|VqdS)N)rB)rCr5rrrrDtsAZz\\?\ZCONZPRNZAUXZNULcCsh|] }d|qS)zCOM%dr)rCirrr zsz_WindowsFlavour. cCsh|] }d|qS)zLPT%dr)rCrIrrrrJ{sc Csb|dd}|dd}||krP||krP|j|\}}|dd}|dd}nd}|dd}||kov||kov||kr|j|d}|dkr|j||d}||dkr|dkrt|}|r||d||||ddfS|d||||ddfSd} } |dkr<||jkr<|dd} |dd}|}||krT|} |j|}|| | |fS) Nrr7r%:rO)_split_extended_pathfindlen drive_letterslstrip) r#r4r!firstsecondprefixZthirdindexZindex2r1r2rrrr*s6      "    z_WindowsFlavour.splitrootcCs|jS)N)lower)r#srrrr8sz_WindowsFlavour.casefoldcCsdd|DS)NcSsg|] }|jqSr)rY)rCprrr sz2_WindowsFlavour.casefold_parts..r)r#r0rrrcasefold_partssz_WindowsFlavour.casefold_partscCsXd}|j|rP|dd}|dd}|jdrP||dd7}d|dd}||fS)Nr%zUNC\rMr?) startswith)r#rZZ ext_prefixrWrrrrPs    z$_WindowsFlavour._split_extended_pathcCs6|sdS|djdrdS|djddj|jkS)NFrz\\r7r&rO)r_ partitionupperreserved_names)r#r0rrr is_reserveds z_WindowsFlavour.is_reservedcCsd|j}t|dkrJ|ddkrJ|jddjd}d|t|jdfSdt|jjdSdS)NrLr7rNr@z file:///%s/%szutf-8zfile:)driverRas_posixrTurlquote_from_bytesencode)r#pathrdrestrrrmake_uris z_WindowsFlavour.make_uric Csdtjkrtjd}n`dtjkr,tjd}nJdtjkrnytjd}Wntk r\d}YnX|tjd}ntd|rtjd|kr|j|f\}}}|d tjdkrtd |||d <|s|r|||j|dd}n |j|}|S) NHOMEZ USERPROFILEZHOMEPATHZ HOMEDRIVEr%zCan't determine home directoryZUSERNAMEr7z%Can't determine home directory for %rrOrO)osenvironKeyError RuntimeErrorr6r")r#usernameuserhomer1r2r0rrr gethomedirs,       z_WindowsFlavour.gethomedirN)r:r;r<r!r'has_drvntpathpathmodrlname is_supportedsetrangeordrSZext_namespace_prefixrbr*r8r]rPrcrjrrrrrrr>gs" "& '   r>c@sZeZdZdZdZdZeZej dkZ efddZ ddZ d d Z d d Zd dZddZdS) _PosixFlavourr@r%FrAcCsV|rH|d|krH|j|}t|t|dkr.wrapped) functoolswraps staticmethod)rrr)rr _wrap_strfunc3sz_NormalAccessor._wrap_strfunccstjfdd}t|S)Ncst|t|f|S)N)r)ZpathobjAZpathobjBr)rrrr:sz5_NormalAccessor._wrap_binary_strfunc..wrapped)rrr)rrr)rr_wrap_binary_strfunc9sz$_NormalAccessor._wrap_binary_strfunclchmodcCs tddS)Nz%lchmod() not available on this system)NotImplementedError)r#rmoderrrrNsz_NormalAccessor.lchmodsymlinkFcCs tddS)Nz)os.symlink() not available on this system)r)r#srcdsttarget_is_directoryrrrr^sz_NormalAccessor.symlinkcCs tj|S)N)rlreadlink)r#rhrrrresz_NormalAccessor.readlinkN)F)r:r;r<rrrlstatlstatopenlistdirscandirchmodhasattrrmkdirunlinkrmdirrenamer)rutimergetcwdrrh expanduserrealpathrrrrr1s0                 rcCsP|d}|dd}|dkr"t}n$d|kr4tdnt|rBt}nt}|||S)Nrr7z**z:Invalid pattern: '**' can only be an entire path component)_RecursiveWildcardSelector ValueErrorr_WildcardSelector_PreciseSelector) pattern_partsr child_partsclsrrr_make_selectorvs  r lru_cachec@s eZdZdZddZddZdS) _SelectorzYA selector matches a specific glob pattern part against the children of a given path.cCs.||_|rt||_d|_nt|_d|_dS)NTF)rr successordironly_TerminatingSelector)r#rrrrr$s  z_Selector.__init__cCs<t|}|j}|j}|jj}||s,tgS|j||||S)zuIterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.)typeis_direxists _accessorriter _select_from)r# parent_pathZpath_clsrrrrrr select_fromsz_Selector.select_fromN)r:r;r<r=r$rrrrrrs rc@seZdZddZdS)rccs |VdS)Nr)r#rrrrrrrrsz!_TerminatingSelector._select_fromN)r:r;r<rrrrrrsrc@seZdZddZddZdS)rcCs||_tj||dS)N)rvrr$)r#rvrrrrr$sz_PreciseSelector.__init__c cs^yD|j|j}|jr|n||rBx |jj||||D] }|Vq4WWntk rXdSXdS)N)_make_child_relpathrvrrrPermissionError)r#rrrrrhr[rrrrs z_PreciseSelector._select_fromN)r:r;r<r$rrrrrrsrc@seZdZddZddZdS)rcCs"tjtj||_tj||dS)N)recompilefnmatch translaterrr$)r#rrrrrr$sz_WildcardSelector.__init__c csy||jj}t||}xb|D]Z}|j s0|jr|j}||} |jj| r|j|} x |j j | |||D] } | VqhWqWWnt k rdSXdS)N) _flavourr8listrrrvrmatchrrrr) r#rrrrcfentriesentryrvZ casefoldedrhr[rrrrs    z_WildcardSelector._select_fromN)r:r;r<r$rrrrrrsrc@s$eZdZddZddZddZdS)rcCstj||dS)N)rr$)r#rrrrrr$sz#_RecursiveWildcardSelector.__init__c csz|VyZt||}xH|D]@}|jr|j r|j|j}x|j|||D] }|VqLWqWWntk rtdSXdS)N)rr is_symlinkrrv_iterate_directoriesr)r#rrrrrrhr[rrrrs   z/_RecursiveWildcardSelector._iterate_directoriesc csyjt}zT|jj}xF|j|||D]4}x.|||||D]}||kr6|V|j|q6Wq"WWd|jXWntk r~dSXdS)N)rxrrraddclearr) r#rrrrZyieldedZsuccessor_selectZstarting_pointr[rrrrsz'_RecursiveWildcardSelector._select_fromN)r:r;r<r$rrrrrrrs rc@s4eZdZdZdZddZdd 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_partscCs&t||_|j|_|j|_|j|_dS)N)rrrrr)r#rhrrrr$s z_PathParents.__init__cCs(|js |jrt|jdSt|jSdS)Nr7)rrrRr)r#rrr__len__s z_PathParents.__len__cCs@|dks|t|krt||jj|j|j|jd| dS)Nrr7)rR IndexErrorr_from_parsed_partsrrr)r#idxrrr __getitem__sz_PathParents.__getitem__cCsdj|jjS)Nz <{}.parents>)formatrr:)r#rrr__repr__ sz_PathParents.__repr__N)rrrr) r:r;r<r= __slots__r$rrrrrrrrs rc@seZdZdZdZZd d Zd d Zed dZed[ddZ ed\ddZ eddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zed&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zeedd4d5Zeedd6d5Zed7d8Zed9d:Z ed;d<Z!ed=d>Z"ed?d@Z#dAdBZ$dCdDZ%dEdFZ&edGdHZ'dIdJZ(dKdLZ)dMdNZ*edOdPZ+edQdRZ,dSdTZ-dUdVZ.dWdXZ/dYS)]ra|Base class for manipulating paths without I/O. PurePath 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_cpartscGs$|tkrtjdkrtnt}|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. rA)rrlrvrr _from_parts)rrrrr__new__szPurePath.__new__cCs|jt|jfS)N) __class__tupler)r#rrr __reduce__&szPurePath.__reduce__cCshg}xV|D]N}t|tr$||j7}q tj|}t|trH|jt|q tdt|q W|j j |S)NzNargument should be a str object or an os.PathLike object returning str, not %r) isinstancerrrlfspathrr, TypeErrorrrr6)rrr0rErrr _parse_args+s     zPurePath._parse_argsTcCs<tj|}|j|\}}}||_||_||_|r8|j|S)N)objectrrrrr_init)rrinitr#r1r2r0rrrr?s zPurePath._from_partscCs,tj|}||_||_||_|r(|j|S)N)rrrrrr)rr1r2r0rr#rrrrLs zPurePath._from_parsed_partscCs4|s|r$|||jj|ddS|jj|SdS)Nr7)rr")rr1r2r0rrr_format_parsed_partsVszPurePath._format_parsed_partscCsdS)Nr)r#rrrr]szPurePath._initcCs@|j|\}}}|jj|j|j|j|||\}}}|j|||S)N)rrr9rrrr)r#rr1r2r0rrr _make_childaszPurePath._make_childc Cs<y|jStk r6|j|j|j|jp,d|_|jSXdS)z[Return the string representation of the path, suitable for passing to system calls.r&N)rAttributeErrorrrrr)r#rrr__str__gs  zPurePath.__str__cCst|S)N)r)r#rrr __fspath__qszPurePath.__fspath__cCs|j}t|j|jdS)zNReturn the string representation of the path with forward (/) slashes.r@)rrr)r!)r#frrrretszPurePath.as_posixcCstjt|S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)rlfsencoder)r#rrr __bytes__zszPurePath.__bytes__cCsdj|jj|jS)Nz{}({!r}))rrr:re)r#rrrrszPurePath.__repr__cCs|jstd|jj|S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI) is_absoluterrrj)r#rrras_uriszPurePath.as_uric Cs2y|jStk r,|jj|j|_|jSXdS)N)rrrr]r)r#rrr_cpartss zPurePath._cpartscCs&t|tstS|j|jko$|j|jkS)N)rrNotImplementedrr)r#otherrrr__eq__s zPurePath.__eq__c Cs2y|jStk r,tt|j|_|jSXdS)N)rrhashrr)r#rrr__hash__s zPurePath.__hash__cCs(t|t s|j|jk rtS|j|jkS)N)rrrrr)r#rrrr__lt__szPurePath.__lt__cCs(t|t s|j|jk rtS|j|jkS)N)rrrrr)r#rrrr__le__szPurePath.__le__cCs(t|t s|j|jk rtS|j|jkS)N)rrrrr)r#rrrr__gt__szPurePath.__gt__cCs(t|t s|j|jk rtS|j|jkS)N)rrrrr)r#rrrr__ge__szPurePath.__ge__z.The drive prefix (letter or UNC path), if any.)doczThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)rr)r#anchorrrrrs zPurePath.anchorcCs.|j}t||js|jrdndkr&dS|dS)z!The final path component, if any.r7rr%rO)rrRrr)r#r0rrrrvsz PurePath.namecCsD|j}|jd}d|ko*t|dknr<||dSdSdS)z*The final component's last suffix, if any.r&rr7Nr%)rvrfindrR)r#rvrIrrrsuffixs    zPurePath.suffixcCs:|j}|jdrgS|jd}dd|jdddDS)z1A list of the final component's suffixes, if any.r&cSsg|] }d|qS)r&r)rCrrrrr\sz%PurePath.suffixes..r7N)rvendswithrTr+)r#rvrrrsuffixess   zPurePath.suffixescCsD|j}|jd}d|ko*t|dknr<|d|S|SdS)z0The final path component, minus its last suffix.r&rr7N)rvrrR)r#rvrIrrrstems    z PurePath.stemcCs|jstd|f|jj|f\}}}| sZ|d|jj|jjgksZ|sZ|sZt|dkrftd||j|j|j |j dd|gS)z-Return a new path with the file name changed.z%r has an empty namer7zInvalid name %rNrOrO) rvrrr6r!r'rRrrrr)r#rvr1r2r0rrr with_names  zPurePath.with_namecCs|j}|j|ks |jr,|j|kr,td||r<|jd sD|dkrPtd||j}|shtd|f|j}|s|||}n|dt| |}|j|j |j |j dd|gS)zReturn a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path. zInvalid suffix %rr&z%r has an empty nameNr7rO) rr!r'rr_rvrrRrrrr)r#rrrvZ old_suffixrrr with_suffixs    zPurePath.with_suffixc Gs|s td|j}|j}|j}|r8||g|dd}n|}|j|\}}}|rf||g|dd} n|} t| } |jj} | dkr|p|n| |d| | | kr|j|||} t dj t |t | |j d| dkr|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 argumentr7Nrz{!r} does not start with {!r}r%) rrrrrrRrr]rrrrr) r#rr0r1r2Z abs_partsZto_drvZto_rootZto_partsZ to_abs_partsnrZ formattedrrr relative_tos( (zPurePath.relative_toc Cs.y|jStk r(t|j|_|jSXdS)zZAn object providing sequence-like access to the components in the filesystem path.N)rrrr)r#rrrr0"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#rrrrjoinpath.szPurePath.joinpathcCs |j|fS)N)r)r#keyrrr __truediv__6szPurePath.__truediv__cCs|j|g|jS)N)rr)r#rrrr __rtruediv__9szPurePath.__rtruediv__cCs@|j}|j}|j}t|dkr*|s&|r*|S|j|||ddS)zThe logical parent of the path.r7NrO)rrrrRr)r#r1r2r0rrrparent<s zPurePath.parentcCst|S)z*A sequence of this path's logical parents.)r)r#rrrparentsFszPurePath.parentscCs|js dS|jj pt|jS)zSTrue if the path is absolute (has both a root and, if applicable, a drive).F)rrrsboolr)r#rrrrKszPurePath.is_absolutecCs|jj|jS)zaReturn True if the path contains one of the special names reserved by the system, if any.)rrcr)r#rrrrcRszPurePath.is_reservedc Cs|jj}||}|jj|f\}}}|s0td|rF|||jkrFdS|r\|||jkr\dS|j}|sj|rt|t|kr~dS|dd}nt|t|krdSx.tt |t |D]\}}t j ||sdSqWdS)zE Return True if this path matches the given pattern. z empty patternFr7NT) rr8r6rrrrrRzipr(rZ fnmatchcase) r#Z path_patternrr1r2Z pat_partsr0r4rrrrrWs( zPurePath.matchN)rrrrrrr)T)T)0r:r;r<r=rrr classmethodrrrrrrrrrerrrpropertyrrrrrrrrrdr2rrvrrrrrrr0rr r r r rrcrrrrrrs^            c@seZdZdZeZfZdS)rzPurePath subclass for non-Windows systems. On a POSIX system, instantiating a PurePath should return this object. However, you can also instantiate it directly on any system. N)r:r;r<r=_posix_flavourrrrrrrrusc@seZdZdZeZfZdS)rzPurePath subclass for Windows systems. On a Windows system, instantiating a PurePath should return this object. However, you can also instantiate it directly on any system. N)r:r;r<r=_windows_flavourrrrrrrrsc@seZdZdZdaZddZdbddZd d Zd d Zd dZ ddZ dcddZ ddddZ e ddZe ddZddZddZdd Zd!d"Zd#d$Zded&d'Zd(d)Zd*d+Zd,d-Zdgd0d1Zd2d3Zdhd4d5Zd6d7Zdid8d9Zdjd;d<Zdkd=d>Zd?d@Z dAdBZ!dCdDZ"dEdFZ#dGdHZ$dIdJZ%dKdLZ&dldMdNZ'dOdPZ(dQdRZ)dSdTZ*dUdVZ+dWdXZ,dYdZZ-d[d\Z.d]d^Z/d_d`Z0dS)mraPurePath subclass that can make system calls. Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa. r_closedcOsL|tkrtjdkrtnt}|j|dd}|jjs@td|j f|j |S)NrAF)rz$cannot instantiate %r on your system) rrlrvrrrrrwrr:r)rrkwargsr#rrrrs z Path.__new__NcCs"d|_|dk r|j|_nt|_dS)NF)rr_normal_accessor)r#templaterrrrs z Path._initcCs|j|g}|j|j|j|S)N)rrrr)r#r4r0rrrrs zPath._make_child_relpathcCs|jr|j|S)N)r _raise_closed)r#rrr __enter__szPath.__enter__cCs d|_dS)NT)r)r#tvtbrrr__exit__sz Path.__exit__cCs tddS)NzI/O operation on closed path)r)r#rrrrszPath._raise_closedcCs|jj|||S)N)rr)r#rvflagsrrrr_openersz Path._openercCs|jr|j|jj|||S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. )rrrr)r#rrrrr _raw_openszPath._raw_opencCs |tjS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )rlr)rrrrcwdszPath.cwdcCs||jjdS)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)rrr)rrrrhomesz Path.homec CsB|j}y |j}Wntk r2tj|}YnXtjj||S)zoReturn whether other_path is the same or not as this file (as returned by os.path.samefile()). )rrrlrhsamestat)r#Z other_pathstZother_strrrsamefiles  z Path.samefileccsL|jr|jx8|jj|D](}|dkr*q|j|V|jr|jqWdS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. r&..N>r&r')rrrrr)r#rvrrriterdirs z Path.iterdirccsl|stdj||jj|}|jj|f\}}}|s:|rBtdtt|}x|j|D] }|VqZWdS)zIterate over this subtree and yield all existing files (of any kind, including directories) matching the given pattern. zUnacceptable pattern: {!r}z%Non-relative patterns are unsupportedN) rrrr8r6rrrr)r#patternr1r2rselectorr[rrrglobs  z Path.globccs^|jj|}|jj|f\}}}|s(|r0tdtdt|}x|j|D] }|VqLWdS)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,)rr8r6rrrr)r#r)r1r2rr*r[rrrrglobs z Path.rglobcCsD|jr|j|jr|S|jtjg|jdd}|j|d|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. F)r)r)rrrrrlrrr)r#objrrrabsolutes z Path.absoluteFcCs|jr|jdd}y|jj||d}Wn,tk rV}z||WYdd}~XnX|j|f}|sy |jWn*tk r}z||WYdd}~XnX|S)z Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). cSs0t|dd}|jtks|tkr,td|jdS)NwinerrorrzSymlink loop from %r)getattrerrnor_WINERROR_CANT_RESOLVE_FILENAMErofilename)er0rrr check_eloop*s z!Path.resolve..check_eloop)strictN)rrrrOSErrorrr)r#r7r6rZr5r[rrrresolve!s  z Path.resolvecCs |jj|S)zh Return the result of the stat() system call on this path, like os.stat() does. )rr)r#rrrr?sz Path.statcCsddl}|j|jjjS)z: Return the login name of the file owner. rN)r}r~rst_uidZpw_name)r#r}rrrownerFsz Path.ownercCsddl}|j|jjjS)z8 Return the group name of the file gid. rN)grpZgetgrgidrst_gidZgr_name)r#r<rrrgroupMsz Path.grouprr7c Cs,|jr|jtjt|||||||jdS)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )opener)rriorrr)r#r bufferingencodingerrorsnewlinerrrrTsz Path.openc Cs |jdd }|jSQRXdS)zK Open the file in bytes mode, read it, and close the file. rb)rN)rread)r#rrrr read_bytes_szPath.read_bytesc Cs$|jd||d }|jSQRXdS)zJ Open the file in text mode, read it, and close the file. r?)rrCrDN)rrG)r#rCrDrrrr read_textfszPath.read_textc Cs*t|}|jdd }|j|SQRXdS)zO Open the file in bytes mode, write to it, and close the file. wb)rN) memoryviewrwrite)r#dataZviewrrrr write_bytesmszPath.write_bytesc Cs@t|tstd|jj|jd||d }|j|SQRXdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %sw)rrCrDN)rrrrr:rrL)r#rMrCrDrrrr write_textvs   zPath.write_textTc Csr|jr|j|r>y|jj|dWntk r8YnXdStjtjB}|sX|tjO}|j ||}tj |dS)zS Create this file with the given access mode, if it doesn't exist. N) rrrrr8rlO_CREATO_WRONLYO_EXCLr!close)r#rexist_okrfdrrrtouchs   z Path.touchc Cs|jr|jy|jj||Wnjtk rf| s@|j|krB|jjddd|j|d|dYn&tk r| s|j rYnXdS)z< Create a new directory at this given path. T)r rUFN)rrrrFileNotFoundErrorr r8r)r#rr rUrrrrsz Path.mkdircCs |jr|j|jj||dS)zF Change the permissions of the path, like os.chmod(). N)rrrr)r#rrrrrsz Path.chmodcCs |jr|j|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#rrrrrsz Path.lchmodcCs|jr|j|jj|dS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)rrrr)r#rrrrsz Path.unlinkcCs|jr|j|jj|dS)zF Remove this directory. The directory must be empty. N)rrrr)r#rrrrsz Path.rmdircCs|jr|j|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#rrrrsz Path.lstatcCs |jr|j|jj||dS)z5 Rename this path to the given path. N)rrrr)r#targetrrrrsz Path.renamecCs |jr|j|jj||dS)zo Rename this path to the given path, clobbering the existing destination if it exists. N)rrrr))r#rYrrrr)sz Path.replacecCs"|jr|j|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#rYrrrr symlink_toszPath.symlink_tocCsBy |jWn0tk r<}z|jttfkr.dSd}~XnXdS)z+ Whether this path exists. FNT)rr8r2rr)r#r5rrrrs z Path.existscCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)z3 Whether this path is a directory. FN)r rst_moder8r2rr)r#r5rrrrs z Path.is_dircCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). FN)r rr[r8r2rr)r#r5rrris_file s z Path.is_filecCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)z7 Whether this path is a symbolic link. FN)r rr[r8r2rr)r#r5rrrrs zPath.is_symlinkcCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)z6 Whether this path is a block device. FN)r rr[r8r2rr)r#r5rrris_block_device$s zPath.is_block_devicecCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)z: Whether this path is a character device. FN)rrr[r8r2rr)r#r5rrris_char_device1s zPath.is_char_devicecCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)z. Whether this path is a FIFO. FN)rrr[r8r2rr)r#r5rrris_fifo>s z Path.is_fifocCsDyt|jjStk r>}z|jttfkr0dSd}~XnXdS)z0 Whether this path is a socket. FN)r rr[r8r2rr)r#r5rrr is_socketKs zPath.is_socketcCsb|jp |j r^|jr^|jddddkr^|jj|jddd}|j|g|jddS|S)zl Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) rNr7~)rrrrrrr)r#ZhomedirrrrrXs zPath.expanduser)rr)N)r)r )FrO)r?rONNN)NN)NN)rT)r FF)F)1r:r;r<r=rrrrrrrrr!rr"r#r&r(r+r-r/r9rr;r>rrHrIrNrPrWrrrrrrrr)rZrrr\rr]r^r_r`rrrrrrs^                      c@seZdZdZfZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. N)r:r;r<r=rrrrrrdsc@s$eZdZdZfZddZddZdS)rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. cCs tddS)Nz*Path.owner() is unsupported on this system)r)r#rrrr;rszWindowsPath.ownercCs tddS)Nz*Path.group() is unsupported on this system)r)r#rrrr>uszWindowsPath.groupN)r:r;r<r=rr;r>rrrrrks)>rrrArtrlrrr- collectionsr contextlibrr2rrrroperatorrrr r r r r rrZ urllib.parserrfZsupports_symlinks__all__Z_WINERROR_NOT_READYZ_WINERROR_INVALID_NAMEr3rrr r>r{rrrrrrrrrrrrrrrPathLikeregisterrrrrrrrrrsd   $  ? 6>  %f   [