eaiovnaovbqoebvqoeavibavo B  f@sjddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejdkrddlZe dd d krdd lm!Z!qd ZdZ!ndZd dddddgZ"e e eefZ#dZ$ddZ%ddZ&Gddde'Z(Gddde(Z)Gddde(Z*e)Z+e*Z,GdddZ-Gd d!d!e-Z.e.Z/d"d#Z0e1ed$re2e0Z0Gd%d&d&Z3Gd'd(d(Z4Gd)d*d*e3Z5Gd+d,d,e3Z6Gd-d.d.e3Z7Gd/d0d0e Z8Gd1d d e'Z9ej:;e9Gd2dde9ZGd5dde>e<Z?Gd6dde>e=Z@dS)7N)Sequence)EINVALENOENTENOTDIREBADFELOOP) attrgetter)S_ISDIRS_ISLNKS_ISREGS_ISSOCKS_ISBLKS_ISCHRS_ISFIFO)quote_from_bytesTnt)r)_getfinalpathnameFPurePath PurePosixPathPureWindowsPathPath PosixPath WindowsPath)icCs t|ddtkpt|ddtkS)NerrnoZwinerror)getattr_IGNORED_ERROS_IGNORED_WINERRORS)Z exceptionr ,/opt/alt/python37/lib64/python3.7/pathlib.py _ignore_error-sr"cCsd|kpd|kpd|kS)N*?[r )patr r r!_is_wildcard_pattern2sr'c@s(eZdZdZddZddZddZdS) _FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dS)N)sepjoin)selfr r r!__init__<sz_Flavour.__init__c Csg}|j}|j}d}}t|}x|D]}|s0q&|r@|||}||\}}} || krxPt| |D] } | rh| dkrh|t| qhWn| r| dkr|t| |s|r&|sx6|D].}|sq|r|||}||d}|rPqWPq&W|s|r |||| |||fS)N.r) r)altsepreversedreplace splitrootsplitappendsysinternreverse) r+partsZparsedr)r/drvrootitpartZrelxr r r! parse_parts?s@       z_Flavour.parse_partscCsz|r*|sp|rp||||g|ddfSnF|rb||ksJ||||krp||||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+r9r:r8Zdrv2Zroot2Zparts2r r r!join_parsed_partsesz_Flavour.join_parsed_partsN)__name__ __module__ __qualname____doc__r,r>rAr r r r!r(8s&r(c@seZdZdZdZdZeZej dkZ e dZ dZ ddd d hd d ed dDBdd ed dDBZefddZddZddZddZd&ddZe fddZddZdd Zd!d"Zd#d$Zd%S)'_WindowsFlavour\/TrZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\ZCONZPRNZAUXZNULcCsh|] }d|qS)zCOM%dr ).0ir r r! sz_WindowsFlavour.r? cCsh|] }d|qS)zLPT%dr )rIrJr r r!rKsc Cs\|dd}|dd}||krP||krP||\}}|dd}|dd}nd}|dd}||kr||kr||kr||d}|dkr|||d}||dkr|dkrt|}|r||d||||ddfS|d||||ddfSd} } |dkr6||jkr6|dd} |dd}|}||krN|} ||}|| | |fS)Nrr?rr-:)_split_extended_pathfindlen drive_letterslstrip) r+r<r)firstsecondprefixZthirdindexZindex2r9r:r r r!r2s6      "    z_WindowsFlavour.splitrootcCs|S)N)lower)r+sr r r!r@sz_WindowsFlavour.casefoldcCsdd|DS)NcSsg|] }|qSr )rY)rIpr r r! sz2_WindowsFlavour.casefold_parts..r )r+r8r r r!casefold_partssz_WindowsFlavour.casefold_partscCstt|tjjS)N)recompilefnmatch translate IGNORECASE fullmatch)r+patternr r r!compile_patternsz_WindowsFlavour.compile_patternFcCst|}|stSd}tdk r|r2|t|Sg}xly|t|}Wn>tk r|}tj|\}}||||kr|SYq8Xtjj |ft |Sq8WdS)N) strosgetcwdr_ext_to_normalFileNotFoundErrorpathr3r4r*r0)r+rkstrictrZZ previous_sZ tail_partstailr r r!resolves&  z_WindowsFlavour.resolvecCsXd}||rP|dd}|dd}|drP||dd7}d|dd}||fS)Nr-zUNC\rMrG) startswith)r+rZZ ext_prefixrWr r r!rPs    z$_WindowsFlavour._split_extended_pathcCs||dS)Nr?)rP)r+rZr r r!risz_WindowsFlavour._ext_to_normalcCs6|sdS|ddrdS|ddd|jkS)NFrz\\rNr.)rp partitionupperreserved_names)r+r8r r r! is_reserveds z_WindowsFlavour.is_reservedcCsd|j}t|dkrJ|ddkrJ|ddd}d|t|dfSdt|dSdS)Nrr?rOrHz file:///%s/%szutf-8zfile:)driverRas_posixrTurlquote_from_bytesencode)r+rkrurestr r r!make_uris z_WindowsFlavour.make_uricCsdtjkrtjd}n`dtjkr,tjd}nJdtjkrnytjd}Wntk r\d}YnX|tjd}ntd|rtjd|kr||f\}}}|dtjdkrtd |||d<|s|r||||d d}n ||}|S) NHOMEZ USERPROFILEZHOMEPATHZ HOMEDRIVEr-zCan't determine home directoryZUSERNAMErNz%Can't determine home directory for %rr?)rgenvironKeyError RuntimeErrorr>r*)r+usernameuserhomer9r:r8r r r! gethomedirs,       z_WindowsFlavour.gethomedirN)F)rBrCrDr)r/has_drvntpathpathmodrgname is_supportedsetrSZext_namespace_prefixrangersr2r@r]rernrPrirtrzrr r r r!rFws&  '    rFc@sleZdZdZdZdZeZej dkZ efddZ ddZ d d Z d d Zdd dZddZddZddZdS) _PosixFlavourrHr-FrcCsV|rH|d|krH||}t|t|dkr._resolver-)r) _accessor is_absolutergrhrf)r+rkrlbaser )rrrr)rlr!rn>s &z_PosixFlavour.resolvecCsdS)NFr )r+r8r r r!rtksz_PosixFlavour.is_reservedcCst|}dt|S)Nzfile://)bytesrw)r+rkZbpathr r r!rznsz_PosixFlavour.make_uricCst|s:y tjdStk r6ddl}|tjSXn6ddl}y ||jStk rntd|YnXdS)Nr{rz%Can't determine home directory for %r) rgr|r}pwdgetpwuidgetuidpw_dirgetpwnamr~)r+rrr r r!rts  z_PosixFlavour.gethomedirN)F)rBrCrDr)r/r posixpathrrgrrr2r@r]rernrtrzrr r r r!rs   -rc@seZdZdZdS) _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)rBrCrDrEr r r r!rsrc@seZdZejZejZejZejZejZej Z e edr>ej Z nddZ ej Z ej Z ejZejZejZer~ertejZqddZn eddZejZddZd S) _NormalAccessorlchmodcCs tddS)Nz%lchmod() not available on this system)NotImplementedError)r+Zpathobjmoder r r!rsz_NormalAccessor.lchmodcCs tddS)Nz&symlink() not available on this system)r)abtarget_is_directoryr r r!symlinksz_NormalAccessor.symlinkcCs t||S)N)rgr)rrrr r r!rscCs t|S)N)rgr)r+rkr r r!rsz_NormalAccessor.readlinkN)rBrCrDrgstatlstatopenlistdirscandirchmodhasattrrmkdirunlinkrmdirrenamer1rsupports_symlinksr staticmethodutimerr r r r!rs*   rcCsR|d}|dd}|dkr"t}n$d|kr4tdnt|rBt}nt}||||S)Nrr?z**z:Invalid pattern: '**' can only be an entire path component)_RecursiveWildcardSelector ValueErrorr'_WildcardSelector_PreciseSelector) pattern_partsflavourr& child_partsclsr r r!_make_selectors  r lru_cachec@s eZdZdZddZddZdS) _SelectorzYA selector matches a specific glob pattern part against the children of a given path.cCs0||_|rt|||_d|_nt|_d|_dS)NTF)rr successordironly_TerminatingSelector)r+rrr r r!r,s  z_Selector.__init__cCs<t|}|j}|j}|jj}||s,tgS|||||S)zuIterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.)typeis_direxistsrriter _select_from)r+ parent_pathZpath_clsrrrr r r! select_fromsz_Selector.select_fromN)rBrCrDrEr,rr r r r!rs rc@seZdZddZdS)rccs |VdS)Nr )r+rrrrr r r!rsz!_TerminatingSelector._select_fromN)rBrCrDrr r r r!rsrc@seZdZddZddZdS)rcCs||_t|||dS)N)rrr,)r+rrrr r r!r,sz_PreciseSelector.__init__ccs^yD||j}|jr|n||rBx |j||||D] }|Vq4WWntk rXdSXdS)N)_make_child_relpathrrrrPermissionError)r+rrrrrkr[r r r!rs z_PreciseSelector._select_fromN)rBrCrDr,rr r r r!rsrc@seZdZddZddZdS)rcCs|||_t|||dS)N)rematchrr,)r+r&rrr r r!r,s z_WildcardSelector.__init__c csy||}t|}WdQRXx|D]}|jrly|s:w$Wn.tk rj}zt|sXw$Wdd}~XYnX|j} || r$|| } x |j | |||D] } | VqWq$WWnt k rdSXdS)N) listrrrr"rrrrrr) r+rrrr scandir_itentriesentryrrrkr[r r r!r s&    z_WildcardSelector._select_fromN)rBrCrDr,rr r r r!rsrc@s$eZdZddZddZddZdS)rcCst|||dS)N)rr,)r+r&rrr r r!r,&sz#_RecursiveWildcardSelector.__init__c cs|Vy||}t|}WdQRXx|D]x}d}y |}Wn,tk rj}zt|sZWdd}~XYnX|r*|s*||j} x|| ||D] } | VqWq*WWntk rdSXdS)NF) rrrr" is_symlinkrr_iterate_directoriesr) r+rrrrrrZ entry_is_dirrrkr[r r r!r)s"     z/_RecursiveWildcardSelector._iterate_directoriesc csyjt}zT|jj}xF||||D]4}x.|||||D]}||kr6|V||q6Wq"WWd|XWntk r~dSXdS)N)rrrraddclearr) r+rrrrZyieldedZsuccessor_selectZstarting_pointr[r r r!r<sz'_RecursiveWildcardSelector._select_fromN)rBrCrDr,rrr r r r!r$src@s4eZdZdZdZddZddZddZd d Zd S) _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+rkr r r!r,Us z_PathParents.__init__cCs(|js |jrt|jdSt|jSdS)Nr?)rrrRr)r+r r r!__len__\s z_PathParents.__len__cCs@|dks|t|krt||j|j|j|jd| dS)Nrr?)rR IndexErrorr_from_parsed_partsrrr)r+idxr r r! __getitem__bsz_PathParents.__getitem__cCsd|jjS)Nz <{}.parents>)formatrrB)r+r r r!__repr__hsz_PathParents.__repr__N) rBrCrDrE __slots__r,rrrr r r r!rPs rc@seZdZdZdZddZddZeddZedVd d Z edWd d Z eddZ ddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zeed.d/d0Zeed1d2d0Zed3d4Zed5d6Z ed7d8Z!ed9d:Z"ed;d<Z#d=d>Z$d?d@Z%dAdBZ&edCdDZ'dEdFZ(dGdHZ)dIdJZ*edKdLZ+edMdNZ,dOdPZ-dQdRZ.dSdTZ/dUS)Xra|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}||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)rrgrrr _from_parts)rargsr r r!__new__zszPurePath.__new__cCs|jt|jfS)N) __class__tupler)r+r r r! __reduce__szPurePath.__reduce__cCshg}xV|D]N}t|tr$||j7}q t|}t|trH|t|q tdt|q W|j |S)NzNargument should be a str object or an os.PathLike object returning str, not %r) isinstancerrrgfspathrfr4 TypeErrorr_flavourr>)rrr8rr r r! _parse_argss     zPurePath._parse_argsTcCs<t|}||\}}}||_||_||_|r8||S)N)objectrrrrr_init)rrinitr+r9r:r8r r r!rs zPurePath._from_partscCs,t|}||_||_||_|r(||S)N)rrrrrr)rr9r:r8rr+r r r!rs zPurePath._from_parsed_partscCs4|s|r$|||j|ddS|j|SdS)Nr?)rr*)rr9r:r8r r r!_format_parsed_partsszPurePath._format_parsed_partscCsdS)Nr )r+r r r!rszPurePath._initcCs@||\}}}|j|j|j|j|||\}}}||||S)N)rrrArrrr)r+rr9r:r8r r r! _make_childszPurePath._make_childcCs<y|jStk r6||j|j|jp,d|_|jSXdS)z[Return the string representation of the path, suitable for passing to system calls.r.N)rAttributeErrorrrrr)r+r r r!__str__s  zPurePath.__str__cCst|S)N)rf)r+r r r! __fspath__szPurePath.__fspath__cCs|j}t||jdS)zNReturn the string representation of the path with forward (/) slashes.rH)rrfr1r))r+fr r r!rvszPurePath.as_posixcCs t|S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)rgfsencode)r+r r r! __bytes__szPurePath.__bytes__cCsd|jj|S)Nz{}({!r}))rrrBrv)r+r r r!rszPurePath.__repr__cCs|std|j|S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)rrrrz)r+r r r!as_uriszPurePath.as_uricCs2y|jStk r,|j|j|_|jSXdS)N)rrrr]r)r+r r r!_cpartss zPurePath._cpartscCs&t|tstS|j|jko$|j|jkS)N)rrNotImplementedrr)r+otherr r r!__eq__s zPurePath.__eq__cCs2y|jStk r,tt|j|_|jSXdS)N)rrhashrr)r+r r r!__hash__s zPurePath.__hash__cCs&t|tr|j|jk rtS|j|jkS)N)rrrrr)r+rr r r!__lt__szPurePath.__lt__cCs&t|tr|j|jk rtS|j|jkS)N)rrrrr)r+rr r r!__le__szPurePath.__le__cCs&t|tr|j|jk rtS|j|jkS)N)rrrrr)r+rr r r!__gt__szPurePath.__gt__cCs&t|tr|j|jk rtS|j|jkS)N)rrrrr)r+rr r r!__ge__ szPurePath.__ge__rz.The drive prefix (letter or UNC path), if any.)docrzThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)rr)r+anchorr r r!rs zPurePath.anchorcCs.|j}t||js|jrdndkr&dS|dS)z!The final path component, if any.r?rr-rN)rrRrr)r+r8r r r!rsz PurePath.namecCsD|j}|d}d|kr,t|dkr.r?N)rendswithrTr3)r+rr r r!suffixes1s   zPurePath.suffixescCsD|j}|d}d|kr,t|dkrs    z PurePath.stemcCs|jstd|f|j|f\}}}|rX|d|jj|jjgksX|sX|sXt|dkrdtd|||j|j |j dd|gS)z-Return a new path with the file name changed.z%r has an empty namerNr?zInvalid name %rN) rrrr>r)r/rRrrrr)r+rr9r:r8r r r! with_nameHs  zPurePath.with_namecCs|j}|j|ks |jr.|j|kr.td|f|r<|drD|dkrPtd||j}|shtd|f|j}|s|||}n|dt| |}||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 nameNrN) rr)r/rrprr rRrrrr)r+r rrZ old_suffixr r r! with_suffixSs   zPurePath.with_suffixc Gs|s td|j}|j}|j}|r8||g|dd}n|}||\}}}|rf||g|dd} n|} t| } |jj} | dkr|s|rn| |d| | | kr||||} t d t |t | | 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 argumentr?Nrz{!r} does not start with {!r}r-) rrrrrrRrr]rrrrfr) r+rr8r9r:Z abs_partsZto_drvZto_rootZto_partsZ to_abs_partsncfZ formattedr r r! relative_tohs( *zPurePath.relative_tocCs.y|jStk r(t|j|_|jSXdS)zZAn object providing sequence-like access to the components in the filesystem path.N)rrrr)r+r r r!r8s  zPurePath.partscGs ||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+rr r r!joinpathszPurePath.joinpathcCs ||fS)N)r)r+keyr r r! __truediv__szPurePath.__truediv__cCs||g|jS)N)rr)r+rr r r! __rtruediv__szPurePath.__rtruediv__cCs@|j}|j}|j}t|dkr*|s&|r*|S||||ddS)zThe logical parent of the path.r?NrN)rrrrRr)r+r9r:r8r r r!parents zPurePath.parentcCst|S)z*A sequence of this path's logical parents.)r)r+r r r!parentsszPurePath.parentscCs|js dS|jj pt|jS)zSTrue if the path is absolute (has both a root and, if applicable, a drive).F)rrrboolr)r+r r r!rszPurePath.is_absolutecCs|j|jS)zaReturn True if the path contains one of the special names reserved by the system, if any.)rrtr)r+r r r!rtszPurePath.is_reservedc Cs|jj}||}|j|f\}}}|s0td|rF|||jkrFdS|r\|||jkr\dS|j}|sj|rt|t|kr~dS|dd}nt|t|krdSx.tt |t |D]\}}t ||sdSqWdS)zE Return True if this path matches the given pattern. z empty patternFr?NT) rr@r>rrrrrRzipr0r`Z fnmatchcase) r+Z path_patternrr9r:Z pat_partsr8r<r&r r r!rs( zPurePath.matchN)T)T)0rBrCrDrErrr classmethodrrrrrrrrrvrrrpropertyrrrrrrrrrur:rrr r r rrrr8rrrrrrrtrr r r r!rls\             c@seZdZdZeZdZdS)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. r N)rBrCrDrE_posix_flavourrrr r r r!rsc@seZdZdZeZdZdS)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. r N)rBrCrDrE_windows_flavourrrr r r r!rsc@seZdZdZdZddZdbddZdd Zd d Zd d Z ddZ dcddZ ddddZ e ddZe ddZddZddZddZd d!Zd"d#Zded%d&Zd'd(Zd)d*Zd+d,Zdfd/d0Zd1d2Zdgd3d4Zd5d6Zdhd7d8Zdid:d;Zdjdd?Z d@dAZ!dBdCZ"dDdEZ#dFdGZ$dHdIZ%dJdKZ&dkdLdMZ'dNdOZ(dPdQZ)dRdSZ*dTdUZ+dVdWZ,dXdYZ-dZd[Z.d\d]Z/d^d_Z0d`daZ1dS)lraPurePath 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| |S)NrF)rz$cannot instantiate %r on your system) rrgrrrrrrrrBr)rrkwargsr+r r r!rs z Path.__new__NcCs"d|_|dk r|j|_nt|_dS)NF)rr_normal_accessor)r+templater r r!r s z Path._initcCs|j|g}||j|j|S)N)rrrr)r+r<r8r r r!rs zPath._make_child_relpathcCs|jr||S)N)r _raise_closed)r+r r r! __enter__szPath.__enter__cCs d|_dS)NT)r)r+tvtbr r r!__exit__sz Path.__exit__cCs tddS)NzI/O operation on closed path)r)r+r r r!r#"szPath._raise_closedcCs|j|||S)N)rr)r+rflagsrr r r!_opener%sz Path._openercCs|jr||j|||S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. )rr#rr)r+r*rr r r! _raw_open)szPath._raw_opencCs |tS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )rgrh)rr r r!cwd4szPath.cwdcCs||jdS)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)rr)rr r r!home;sz Path.homecCsB|}y |}Wntk r2t|}YnXtj||S)zoReturn whether other_path is the same or not as this file (as returned by os.path.samefile()). )rrrgrksamestat)r+Z other_pathstZother_str r r!samefileBs  z Path.samefileccsL|jr|x8|j|D](}|dkr*q||V|jr|qWdS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. >r...N)rr#rrr)r+rr r r!iterdirMs z Path.iterdirccsd|std||j|f\}}}|s.|r6tdtt||j}x||D] }|VqRWdS)zIterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern. zUnacceptable pattern: {!r}z%Non-relative patterns are unsupportedN)rrrr>rrrr)r+rdr9r:rselectorr[r r r!glob[sz Path.globccsV|j|f\}}}|s|r$tdtdt||j}x||D] }|VqDWdS)zRecursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. z%Non-relative patterns are unsupported)z**N)rr>rrrr)r+rdr9r:rr5r[r r r!rglobhs z Path.rglobcCsD|jr||r|S|jtg|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")rr#rrrgrhrr)r+objr r r!absolutets z Path.absoluteFcCsh|jr||jj||d}|dkr:|t|}|jj|}|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). )rlNF)r)r") rr#rrnrrfr9rnormpathrr)r+rlrZZnormedr8r r r!rns  z Path.resolvecCs |j|S)zh Return the result of the stat() system call on this path, like os.stat() does. )rr)r+r r r!rsz Path.statcCsddl}||jjS)z: Return the login name of the file owner. rN)rrrst_uidZpw_name)r+rr r r!ownersz Path.ownercCsddl}||jjS)z8 Return the group name of the file gid. rN)grpZgetgrgidrst_gidZgr_name)r+r=r r r!groupsz Path.grouprrNc Cs(|jr|tj|||||||jdS)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )opener)rr#iorr+)r+r bufferingencodingerrorsnewliner r r!rsz Path.openc Cs |jdd }|SQRXdS)zK Open the file in bytes mode, read it, and close the file. rb)rN)rread)r+rr r r! read_bytesszPath.read_bytesc Cs$|jd||d }|SQRXdS)zJ Open the file in text mode, read it, and close the file. r@)rrDrEN)rrH)r+rDrErr r r! read_textszPath.read_textc Cs*t|}|jdd }||SQRXdS)zO Open the file in bytes mode, write to it, and close the file. wb)rN) memoryviewrwrite)r+dataZviewrr r r! write_bytesszPath.write_bytesc Cs@t|tstd|jj|jd||d }||SQRXdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %sw)rrDrEN)rrfrrrBrrM)r+rNrDrErr r r! write_texts   zPath.write_textTcCsr|jr||r>y|j|dWntk r8YnXdStjtjB}|sX|tjO}| ||}t |dS)zS Create this file with the given access mode, if it doesn't exist. N) rr#rrrrgO_CREATO_WRONLYO_EXCLr-close)r+rexist_okr*fdr r r!touchs   z Path.touchcCs|jr|y|j||Wndtk rd|r>|j|kr@|jjddd|j|d|dYn"tk r|r~|sYnXdS)z< Create a new directory at this given path. T)rrVFN)rr#rrrjrrr)r+rrrVr r r!rs z Path.mkdircCs |jr||j||dS)zF Change the permissions of the path, like os.chmod(). N)rr#rr)r+rr r r!rsz Path.chmodcCs |jr||j||dS)z Like chmod(), except if the path points to a symlink, the symlink's permissions are changed, rather than its target's. N)rr#rr)r+rr r r!r sz Path.lchmodcCs|jr||j|dS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)rr#rr)r+r r r!rsz Path.unlinkcCs|jr||j|dS)zF Remove this directory. The directory must be empty. N)rr#rr)r+r r r!rsz Path.rmdircCs|jr||j|S)z Like stat(), except if the path points to a symlink, the symlink's status information is returned, rather than its target's. )rr#rr)r+r r r!r'sz Path.lstatcCs |jr||j||dS)z5 Rename this path to the given path. N)rr#rr)r+rr r r!r0sz Path.renamecCs |jr||j||dS)zo Rename this path to the given path, clobbering the existing destination if it exists. N)rr#rr1)r+rr r r!r18sz Path.replacecCs"|jr||j|||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)rr#rr)r+rrr r r! symlink_toAszPath.symlink_toc Cs>y |Wn,tk r8}zt|s(dSd}~XYnXdS)z+ Whether this path exists. FNT)rrr")r+rr r r!rLs z Path.existsc Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)z3 Whether this path is a directory. FN)r rst_moderr")r+rr r r!rXs z Path.is_dirc Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). FN)r rrZrr")r+rr r r!is_filees z Path.is_filecCst|r|sdSt|j}y|j}Wntk r@dSX|j}||krXdS|j}|j}||kS)z; Check if this path is a POSIX mount point FT)rrrrrst_devrst_ino)r+rZ parent_devZdevZinoZ parent_inor r r!is_mountss    z Path.is_mountc Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)z7 Whether this path is a symbolic link. FN)r rrZrr")r+rr r r!rs zPath.is_symlinkc Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)z6 Whether this path is a block device. FN)r rrZrr")r+rr r r!is_block_devices zPath.is_block_devicec Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)z: Whether this path is a character device. FN)rrrZrr")r+rr r r!is_char_devices zPath.is_char_devicec Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)z. Whether this path is a FIFO. FN)rrrZrr")r+rr r r!is_fifos z Path.is_fifoc Cs@yt|jStk r:}zt|s*dSd}~XYnXdS)z0 Whether this path is a socket. FN)r rrZrr")r+rr r r! is_sockets zPath.is_socketcCs`|js\|js\|jr\|jddddkr\|j|jddd}||g|jddS|S)zl Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) rNr?~)rrrrrr)r+Zhomedirr r r! expandusers  zPath.expanduser)N)r))r,)F)r@rNNNN)NN)NN)r)T)r,FF)F)2rBrCrDrErrrrr$r(r#r+r-rr.r/r2r4r6r7r9rnrr<r?rrIrJrOrQrXrrrrrrrr1rYrrr[r^rr_r`rarbrdr r r r!rs^                       c@seZdZdZdZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. r N)rBrCrDrErr r r r!rsc@s,eZdZdZdZddZddZddZd S) rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. r cCs tddS)Nz*Path.owner() is unsupported on this system)r)r+r r r!r<szWindowsPath.ownercCs tddS)Nz*Path.group() is unsupported on this system)r)r+r r r!r?szWindowsPath.groupcCs tddS)Nz-Path.is_mount() is unsupported on this system)r)r+r r r!r^szWindowsPath.is_mountN)rBrCrDrErr<r?r^r r r r!rs )Ar` functoolsrBrrgrr^r5_collections_abcrrrrrrroperatorrrr r r r r rrZ urllib.parserrwrrrZgetwindowsversionr__all__rrr"r'rr(rFrrrrrr!rrrrrrrrrrPathLikeregisterrrrrrr r r r!sp  $    ?(f1  ,n   e