o bc@s4ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZmZddlmZddlmZmZmZmZmZmZmZddlmZgdZdZd Z d Z!e eeefZ"ee e!fZ#d d Z$d dZ%Gddde&Z'Gddde'Z(Gddde'Z)e(Z*e)Z+GdddZ,Gddde,Z-e-Z.ddZ/e0edre1e/Z/GdddZ2GdddZ3Gd d!d!e2Z4Gd"d#d#e2Z5Gd$d%d%e2Z6Gd&d'd'e Z7Gd(d)d)e&Z8ej9:e8Gd*d+d+e8Z;Gd,d-d-e8ZGd2d3d3e=e<Z?dS)4N)Sequence)EINVALENOENTENOTDIREBADFELOOP) attrgetter)S_ISDIRS_ISLNKS_ISREGS_ISSOCKS_ISBLKS_ISCHRS_ISFIFO)quote_from_bytes)PurePath PurePosixPathPureWindowsPathPath PosixPath WindowsPath{icCs t|ddtvpt|ddtvS)Nerrnowinerror)getattr_IGNORED_ERROS_IGNORED_WINERRORS)Z exceptionrh/home/lily/lilypond-2.24.1/release/binaries/dependencies/install/Python-3.10.8/lib/python3.10/pathlib.py _ignore_error&sr cCsd|vp d|vp d|vS)N*?[r)patrrr_is_wildcard_pattern+sr%c@s(eZdZdZddZddZddZdS) _FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dSN)sepjoinselfrrr__init__5z_Flavour.__init__c Csg}|j}|j}d}}t|}|D]c}|sq|r|||}||\}}} || vrDt| |D]} | rB| dkrB|t| q2n| rR| dkrR|t| |sV|ru|ss|D]}|s_qZ|rg|||}||d}|rrnqZnq|sz|r|||| |||fS)N.r) r(altsepreversedreplace splitrootsplitappendsysinternreverse) r+partsZparsedr(r0drvrootitpartZrelxrrr parse_parts8sH     z_Flavour.parse_partscCsz|r|s|r||||g|ddfSn#|r1||ks%||||kr0||||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;r9Zdrv2Zroot2Zparts2rrrjoin_parsed_parts^s z_Flavour.join_parsed_partsN)__name__ __module__ __qualname____doc__r,r?rBrrrrr&1s  &r&c@seZdZdZdZdZeZej dkZ e dZ dZ hddd d DBd d d DBZefd d ZddZddZddZe fddZddZddZdS)_WindowsFlavour\/TntZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\>zCONOUT$ZCONZAUXzCONIN$ZNULZPRNcCh|]}d|qS)zCOM%sr.0crrr z_WindowsFlavour.u123456789¹²³cCrK)zLPT%srrLrrrrOrPc CsV|dd}|dd}||kr(||kr(||\}}|dd}|dd}nd}|dd}||kr~||kr~||kr~||d}|dkr~|||d}||dkr~|dkr\t|}|ro||d||||ddfS|d||||ddfSd} } |dkr||jvr|dd} |dd}|}||kr|} ||}|| | |fS)Nrr@r.:)_split_extended_pathfindlen drive_letterslstrip) r+r=r(firstsecondprefixZthirdindexZindex2r:r;rrrr3s6      "   z_WindowsFlavour.splitrootcCs|Sr'lowerr+srrrrAz_WindowsFlavour.casefoldcCsdd|DS)NcSsg|]}|qSrr^)rMprrr rPz2_WindowsFlavour.casefold_parts..rr+r9rrrcasefold_partsr-z_WindowsFlavour.casefold_partscCstt|tjjSr')recompilefnmatch translate IGNORECASE fullmatchr+patternrrrcompile_patternsz_WindowsFlavour.compile_patterncCsXd}||r(|dd}|dd}|dr(||dd7}d|dd}||fS)Nr.zUNC\rRrH) startswith)r+raZ ext_prefixr\rrrrUs    z$_WindowsFlavour._split_extended_pathcCsJ|sdS|ddr dS|dddddd}||jvS)NFrz\\rSr/rT )rq partitionrstripupperreserved_names)r+r9namerrr is_reserveds "z_WindowsFlavour.is_reservedcCs`|j}t|dkr%|ddkr%|ddd}d|t|dfSdt|dS)NrQr@rTrIz file:///%s/%szutf-8zfile:)driverWas_posixrYurlquote_from_bytesencode)r+pathryrestrrrmake_urisz_WindowsFlavour.make_uriN)rCrDrEr(r0has_drvntpathpathmodosrw is_supportedsetrXZext_namespace_prefixrvr3rArfrorUrxrrrrrrGps*    '  rGc@sZeZdZdZdZdZeZej dkZ efddZ ddZ d d Z d d Zd dZddZdS) _PosixFlavourrIr.FrJcCsP|r#|d|kr#||}t|t|dkrd|d|fSd||fSdd|fS)NrrQr.)rYrW)r+r=r(Z stripped_partrrrr3s    z_PosixFlavour.splitrootcC|Sr'rr`rrrrAz_PosixFlavour.casefoldcCrr'rrerrrrfrz_PosixFlavour.casefold_partscCstt|jSr')rgrhrirjrlrmrrrroz_PosixFlavour.compile_patterncCsdSNFrrerrrrxrz_PosixFlavour.is_reservedcCst|}dt|S)Nzfile://)bytesr{)r+r}Zbpathrrrr s z_PosixFlavour.make_uriN)rCrDrEr(r0r posixpathrrrwrr3rArfrorxrrrrrrs   rc@seZdZdZdS) _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)rCrDrErFrrrrrsrc@seZdZejZejZejZejZej Z ej Z ej Z e edr"ej Z nddZ ejZejZejZe edr8ejZndddZdd d Ze ed rKejZnd dZddZddZejZeejjZeejjZdS)_NormalAccessorlinkcCtd)Nz&os.link() not available on this systemNotImplementedError)r+srcdstrrrr-rbz_NormalAccessor.linksymlinkFcCr)Nz)os.symlink() not available on this systemr)r+rrtarget_is_directoryrrrr9rbz_NormalAccessor.symlinkTcCs`|rz t|dWdStyYnwtjtjB}|s"|tjO}t|||}t|dSr')rutimeOSErrorO_CREATO_WRONLYO_EXCLopenclose)r+r}modeexist_okflagsfdrrrtouch<s   z_NormalAccessor.touchreadlinkcCr)Nz*os.readlink() not available on this systemrr+r}rrrrQrbz_NormalAccessor.readlinkcC6zddl}|||jjWStytdw)Nrz*Path.owner() is unsupported on this system)pwdgetpwuidstatst_uidZpw_name ImportErrorr)r+r}rrrrownerT  z_NormalAccessor.ownercCr)Nrz*Path.group() is unsupported on this system)grpZgetgrgidrst_gidZgr_namerr)r+r}rrrrgroup[rz_NormalAccessor.groupNFrT)rCrDrErriorlistdirscandirchmodmkdirunlinkhasattrrrmdirrenamer2rrrrrgetcwd staticmethodr} expanduserrealpathrrrrrs4      rcCsP|d}|dd}|dkrt}nd|vrtdt|r t}nt}||||S)Nrr@**z:Invalid pattern: '**' can only be an entire path component)_RecursiveWildcardSelector ValueErrorr%_WildcardSelector_PreciseSelector) pattern_partsflavourr$ child_partsclsrrr_make_selectorps  r lru_cachec@s eZdZdZddZddZdS) _SelectorzYA selector matches a specific glob pattern part against the children of a given path.cCs2||_|rt|||_d|_dSt|_d|_dS)NTF)rr successordironly_TerminatingSelector)r+rrrrrr,s    z_Selector.__init__cCs<t|}|j}|j}|jj}||stgS|||||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)rCrDrErFr,rrrrrrs rc@seZdZddZdS)rccs |VdSr'r)r+rrrrrrrrs z!_TerminatingSelector._select_fromN)rCrDrErrrrrrs rc@eZdZddZddZdS)rcCs||_t|||dSr')rwrr,)r+rwrrrrrr,sz_PreciseSelector.__init__ccs`z$||j}|jr |n||r |j||||D]}|VqWdSWdSty/YdSwr')_make_child_relpathrwrrrPermissionError)r+rrrrr}rcrrrrs  z_PreciseSelector._select_fromNrCrDrEr,rrrrrr rc@r)rcCs|||_t|||dSr')romatchrr,r+r$rrrrrr,s z_WildcardSelector.__init__c csz_|| }t|}Wdn1swY|D]A}|jrAz|s(WqWnty@}z t|s6WYd}~qd}~ww|j} || r]|| } |j | |||D]} | VqWqWdSt yjYdSwr') listrrrr rwrrrrr) r+rrrr scandir_itentriesentryerwr}rcrrrrs6      z_WildcardSelector._select_fromNrrrrrrrrc@s$eZdZddZddZddZdS)rcCst|||dSr')rr,rrrrr,rz#_RecursiveWildcardSelector.__init__c cs|VzY|| }t|}Wdn1swY|D];}d}z|}Wnty@}z t|s6WYd}~nd}~ww|rZ|sZ||j} || ||D]} | VqTqWdStygYdSwr) rrrr is_symlinkrrw_iterate_directoriesr) r+rrrrrrZ entry_is_dirrr}rcrrrrs2       z/_RecursiveWildcardSelector._iterate_directoriesc csz5t}z,|jj}||||D]}|||||D]}||vr(|V||qqW|WdS|wty@YdSwr')rrrraddclearr) r+rrrrZyieldedZsuccessor_selectZstarting_pointrcrrrrs"  z'_RecursiveWildcardSelector._select_fromN)rCrDrEr,rrrrrrrs rc@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|_dSr')rrrrrrrrrr,s  z_PathParents.__init__cCs$|js|jr t|jdSt|jSNr@)rrrWrr*rrr__len__s  z_PathParents.__len__cst|trtfddt|tDS|tks$|t kr(t||dkr2|t7}jj j j d| dS)Nc3s|]}|VqdSr'r)rMir*rr sz+_PathParents.__getitem__..rr@) isinstanceslicetuplerangeindicesrW IndexErrorr_from_parsed_partsrrr)r+idxrr*r __getitem__ s $ z_PathParents.__getitem__cCsd|jjS)Nz <{}.parents>)formatrrCr*rrr__repr__r-z_PathParents.__repr__N) rCrDrErF __slots__r,rrrrrrrrs rc@seZdZdZdZddZddZeddZed d Z ed d Z ed dZ ddZ ddZ ddZddZddZddZddZeddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zeed-d.d/Zeed0d1d/Zed2d3Zed4d5Z ed6d7Z!ed8d9Z"ed:d;Z#dd?Z%d@dAZ&dBdCZ'dDdEZ(edFdGZ)dHdIZ*dJdKZ+dLdMZ,edNdOZ-edPdQZ.dRdSZ/dTdUZ0dVdWZ1dXS)Yra|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$|tur tjdkr tnt}||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. rJ)rrrwrr _from_parts)rargsrrr__new__*s zPurePath.__new__cCs|jt|jfSr') __class__rrr*rrr __reduce__4szPurePath.__reduce__cCsbg}|D]&}t|tr||j7}qt|}t|tr#|t|qtdt||j |S)NzNargument should be a str object or an os.PathLike object returning str, not %r) rrrrfspathstrr5 TypeErrorr_flavourr?)rrr9arrr _parse_args9s     zPurePath._parse_argscCs0t|}||\}}}||_||_||_|Sr')objectrr rrr)rrr+r:r;r9rrrrMs zPurePath._from_partscCs t|}||_||_||_|Sr')r rrrr)rr:r;r9r+rrrrXs zPurePath._from_parsed_partscCs0|s|r|||j|ddS|j|Sr)rr))rr:r;r9rrr_format_parsed_parts`s zPurePath._format_parsed_partscCs@||\}}}|j|j|j|j|||\}}}||||Sr')r rrBrrrr)r+rr:r;r9rrr _make_childgs  zPurePath._make_childcCs<z|jWSty||j|j|jpd|_|jYSw)z[Return the string representation of the path, suitable for passing to system calls.r/)rAttributeErrorr rrrr*rrr__str__ms   zPurePath.__str__cCt|Sr')rr*rrr __fspath__wrbzPurePath.__fspath__cCs|j}t||jdS)zNReturn the string representation of the path with forward (/) slashes.rI)rrr2r(r+frrrrzzszPurePath.as_posixcCs t|S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)rfsencoder*rrr __bytes__s zPurePath.__bytes__cCsd|jj|S)Nz{}({!r}))rrrCrzr*rrrrszPurePath.__repr__cCs|std|j|S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI) is_absoluterrrr*rrras_uris zPurePath.as_uricCs2z|jWSty|j|j|_|jYSwr')rrrrfrr*rrr_cpartss   zPurePath._cpartscCs&t|tstS|j|jko|j|juSr')rrNotImplementedrrr+otherrrr__eq__s zPurePath.__eq__cCs2z|jWStytt|j|_|jYSwr')rrhashrrr*rrr__hash__s   zPurePath.__hash__cCs&t|tr |j|jur tS|j|jkSr'rrrrrrrrr__lt__ zPurePath.__lt__cCs&t|tr |j|jur tS|j|jkSr'rrrrr__le__r!zPurePath.__le__cCs&t|tr |j|jur tS|j|jkSr'rrrrr__gt__r!zPurePath.__gt__cCs&t|tr |j|jur tS|j|jkSr'rrrrr__ge__r!zPurePath.__ge__cC|Sr'r)rrrrr__class_getitem__rzPurePath.__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+anchorrrrr(s zPurePath.anchorcCs.|j}t||js |jrdndkrdS|dS)z!The final path component, if any.r@rr.rS)rrWrrrerrrrwsz PurePath.namecCsB|j}|d}d|krt|dkrndS||dSdS)z{ The final component's last suffix, if any. This includes the leading period. For example: '.txt' r/rr@Nr.rwrfindrWr+rwrrrrsuffixs   zPurePath.suffixcCs:|j}|dr gS|d}dd|dddDS)z A list of the final component's suffixes, if any. These include the leading periods. For example: ['.tar', '.gz'] r/cSsg|]}d|qS)r/r)rMr,rrrrdrPz%PurePath.suffixes..r@N)rwendswithrYr4r+rwrrrsuffixess   zPurePath.suffixescCsB|j}|d}d|krt|dkrn|S|d|S|S)z0The final path component, minus its last suffix.r/rr@Nr)r+rrrstems   z PurePath.stemcCs|js td|f|j|f\}}}|r,|d|jj|jjfvs,|s,|s,t|dkr2td|||j|j |j dd|gS)z-Return a new path with the file name changed.%r has an empty namerSr@zInvalid name %rN) rwrrr?r(r0rWrrrr)r+rwr:r;r9rrr with_names   zPurePath.with_namecCs|||jS)z(Return a new path with the stem changed.)r2r,)r+r0rrr with_stemszPurePath.with_stemcCs|j}|j|vs|jr|j|vrtd|f|r|dr"|dkr(td||j}|s4td|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/r1NrS) rr(r0rrqrwr,rWrrrr)r+r,rrwZ old_suffixrrr with_suffixs   zPurePath.with_suffixc Gs|std|j}|j}|j}|r||g|dd}n|}||\}}}|r3||g|dd} n|} t| } |jj} | dkrF|sE|ren | |d| | | kre||||} t d t |t | | d| dkrn|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@NrzU{!r} is not in the subpath of {!r} OR one path is relative and the other is absolute.r.) rrrrr rWrrfr rrrr) r+rr9r:r;Z abs_partsZto_drvZto_rootZto_partsZ to_abs_partsncfZ formattedrrr relative_tos0  zPurePath.relative_tocGs&z|j|WdStyYdSw)zFReturn True if the path is relative to another path or False. TF)r7rrrrris_relative_to8s   zPurePath.is_relative_tocCs.z|jWStyt|j|_|jYSw)zZAn object providing sequence-like access to the components in the filesystem path.)rrrrr*rrrr9As    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+rrrrjoinpathMs zPurePath.joinpathcCs&z||fWStytYSwr')r rrr+keyrrr __truediv__Us  zPurePath.__truediv__cCs,z ||g|jWStytYSwr')rrrrr:rrr __rtruediv__[s  zPurePath.__rtruediv__cCs@|j}|j}|j}t|dkr|s|r|S||||ddS)zThe logical parent of the path.r@NrS)rrrrWr)r+r:r;r9rrrparentas zPurePath.parentcCr)z*A sequence of this path's logical parents.)rr*rrrparentskszPurePath.parentscCs|jsdS|jj pt|jS)zSTrue if the path is absolute (has both a root and, if applicable, a drive).F)rrrboolrr*rrrrpszPurePath.is_absolutecCs|j|jS)zaReturn True if the path contains one of the special names reserved by the system, if any.)rrxrr*rrrrxwszPurePath.is_reservedc Cs|jj}||}|j|f\}}}|std|r#|||jkr#dS|r.|||jkr.dS|j}|s5|rFt|t|kr?dS|dd}n t|t|krPdStt |t |D] \}}t ||sfdSqYdS)zE Return True if this path matches the given pattern. z empty patternFr@NT) rrAr?rrrrrWzipr1riZ fnmatchcase) r+Z path_patternr6r:r;Z pat_partsr9r=r$rrrr|s* zPurePath.matchN)2rCrDrErFrrr classmethodr rrr r rrrzrrrpropertyrrrr r"r#r$r&rryr;r(rwr,r/r0r2r3r4r7r8r9r9r<r=r>r?rrxrrrrrrs|              !     rc@eZdZdZeZdZdS)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. rN)rCrDrErF_posix_flavourrrrrrrrrc@rD)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. rN)rCrDrErF_windows_flavourrrrrrrrrFrc@seZdZdZeZdZddZddZddZ d d Z e d d Z e d dZ ddZddZddZddZddZdaddZddddZd d!Zd"d#Z & &dbd'd(Zd)d*Zdcd+d,Zd-d.Zddd/d0Zd1d2Zded4d5Zdfd7d8Zddd9d:Zd;d<Z dad=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dadGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2d&S)graPurePath 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. rcOs@|tur tjdkr tnt}||}|jjstd|j f|S)NrJz$cannot instantiate %r on your system) rrrwrrrrrrrC)rrkwargsr+rrrrs z Path.__new__cCs|j|g}||j|j|Sr')rrrr)r+r=r9rrrrs zPath._make_child_relpathcCr%r'rr*rrr __enter__rzPath.__enter__cCsdSr'r)r+tvtbrrr__exit__s z Path.__exit__cCs||jS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )rrrrrrcwdszPath.cwdcCs |dS)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). ~)rrNrrrhome z Path.homecCsB|}z|}Wnty|j|}Ynwtj||S)zoReturn whether other_path is the same or not as this file (as returned by os.path.samefile()). )rrrrr}samestat)r+Z other_pathstZother_strrrsamefiles  z Path.samefileccs.|j|D] }|dvrq||VqdS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. >r/z..N)rrrr.rrriterdirs z Path.iterdirccsptd|||std||j|f\}}}|s|r#tdtt||j}| |D]}|Vq0dS)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) r6auditrrrr?rrrrr+rnr:r;rZselectorrcrrrglobsz Path.globccsbtd|||j|f\}}}|s|rtdtdt||j}||D]}|Vq)dS)zRecursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. zpathlib.Path.rglobrW)rN)r6rXrr?rrrrrYrrrrglob sz Path.rglobcCs$|r|S||jg|jS)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. )rrrrrr*rrrabsolutesz Path.absoluteFc Csdd}z |jj||d}Wnty}z||d}~ww||f}|sGz|W|StyF}z ||WYd}~|Sd}~ww|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|tkrtd|jdS)NrrzSymlink loop from %r)rrr_WINERROR_CANT_RESOLVE_FILENAME RuntimeErrorfilename)rrrrr check_eloop/s z!Path.resolve..check_eloop)strictN)rrrrr)r+rar`rarrcrrrresolve(s&  z Path.resolveTfollow_symlinkscCs|jj||dS)zh Return the result of the stat() system call on this path, like os.stat() does. rc)rr)r+rdrrrrDsz Path.statcC |j|S)z: Return the login name of the file owner. )rrr*rrrrK z Path.ownercCre)z8 Return the group name of the file gid. )rrr*rrrrQrfz Path.grouprrSNcCs(d|vr t|}|j||||||S)z| Open the file pointed by this path and return a file object, as the built-in open() function does. b)r text_encodingrr)r+r bufferingencodingerrorsnewlinerrrrWs  z Path.opencCs8|jdd }|WdS1swYdS)zK Open the file in bytes mode, read it, and close the file. rbrN)rreadrrrr read_bytesbs$zPath.read_bytescCsFt|}|jd||d }|WdS1swYdS)zJ Open the file in text mode, read it, and close the file. rg)rrkrlN)rrirrp)r+rkrlrrrr read_textis $zPath.read_textcCsBt|}|jdd }||WdS1swYdS)zO Open the file in bytes mode, write to it, and close the file. wbroN) memoryviewrwrite)r+dataZviewrrrr write_bytesqs$zPath.write_bytescCsdt|ts td|jjt|}|jd|||d }||WdS1s+wYdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %sw)rrkrlrmN) rrrrrCrrirru)r+rvrkrlrmrrrr write_textzs  $zPath.write_textcCs|j|}||fS)zD Return the path to which the symbolic link points. )rrrrrrrrs  z Path.readlinkrcCs|j|||dS)zS Create this file with the given access mode, if it doesn't exist. N)rr)r+rrrrrrsz Path.touchcCszz |j||WdSty,|r|j|kr|jjddd|j|d|dYdSty<|r8|s9YdSw)z< Create a new directory at this given path. T)r?rFN)rrFileNotFoundErrorr>rr)r+rr?rrrrrs   z Path.mkdircCs|jj|||ddS)zF Change the permissions of the path, like os.chmod(). rcN)rr)r+rrdrrrrsz Path.chmodcCs|j|dddS)z Like chmod(), except if the path points to a symlink, the symlink's permissions are changed, rather than its target's. FrcN)r)r+rrrrlchmodsz Path.lchmodcCs.z |j|WdSty|sYdSw)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)rrr{)r+Z missing_okrrrrs z Path.unlinkcCs|j|dS)zF Remove this directory. The directory must be empty. N)rrr*rrrrsz Path.rmdircCs |jddS)z Like stat(), except if the path points to a symlink, the symlink's status information is returned, rather than its target's. Frc)rr*rrrlstatrRz Path.lstatcC|j||||S)a2 Rename this path to the target path. The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, *not* the directory of the Path object. Returns the new Path instance pointing to the target path. )rrrr+targetrrrr z Path.renamecCr~)aS Rename this path to the target path, overwriting if that path exists. The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, *not* the directory of the Path object. Returns the new Path instance pointing to the target path. )rr2rrrrrr2rz Path.replacecCs|j|||dS)z Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink. N)rr)r+rrrrr symlink_toszPath.symlink_tocCs|j||dS)z Make this path a hard link pointing to the same file as *target*. Note the order of arguments (self, target) is the reverse of os.link's. N)rrrrrr hardlink_toszPath.hardlink_tocCs"tjdtdd|j||dS)a Make the target path a hard link pointing to this path. Note this function does not make this path a hard link to *target*, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link. Deprecated since Python 3.10 and scheduled for removal in Python 3.12. Use `hardlink_to()` instead. zypathlib.Path.link_to() is deprecated and is scheduled for removal in Python 3.12. Use pathlib.Path.hardlink_to() instead.rQ) stacklevelN)warningswarnDeprecationWarningrrrrrrlink_tos z Path.link_toc CsRz|WdSty}z t|sWYd}~dSd}~wty(YdSw)z+ Whether this path exists. NFT)rrr rr+rrrrrs  z Path.existsc CTzt|jWSty }z t|sWYd}~dSd}~wty)YdSw)z3 Whether this path is a directory. NF)r rst_moderr rrrrrr z Path.is_dirc Cr)zq Whether this path is a regular file (also True for symlinks pointing to regular files). NF)r rrrr rrrrris_file$s z Path.is_filecCsn|r|s dSz|jj}Wn tyYdSw|j}||kr(dS|j}|jj}||kS)z; Check if this path is a POSIX mount point FT)rrr>rst_devrst_ino)r+Z parent_devZdevZinoZ parent_inorrris_mount5s    z Path.is_mountc Cr)z7 Whether this path is a symbolic link. NF)r r}rrr rrrrrrIs zPath.is_symlinkc Cr)z6 Whether this path is a block device. NF)r rrrr rrrrris_block_deviceXrzPath.is_block_devicec Cr)z: Whether this path is a character device. NF)rrrrr rrrrris_char_devicehrzPath.is_char_devicec Cr)z. Whether this path is a FIFO. NF)rrrrr rrrrris_fifoxrz Path.is_fifoc Cr)z0 Whether this path is a socket. NF)r rrrr rrrrr is_socketrzPath.is_socketcCsp|js6|js6|jr6|jddddkr6|j|jd}|dddkr)td||g|jddS|S)zl Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) rNr@rPz#Could not determine home directory.)rrrrrr^r)r+Zhomedirrrrrs zPath.expanduserr)rgrSNNN)NN)NNNr)rzFF)3rCrDrErF_normal_accessorrrrrrIrMrBrOrQrUrVrZr[r\rbrrrrrqrrrwryrrrrr|rrr}rr2rrrrrrrrrrrrrrrrrrsf               rc@seZdZdZdZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. rN)rCrDrErFrrrrrrsrc@seZdZdZdZddZdS)rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. rcCr)Nz-Path.is_mount() is unsupported on this systemrr*rrrrrbzWindowsPath.is_mountN)rCrDrErFrrrrrrrs r)@ri functoolsrrrrrgr6r_collections_abcrrrrrrroperatorrrr r r r r rrZ urllib.parserr{__all__Z_WINERROR_NOT_READYZ_WINERROR_INVALID_NAMEr]rrr r%r r&rGrrGrErrrrrrrrrrrrrPathLikeregisterrrrrrrrrrsl  $   ?w*O ,! }  x