a Z^@sbddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejdkrddlZe dd d krdd lm!Z!qd ZdZ!ndZgd Z"e e eefZ#dZ$ddZ%ddZ&Gddde'Z(Gddde(Z)Gddde(Z*e)Z+e*Z,GdddZ-Gddde-Z.e.Z/ddZ0e1edre2e0Z0Gd d!d!Z3Gd"d#d#Z4Gd$d%d%e3Z5Gd&d'd'e3Z6Gd(d)d)e3Z7Gd*d+d+e Z8Gd,d-d-e'Z9ej:;e9Gd.d/d/e9ZGd4d5d5e>e<Z?Gd6d7d7e>e=Z@dS)8N)Sequence)EINVALENOENTENOTDIREBADFELOOP) attrgetter)S_ISDIRS_ISLNKS_ISREGS_ISSOCKS_ISBLKS_ISCHRS_ISFIFO)quote_from_bytesTnt)r)_getfinalpathnameF)PurePath PurePosixPathPureWindowsPathPath PosixPath WindowsPath)icCs t|ddtvpt|ddtvS)Nerrnowinerror)getattr_IGNORED_ERROS_IGNORED_WINERRORS) exceptionr"/usr/lib64/python3.9/pathlib.py _ignore_error-sr$cCsd|vpd|vpd|vS)N*?[r")patr"r"r#_is_wildcard_pattern2sr)c@s(eZdZdZddZddZddZdS) _FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dSN)sepjoinselfr"r"r#__init__<sz_Flavour.__init__c Csg}|j}|j}d}}t|}|D]}|s.q$|r>|||}||\}}} || vrt| |D] } | rd| dkrd|t| qdn| r| dkr|t| |s|r$|s|D]0}|sq|r|||}||d}|rqqqq$|s|r|||| |||fS)N.r) r,altsepreversedreplace splitrootsplitappendsysinternreverse) r/partsparsedr,r3drvrootitpartrelxr"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/r>r?r<drv2root2parts2r"r"r#join_parsed_partsesz_Flavour.join_parsed_partsN)__name__ __module__ __qualname____doc__r0rDrJr"r"r"r#r*8s&r*c@seZdZdZdZdZeZej dkZ e dZ dZ hddd ed d DBd d ed d DBZefd dZddZddZddZd#ddZe fddZddZddZddZd d!Zd"S)$_WindowsFlavour\/TrZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\>PRNAUXNULCONcCsh|] }d|qS)zCOM%dr".0ir"r"r# z_WindowsFlavour.rE cCsh|] }d|qS)zLPT%dr"rVr"r"r#rYrZc Cs\|dd}|dd}||krP||krP||\}}|dd}|dd}nd}|dd}||kr||kr||kr||d}|dkr|||d}||dkr|dkrt|}|r||d||||ddfS|d||||ddfSd} } |dkr6||jvr6|dd} |dd}|}||krN|} ||}|| | |fS)NrrErr1:)_split_extended_pathfindlen drive_letterslstrip) r/rAr,firstsecondprefixthirdindexindex2r>r?r"r"r#r6s6      "    z_WindowsFlavour.splitrootcCs|Sr+lowerr/sr"r"r#rFsz_WindowsFlavour.casefoldcCsdd|DS)NcSsg|] }|qSr"rj)rWpr"r"r# rZz2_WindowsFlavour.casefold_parts..r"r/r<r"r"r#casefold_partssz_WindowsFlavour.casefold_partscCstt|tjjSr+)recompilefnmatch translate IGNORECASE fullmatchr/patternr"r"r#compile_patternsz_WindowsFlavour.compile_patternFcCst|}|stSd}tdur|r2|t|Sg}z|t|}Wn@ty|}tj|\}}||||kr|YSYq60tjj |gt |RSq6dSr+) strosgetcwdr_ext_to_normalFileNotFoundErrorpathr7r8r-r4)r/rstrictrm previous_s tail_partstailr"r"r#resolves$  z_WindowsFlavour.resolvecCsXd}||rP|dd}|dd}|drP||dd7}d|dd}||fS)Nr1zUNC\r\rP) startswith)r/rm ext_prefixrfr"r"r#r_s    z$_WindowsFlavour._split_extended_pathcCs||dSNrE)r_rlr"r"r#r~sz_WindowsFlavour._ext_to_normalcCs6|sdS|ddrdS|ddd|jvS)NFrz\\r]r2)r partitionupperreserved_namesrpr"r"r# is_reserveds z_WindowsFlavour.is_reservedcCsd|j}t|dkrJ|ddkrJ|ddd}d|t|dfSdt|dSdS)NrrEr^rQz file:///%s/%szutf-8zfile:)driveraas_posixrcurlquote_from_bytesencode)r/rrrestr"r"r#make_urisz_WindowsFlavour.make_uricCsdtjvrtjd}nHdtjvrVztjd}WntyDd}Yn0|tjd}ntd|rtjd|kr||f\}}}|dtjdkrtd|||d<|s|r||||d d}n ||}|S) N USERPROFILEHOMEPATH HOMEDRIVEr1zCan't determine home directoryUSERNAMEr]%Can't determine home directory for %rrE)r|environKeyError RuntimeErrorrDr-)r/usernameuserhomer>r?r<r"r"r# gethomedirs*      z_WindowsFlavour.gethomedirN)F)rKrLrMr,r3has_drvntpathpathmodr|name is_supportedsetrbext_namespace_prefixrangerr6rFrqrzrr_r~rrrr"r"r"r#rOws.  '    rOc@sleZdZdZdZdZeZej dkZ efddZ ddZ d d Z d d Zdd dZddZddZddZdS) _PosixFlavourrQr1FrcCsV|rH|d|krH||}t|t|dkr._resolver1)r, _accessor is_absoluter|r}r{)r/rrbaser"rr#r<s &z_PosixFlavour.resolvecCsdSNFr"rpr"r"r#risz_PosixFlavour.is_reservedcCst|}dt|S)Nzfile://)bytesr)r/rbpathr"r"r#rlsz_PosixFlavour.make_uricCsx|s>z tjdWSty:ddl}|tjYS0n6ddl}z||jWStyrtd|Yn0dS)NHOMErr) r|rrpwdgetpwuidgetuidpw_dirgetpwnamr)r/rrr"r"r#rrs   z_PosixFlavour.gethomedirN)F)rKrLrMr,r3r posixpathrr|rrr6rFrqrzrrrrr"r"r"r#rs   -rc@seZdZdZdS) _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)rKrLrMrNr"r"r"r#rsrc@seZdZejZejZejZejZejZej Z e edr>ej Z nddZ ej Z ej Z e edrdejZn eddZejZejZejZererejZqddZn ed dZejZd d Zd d ZddZdS)_NormalAccessorlchmodcCs tddS)Nz%lchmod() not available on this systemNotImplementedError)r/pathobjmoder"r"r#rsz_NormalAccessor.lchmodlinkcCs tddS)Nz&os.link() not available on this systemrr/rr"r"r#link_tosz_NormalAccessor.link_tocCs tddS)Nz&symlink() not available on this systemrabtarget_is_directoryr"r"r#symlinksz_NormalAccessor.symlinkcCs t||Sr+)r|rrr"r"r#rscCs t|Sr+)r|rr/rr"r"r#rsz_NormalAccessor.readlinkcCs>zddl}|||jjWSty8tdYn0dS)Nrz*Path.owner() is unsupported on this system)rrstatst_uidpw_name ImportErrorr)r/rrr"r"r#owners  z_NormalAccessor.ownercCs>zddl}|||jjWSty8tdYn0dS)Nrz*Path.group() is unsupported on this system)grpgetgrgidrst_gidgr_namerr)r/rrr"r"r#groups  z_NormalAccessor.groupN)rKrLrMr|rlstatopenlistdirscandirchmodhasattrrmkdirunlinkrr staticmethodrmdirrenamer5rsupports_symlinksrutimerrrr"r"r"r#rs8     rcCsR|d}|dd}|dkr"t}n$d|vr4tdnt|rBt}nt}||||S)NrrE**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#r0s  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_pathpath_clsrrrr"r"r# select_fromsz_Selector.select_fromN)rKrLrMrNr0rr"r"r"r#rs rc@seZdZddZdS)rccs |VdSr+r")r/rrrrr"r"r#rsz!_TerminatingSelector._select_fromN)rKrLrMrr"r"r"r#rsrc@seZdZddZddZdS)rcCs||_t|||dSr+)rrr0)r/rrrr"r"r#r0 sz_PreciseSelector.__init__ccsZz@||j}|jr|n||r>|j||||D] }|Vq2WntyTYdS0dSr+)_make_child_relpathrrrrPermissionError)r/rrrrrrnr"r"r#rs   z_PreciseSelector._select_fromNrKrLrMr0rr"r"r"r#rsrc@seZdZddZddZdS)rcCs|||_t|||dSr+)rzmatchrr0r/r(rrr"r"r#r0s z_WildcardSelector.__init__c csz||}t|}Wdn1s(0Y|D]}|jrz|sNWq6Wn:ty}z"t|sjWYd}~q6WYd}~n d}~00|j} || r6|| } |j | |||D] } | Vqq6Wnt yYdS0dSr+) listrrrr$rrrrrr) r/rrrr scandir_itentriesentryrrrrnr"r"r#rs& &"   z_WildcardSelector._select_fromNrr"r"r"r#rsrc@s$eZdZddZddZddZdS)rcCst|||dSr+)rr0rr"r"r#r09sz#_RecursiveWildcardSelector.__init__c cs|Vz||}t|}Wdn1s.0Y|D]v}d}z |}Wn.ty~}zt|sjWYd}~n d}~00|r<|s<||j} || ||D] } | Vqq)formatrrKr.r"r"r#__repr__{sz_PathParents.__repr__N) rKrLrMrN __slots__r0rrrr"r"r"r#rcs rc@seZdZdZdZddZddZeddZed\d d Z ed]d d Z eddZ ddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zeed0d1d2Zeed3d4d2Zed5d6Z ed7d8Z!ed9d:Z"ed;d<Z#ed=d>Z$d?d@Z%dAdBZ&dCdDZ'dEdFZ(dGdHZ)edIdJZ*dKdLZ+dMdNZ,dOdPZ-edQdRZ.edSdTZ/dUdVZ0dWdXZ1dYdZZ2d[S)^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$|turtjdkrtnt}||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|rrr _from_parts)rargsr"r"r#__new__szPurePath.__new__cCs|jt|jfSr+) __class__tuplerr.r"r"r# __reduce__szPurePath.__reduce__cCsdg}|D]N}t|tr"||j7}qt|}t|trF|t|qtdt|q|j |S)NzNargument should be a str object or an os.PathLike object returning str, not %r) isinstancerrr|fspathr{r8 TypeErrorr_flavourrD)rr#r<rr"r"r# _parse_argss    zPurePath._parse_argsTcCs<t|}||\}}}||_||_||_|r8||Sr+)objectr$r,rrr_init)rr#initr/r>r?r<r"r"r#r"s zPurePath._from_partscCs,t|}||_||_||_|r(||Sr+)r-r$rrrr.)rr>r?r<r/r/r"r"r#rs zPurePath._from_parsed_partscCs4|s|r$|||j|ddS|j|SdSr)r+r-)rr>r?r<r"r"r#_format_parsed_partsszPurePath._format_parsed_partscCsdSr+r"r.r"r"r#r.szPurePath._initcCs@||\}}}|j|j|j|j|||\}}}||||Sr+)r,r+rJrrrr)r/r#r>r?r<r"r"r# _make_childs  zPurePath._make_childcCs@z|jWSty:||j|j|jp,d|_|jYS0dS)z[Return the string representation of the path, suitable for passing to system calls.r2N)rAttributeErrorr0rrrr.r"r"r#__str__s  zPurePath.__str__cCst|Sr+)r{r.r"r"r# __fspath__szPurePath.__fspath__cCs|j}t||jdS)zNReturn the string representation of the path with forward (/) slashes.rQ)r+r{r5r,r/fr"r"r#rszPurePath.as_posixcCs t|S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)r|fsencoder.r"r"r# __bytes__szPurePath.__bytes__cCsd|jj|S)Nz{}({!r}))rr%rKrr.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)rrr+rr.r"r"r#as_uriszPurePath.as_uricCs6z|jWSty0|j|j|_|jYS0dSr+)r!r2r+rqrr.r"r"r#_cpartss  zPurePath._cpartscCs&t|tstS|j|jko$|j|juSr+)r(rNotImplementedr:r+r/otherr"r"r#__eq__s zPurePath.__eq__cCs6z|jWSty0tt|j|_|jYS0dSr+)rr2hashr&r:r.r"r"r#__hash__s  zPurePath.__hash__cCs&t|tr|j|jurtS|j|jkSr+r(rr+r;r:r<r"r"r#__lt__szPurePath.__lt__cCs&t|tr|j|jurtS|j|jkSr+rAr<r"r"r#__le__szPurePath.__le__cCs&t|tr|j|jurtS|j|jkSr+rAr<r"r"r#__gt__szPurePath.__gt__cCs&t|tr|j|jurtS|j|jkSr+rAr<r"r"r#__ge__szPurePath.__ge__cCs|Sr+r")rrr"r"r#__class_getitem__"szPurePath.__class_getitem__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#rH+s zPurePath.anchorcCs.|j}t||js|jrdndkr&dS|dS)z!The final path component, if any.rErr1r])rrarrrpr"r"r#r1sz PurePath.namecCsD|j}|d}d|kr,t|dkr.rEN)rendswithrcr7r/rr"r"r#suffixesGs   zPurePath.suffixescCsD|j}|d}d|kr,t|dkrr?r<r"r"r# with_name^s   zPurePath.with_namecCs|||jS)z(Return a new path with the stem changed.)rRrL)r/rPr"r"r# with_stemiszPurePath.with_stemcCs|j}|j|vs |jr.|j|vr.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 %rr2rQNr]) r+r,r3rrrrLrarrrr)r/rLr6r old_suffixr"r"r# with_suffixms   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 argumentrENrzU{!r} is not in the subpath of {!r} OR one path is relative and the other is absolute.r1) r*rrrr,rar+rqr0rrr{r) r/r=r<r>r? abs_partsto_drvto_rootto_parts to_abs_partsncf formattedr"r"r# relative_tos, *  zPurePath.relative_tocGs*z|j|WdSty$YdS0dS)zFReturn True if the path is relative to another path or False. TFN)r^rr<r"r"r#is_relative_tos   zPurePath.is_relative_tocCs2z|jWSty,t|j|_|jYS0dS)zZAn object providing sequence-like access to the components in the filesystem path.N)r r2r&rr.r"r"r#r<s   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). )r1)r/r#r"r"r#joinpathszPurePath.joinpathcCs*z||fWSty$tYS0dSr+)r1r*r;r/keyr"r"r# __truediv__s zPurePath.__truediv__cCs0z||g|jWSty*tYS0dSr+)r"rr*r;rar"r"r# __rtruediv__s zPurePath.__rtruediv__cCs@|j}|j}|j}t|dkr*|s&|r*|S||||ddS)zThe logical parent of the path.rENr])rrrrar)r/r>r?r<r"r"r#parents zPurePath.parentcCst|S)z*A sequence of this path's logical parents.)rr.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)rr+rboolrr.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.)r+rrr.r"r"r#rszPurePath.is_reservedc Cs|jj}||}|j|f\}}}|s0td|rF|||jkrFdS|r\|||jkr\dS|j}|sj|rt|t|kr~dS|dd}nt|t|krdStt |t |D]\}}t ||sdSqdS)zE Return True if this path matches the given pattern. z empty patternFrENT) r+rFrDrrrr:razipr4rt fnmatchcase) r/ path_patternr\r>r? pat_partsr<rAr(r"r"r#rs( zPurePath.matchN)T)T)3rKrLrMrNrr$r' classmethodr,r"rr0r.r1r3r4rr8rr9propertyr:r>r@rBrCrDrErFrrr?rHrrLrOrPrRrSrUr^r_r<r`rcrdrerfrrrr"r"r"r#rs|             !    rc@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)rKrLrMrN_posix_flavourr+rr"r"r"r#rsrc@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)rKrLrMrN_windows_flavourr+rr"r"r"r#rsrc@seZdZdZdZddZddddZdd Zd d Zd d Z deddZ dfddZ e ddZ e ddZddZddZddZddZd d!Zdgd#d$Zd%d&Zd'd(Zd)d*Zdhd-d.Zd/d0Zdid1d2Zd3d4Zdjd5d6Zd7d8Zdkd:d;Zdldd?Z d@dAZ!dmdBdCZ"dDdEZ#dFdGZ$dHdIZ%dJdKZ&dLdMZ'dndNdOZ(dPdQZ)dRdSZ*dTdUZ+dVdWZ,dXdYZ-dZd[Z.d\d]Z/d^d_Z0d`daZ1dbdcZ2dS)oraPurePath 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. )rcOsL|turtjdkrtnt}|j|dd}|jjs@td|j f| |S)NrFr/z$cannot instantiate %r on your system) rr|rrrr"r+rrrKr.)rr#kwargsr/r"r"r#r$)sz Path.__new__NcCs|dur|j|_nt|_dSr+)r_normal_accessor)r/templater"r"r#r.3s z Path._initcCs|j|g}||j|j|Sr+)rrrr)r/rAr<r"r"r#r<s zPath._make_child_relpathcCs|Sr+r"r.r"r"r# __enter__BszPath.__enter__cCsdSr+r")r/tvtbr"r"r#__exit__Es z Path.__exit__cCs|j|||Sr+rr)r/rflagsrr"r"r#_openerPsz Path._openercCs|j|||S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. rz)r/r{rr"r"r# _raw_openTszPath._raw_opencCs |tS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )r|r}rr"r"r#cwd]szPath.cwdcCs||jdS)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)r+rrr"r"r#homedsz Path.homecCsB|}z |}Wnty2|j|}Yn0tj||S)zoReturn whether other_path is the same or not as this file (as returned by os.path.samefile()). )rr2rr|rsamestat)r/ other_pathstother_str"r"r#samefileks   z Path.samefileccs,|j|D]}|dvrq ||Vq dS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. >r2rN)rrrrNr"r"r#iterdirvsz Path.iterdirccsntd|||s td||j|f\}}}|s<|rDtdtt||j}| |D] }|Vq^dS)zIterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern. zpathlib.Path.globzUnacceptable pattern: {!r}%Non-relative patterns are unsupportedN) r9auditrrr+rDrrr&rr/ryr>r?rselectorrnr"r"r#globsz Path.globccs`td|||j|f\}}}|s*|r2tdtdt||j}||D] }|VqPdS)zRecursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. zpathlib.Path.rglobr)rN)r9rr+rDrrr&rrr"r"r#rglobsz Path.rglobcCs6|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. Frprs)rr"r|r}rr.)r/objr"r"r#absolutes  z Path.absoluteFcCsZ|jj||d}|dur,|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). )rNFrpr) r+rrr{rrnormpathr"r.)r/rrmnormedrr"r"r#rs  z Path.resolvecCs |j|S)zh Return the result of the stat() system call on this path, like os.stat() does. )rrr.r"r"r#rsz Path.statcCs |j|S)z: Return the login name of the file owner. )rrr.r"r"r#rsz Path.ownercCs |j|S)z8 Return the group name of the file gid. )rrr.r"r"r#rsz Path.grouprr]c Cstj|||||||jdS)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )opener)iorr|)r/r bufferingencodingerrorsnewliner"r"r#rsz Path.opencCs8|jdd}|WdS1s*0YdS)zK Open the file in bytes mode, read it, and close the file. rbrNrreadr5r"r"r# read_bytesszPath.read_bytescCs<|jd||d}|WdS1s.0YdS)zJ Open the file in text mode, read it, and close the file. rrrrNr)r/rrr6r"r"r# read_textszPath.read_textcCsBt|}|jdd}||WdS1s40YdS)zO Open the file in bytes mode, write to it, and close the file. wbrN) memoryviewrwrite)r/dataviewr6r"r"r# write_bytesszPath.write_bytescCsXt|tstd|jj|jd||d}||WdS1sJ0YdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %swrN)r(r{r*r%rKrr)r/rrrr6r"r"r# write_texts  zPath.write_textcCs,|j|}|j|fdd}|j|d|S)zD Return the path to which the symbolic link points. Frpr)rrr"r.)r/rrr"r"r#rs  z Path.readlinkTcCsb|r.z|j|dWnty(Yn0dStjtjB}|sH|tjO}|||}t|dS)zS Create this file with the given access mode, if it doesn't exist. N) rrrr|O_CREATO_WRONLYO_EXCLr~close)r/rexist_okr{fdr"r"r#touchs    z Path.touchcCsxz|j||Wn`tyT|r.|j|kr0|jjddd|j|d|dYn tyr|rl|snYn0dS)z< Create a new directory at this given path. T)rfrFN)rrrrerr)r/rrfrr"r"r#rs   z Path.mkdircCs|j||dS)zF Change the permissions of the path, like os.chmod(). N)rrr/rr"r"r#r)sz Path.chmodcCs|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)rrrr"r"r#r/sz Path.lchmodcCs.z|j|Wnty(|s$Yn0dS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)rrr)r/ missing_okr"r"r#r6s  z Path.unlinkcCs|j|dS)zF Remove this directory. The directory must be empty. N)rrr.r"r"r#rAsz Path.rmdircCs |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. )rrr.r"r"r#rGsz Path.lstatcCs|j||dS)zE Create a hard link pointing to a path named target. N)rrrr"r"r#rNsz Path.link_tocCs|j||||S)zx Rename this path to the given path, and return a new Path instance pointing to the given path. )rrr%rr"r"r#rTsz Path.renamecCs|j||||S)z Rename this path to the given path, clobbering the existing destination if it exists, and return a new Path instance pointing to the given path. )rr5r%rr"r"r#r5\sz Path.replacecCs|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)r/rrr"r"r# symlink_toeszPath.symlink_toc CsTz |WnBty<}zt|s&WYd}~dSd}~0tyNYdS0dS)z+ Whether this path exists. NFT)rrr$rr/rr"r"r#rns  z Path.existsc CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)z3 Whether this path is a directory. NF)r rst_moderr$rrr"r"r#r}s z Path.is_dirc CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). NF)r rrrr$rrr"r"r#is_files z Path.is_filecCsn|r|sdSz|jj}Wnty8YdS0|j}||krPdS|j}|jj}||kS)z; Check if this path is a POSIX mount point FT)rrrerst_devrst_ino)r/ parent_devdevino parent_inor"r"r#is_mounts    z Path.is_mountc CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)z7 Whether this path is a symbolic link. NF)r rrrr$rrr"r"r#r s zPath.is_symlinkc CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)z6 Whether this path is a block device. NF)r rrrr$rrr"r"r#is_block_devices zPath.is_block_devicec CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)z: Whether this path is a character device. NF)rrrrr$rrr"r"r#is_char_devices zPath.is_char_devicec CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)z. Whether this path is a FIFO. NF)rrrrr$rrr"r"r#is_fifos z Path.is_fifoc CsXzt|jWSty@}zt|s*WYd}~dSd}~0tyRYdS0dS)z0 Whether this path is a socket. NF)r rrrr$rrr"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) rNrE~)rrrr+rr")r/homedirr"r"r# expandusers zPath.expanduser)N)ry)r})F)rr]NNN)NN)NN)ryT)r}FF)F)F)3rKrLrMrNrr$r.rrtrxr|r~rlrrrrrrrrrrrrrrrrrrrrrrrrrrr5rrrrrr rrrrrr"r"r"r#rsh                rc@seZdZdZdZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. r"N)rKrLrMrNrr"r"r"r#r src@seZdZdZdZddZdS)rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. r"cCs tddS)Nz-Path.is_mount() is unsupported on this systemrr.r"r"r#rszWindowsPath.is_mountN)rKrLrMrNrrr"r"r"r#rsr)Art functoolsrrr|rrrr9_collections_abcrrrrrrroperatorrrr r r r r rr urllib.parserrrrrZgetwindowsversionr__all__rr r$r)r-r*rOrrornrrrrrrrrrrrrrrPathLikeregisterrrrrrr"r"r"r#sp  $   ?&fF  ,   t