U e5d‚Íã@sjddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejdkræddlZe  ¡dd …d krÜdd lm!Z!qêd ZdZ!ndZd dddddgZ"e e eefZ#dZ$dd„Z%dd„Z&Gdd„de'ƒZ(Gdd„de(ƒZ)Gdd„de(ƒZ*e)ƒZ+e*ƒZ,Gdd„dƒZ-Gd d!„d!e-ƒZ.e.ƒZ/d"d#„Z0e1ed$ƒ�rše 2¡e0ƒZ0Gd%d&„d&ƒZ3Gd'd(„d(ƒZ4Gd)d*„d*e3ƒZ5Gd+d,„d,e3ƒZ6Gd-d.„d.e3ƒZ7Gd/d0„d0e ƒZ8Gd1d „d e'ƒZ9ej: ;e9¡Gd2d„de9ƒZGd5d„de>e<ƒZ?Gd6d„de>e=ƒZ@dS)7éN)ÚSequence)ÚEINVALÚENOENTÚENOTDIRÚEBADFÚELOOP)Ú attrgetter)ÚS_ISDIRÚS_ISLNKÚS_ISREGÚS_ISSOCKÚS_ISBLKÚS_ISCHRÚS_ISFIFO)Úquote_from_bytesTÚnté)ér)Ú_getfinalpathnameFÚPurePathÚ PurePosixPathÚPureWindowsPathÚPathÚ PosixPathÚ WindowsPath)éé{i�cCs t|ddƒtkpt|ddƒtkS)NÚerrnoZwinerror)ÚgetattrÚ_IGNORED_ERROSÚ_IGNORED_WINERRORS)Z exception©r!ú/usr/lib64/python3.8/pathlib.pyÚ _ignore_error.sÿr#cCsd|kpd|kpd|kS)NÚ*ú?ú[r!)Úpatr!r!r"Ú_is_wildcard_pattern3sr(c@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú_FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dS©N)ÚsepÚjoin©Úselfr!r!r"Ú__init__=sz_Flavour.__init__c Csg}|j}|j}d}}t|ƒ}|D]Æ}|s.q$|r>| ||¡}| |¡\}}} || krˆt|  |¡ƒD] } | rd| dkrd| t | ¡¡qdn| r¤| dkr¤| t | ¡¡|s¬|r$|sæ|D]0}|s¾q´|rÎ| ||¡}| |¡d}|r´qæq´qìq$|sö|�r| ||¡|  ¡|||fS)NÚÚ.r) r+ÚaltsepÚreversedÚreplaceÚ splitrootÚsplitÚappendÚsysÚinternÚreverse) r.ÚpartsZparsedr+r2ÚdrvÚrootÚitÚpartZrelÚxr!r!r"Ú parse_parts@s@     z_Flavour.parse_partscCsz|r*|sp|rp||||g|dd…fSnF|rb||ksJ| |¡| |¡krp||||dd…fSn||||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;Zdrv2Zroot2Zparts2r!r!r"Újoin_parsed_partsfsz_Flavour.join_parsed_partsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r/rArDr!r!r!r"r)9s&r)c@sÀeZdZdZdZdZeZej dkZ e dƒZ dZ ddd d hd d „ed dƒDƒBdd „ed dƒDƒBZefdd„Zdd„Zdd„Zdd„Zd&dd„Ze fdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%S)'Ú_WindowsFlavourú\ú/TrZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\ZCONZPRNZAUXZNULcCsh|] }d|’qS)zCOM%dr!©Ú.0Úir!r!r"Ú ˆsz_WindowsFlavour.rBé cCsh|] }d|’qS)zLPT%dr!rLr!r!r"rO‰sc Cs\|dd…}|dd…}||krP||krP| |¡\}}|dd…}|dd…}nd}|dd…}||krü||krü||krü| |d¡}|dkrü| ||d¡}||dkrü|dkr¸t|ƒ}|rÞ||d|…|||dd…fS|d|…|||dd…fSd} } |dk�r6||jk�r6|dd…} |dd…}|}||k�rN|} | |¡}|| | |fS)NrrBrr0ééÿÿÿÿú:)Ú_split_extended_pathÚfindÚlenÚ drive_lettersÚlstrip) r.r?r+ÚfirstÚsecondÚprefixZthirdÚindexZindex2r<r=r!r!r"r5’s6      "    z_WindowsFlavour.splitrootcCs| ¡Sr*©Úlower©r.Úsr!r!r"rC¹sz_WindowsFlavour.casefoldcCsdd„|DƒS)NcSsg|] }| ¡‘qSr!r])rMÚpr!r!r"Ú ½sz2_WindowsFlavour.casefold_parts..r!©r.r;r!r!r"Úcasefold_parts¼sz_WindowsFlavour.casefold_partscCst t |¡tj¡jSr*)ÚreÚcompileÚfnmatchÚ translateÚ IGNORECASEÚ fullmatch©r.Úpatternr!r!r"Úcompile_pattern¿sz_WindowsFlavour.compile_patternFcCs¨t|ƒ}|st ¡Sd}tdk r¤|r2| t|ƒ¡Sg}z| t|ƒ¡}WnBtk rŠ|}tj |¡\}}| |¡||kr†|YSYq6Xtjj |ft |ƒžŽSq6dSr*) ÚstrÚosÚgetcwdrÚ_ext_to_normalÚFileNotFoundErrorÚpathr6r7r,r3)r.rsÚstrictr`Z previous_sZ tail_partsÚtailr!r!r"ÚresolveÂs$ z_WindowsFlavour.resolvecCsXd}| |¡rP|dd…}|dd…}| d¡rP||dd…7}d|dd…}||fS)Nr0ézUNC\rQrJ)Ú startswith)r.r`Z ext_prefixr[r!r!r"rTÚs    z$_WindowsFlavour._split_extended_pathcCs| |¡dS©NrB)rTr_r!r!r"rqäsz_WindowsFlavour._ext_to_normalcCs6|sdS|d d¡rdS|d d¡d ¡|jkS)NFrz\\rRr1)rxÚ partitionÚupperÚreserved_namesrcr!r!r"Ú is_reservedès z_WindowsFlavour.is_reservedcCsd|j}t|ƒdkrJ|ddkrJ| ¡dd… d¡}d|t| d¡ƒfSdt| ¡ d¡ƒSdS)NrrBrSrKz file:///%s/%szutf-8zfile:)ÚdriverVÚas_posixrXÚurlquote_from_bytesÚencode)r.rsr~Úrestr!r!r"Úmake_uriôs ÿz_WindowsFlavour.make_uricCsÜdtjkrtjd}nJdtjkrXztjd}Wntk rFd}YnX|tjd}ntdƒ‚|rØtjd|krØ| |f¡\}}}|dtjdkr¢td|ƒ‚||d<|s²|rÎ||| |d d…¡}n | |¡}|S) NZ USERPROFILEZHOMEPATHZ HOMEDRIVEr0zCan't determine home directoryZUSERNAMErRú%Can't determine home directory for %rrB)roÚenvironÚKeyErrorÚ RuntimeErrorrAr,)r.ÚusernameÚuserhomer<r=r;r!r!r"Ú gethomedirs*    ÿ z_WindowsFlavour.gethomedirN)F)rErFrGr+r2Úhas_drvÚntpathÚpathmodroÚnameÚ is_supportedÚsetrWZext_namespace_prefixÚranger|r5rCrdrmrvrTrqr}rƒrŠr!r!r!r"rIxs.  ÿþÿ '    rIc@sleZdZdZdZdZeZej dkZ efdd„Z dd„Z d d „Z d d „Zdd d„Zdd„Zdd„Zdd„ZdS)Ú _PosixFlavourrKr0FrcCsV|rH|d|krH| |¡}t|ƒt|ƒdkr._resolver0)r+Ú _accessorÚ is_absoluterorprn)r.rsrtÚbaser!rœr"rv=s )z_PosixFlavour.resolvecCsdS©NFr!rcr!r!r"r}msz_PosixFlavour.is_reservedcCst|ƒ}dt|ƒS)Nzfile://)Úbytesr€)r.rsZbpathr!r!r"rƒpsz_PosixFlavour.make_uricCs||s@z tjdWStk r<ddl}| t ¡¡jYSXn8ddl}z| |¡jWStk rvtd|ƒ‚YnXdS)NÚHOMErr„) ror…r†ÚpwdÚgetpwuidÚgetuidÚpw_dirÚgetpwnamr‡)r.rˆr¥r!r!r"rŠvs ÿz_PosixFlavour.gethomedirN)F)rErFrGr+r2r‹Ú posixpathr�rorŽr�r5rCrdrmrvr}rƒrŠr!r!r!r"r’s   0r’c@seZdZdZdS)Ú _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)rErFrGrHr!r!r!r"r«Šsr«c@sºeZdZejZejZejZejZejZej Z e edƒr>ej Z ndd„Z ej Z ej Z e edƒrdejZn edd„ƒZejZejZejZerœer’ejZq¨dd„Zn ed d„ƒZejZd d „Zd S) Ú_NormalAccessorÚlchmodcCs tdƒ‚dS)Nz%lchmod() not available on this system©ÚNotImplementedError)r.ZpathobjÚmoder!r!r"r­ sz_NormalAccessor.lchmodÚlinkcCs tdƒ‚dS)Nz&os.link() not available on this systemr®©r.ršr!r!r"Úlink_toªsz_NormalAccessor.link_tocCs tdƒ‚dS)Nz&symlink() not available on this systemr®©ÚaÚbÚtarget_is_directoryr!r!r"Úsymlink¸sz_NormalAccessor.symlinkcCs t ||¡Sr*)ror¸r´r!r!r"r¸¼scCs t |¡Sr*)ror–©r.rsr!r!r"r–Ãsz_NormalAccessor.readlinkN)rErFrGroÚstatÚlstatÚopenÚlistdirÚscandirÚchmodÚhasattrr­ÚmkdirÚunlinkr±r³Ú staticmethodÚrmdirÚrenamer4rÚsupports_symlinksr¸Úutimer–r!r!r!r"r¬�s4     r¬cCsR|d}|dd…}|dkr"t}n$d|kr4tdƒ‚nt|ƒrBt}nt}||||ƒS)NrrBú**z:Invalid pattern: '**' can only be an entire path component)Ú_RecursiveWildcardSelectorÚ ValueErrorr(Ú_WildcardSelectorÚ_PreciseSelector)Ú pattern_partsÚflavourr'Ú child_partsÚclsr!r!r"Ú_make_selectorÎs  rÑÚ lru_cachec@s eZdZdZdd„Zdd„ZdS)Ú _SelectorzYA selector matches a specific glob pattern part against the children of a given path.cCs0||_|rt||ƒ|_d|_ntƒ|_d|_dS)NTF)rÏrÑÚ successorÚdironlyÚ_TerminatingSelector)r.rÏrÎr!r!r"r/ãs  z_Selector.__init__cCs<t|ƒ}|j}|j}|jj}||ƒs,tgƒS| ||||¡S)zuIterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.)ÚtypeÚis_dirÚexistsrŸr¾ÚiterÚ _select_from)r.Ú parent_pathZpath_clsrØrÙr¾r!r!r"Ú select_fromìsz_Selector.select_fromN)rErFrGrHr/rÝr!r!r!r"rÓßs rÓc@seZdZdd„ZdS)rÖccs |VdSr*r!)r.rÜrØrÙr¾r!r!r"rÛúsz!_TerminatingSelector._select_fromN)rErFrGrÛr!r!r!r"rÖøsrÖc@seZdZdd„Zdd„ZdS)rÌcCs||_t |||¡dSr*)rŽrÓr/)r.rŽrÏrÎr!r!r"r/sz_PreciseSelector.__init__ccs\z@| |j¡}|jr|n||ƒr>|j ||||¡D] }|Vq2Wntk rVYdSXdSr*)Ú_make_child_relpathrŽrÕrÔrÛÚPermissionError)r.rÜrØrÙr¾rsrar!r!r"rÛs  z_PreciseSelector._select_fromN©rErFrGr/rÛr!r!r!r"rÌþsrÌc@seZdZdd„Zdd„ZdS)rËcCs| |¡|_t |||¡dSr*)rmÚmatchrÓr/©r.r'rÏrÎr!r!r"r/s z_WildcardSelector.__init__c csÊz®||ƒ�}t|ƒ}W5QRX|D]ˆ}|jrrz| ¡s:Wq"Wn4tk rp}zt|ƒsX‚WY¢q"W5d}~XYnX|j} | | ¡r"| | ¡} |j  | |||¡D] } | Vqžq"Wnt k rÄYdSXdSr*) ÚlistrÕrØr—r#rŽrárÞrÔrÛrß) r.rÜrØrÙr¾Ú scandir_itÚentriesÚentryr›rŽrsrar!r!r"rÛs&   z_WildcardSelector._select_fromNràr!r!r!r"rËsrËc@s$eZdZdd„Zdd„Zdd„ZdS)rÉcCst |||¡dSr*)rÓr/râr!r!r"r//sz#_RecursiveWildcardSelector.__init__c cs¼|Vzš||ƒ�}t|ƒ}W5QRX|D]t}d}z | ¡}Wn,tk rh}zt|ƒsX‚W5d}~XYnX|r(| ¡s(| |j¡} | | ||¡D] } | Vq�q(Wntk r¶YdSXdSr¢) rãrØr—r#Ú is_symlinkrÞrŽÚ_iterate_directoriesrß) r.rÜrØr¾räråræZ entry_is_dirr›rsrar!r!r"rè2s"    z/_RecursiveWildcardSelector._iterate_directoriesc cs~zbtƒ}zL|jj}| |||¡D]0}|||||ƒD]}||kr2|V| |¡q2q W5| ¡XWntk rxYdSXdSr*)r�ÚclearrÔrÛrèÚaddrß) r.rÜrØrÙr¾ZyieldedZsuccessor_selectZstarting_pointrar!r!r"rÛEsz'_RecursiveWildcardSelector._select_fromN)rErFrGr/rèrÛr!r!r!r"rÉ-srÉc@s4eZdZdZdZdd„Zdd„Zdd„Zd 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*)r×rìrírîrïr¹r!r!r"r/^s z_PathParents.__init__cCs(|js |jrt|jƒdSt|jƒSdSry)rírîrVrïr-r!r!r"Ú__len__es z_PathParents.__len__cCs@|dks|t|ƒkrt|ƒ‚|j |j|j|jd| d…¡S)NrrB)rVÚ IndexErrorrìÚ_from_parsed_partsrírîrï)r.Úidxr!r!r"Ú __getitem__ks ÿz_PathParents.__getitem__cCsd |jj¡S)Nz <{}.parents>)ÚformatrìrEr-r!r!r"Ú__repr__qsz_PathParents.__repr__N) rErFrGrHÚ __slots__r/rðrôrör!r!r!r"rëYs rëc@sœeZdZdZdZdd„Zdd„Zedd„ƒZedVd d „ƒZ edWd d „ƒZ edd„ƒZ dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zed d!„ƒZd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zeed.ƒd/d0�Zeed1ƒd2d0�Zed3d4„ƒZed5d6„ƒZ ed7d8„ƒZ!ed9d:„ƒZ"ed;d<„ƒZ#d=d>„Z$d?d@„Z%dAdB„Z&edCdD„ƒZ'dEdF„Z(dGdH„Z)dIdJ„Z*edKdL„ƒZ+edMdN„ƒZ,dOdP„Z-dQdR„Z.dSdT„Z/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. )rírîrïÚ_strÚ_hashÚ_ppartsÚ_cached_cpartscGs$|tkrtjdkrtnt}| |¡S)z÷Construct 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)rrorŽrrÚ _from_parts)rÐÚargsr!r!r"Ú__new__ƒszPurePath.__new__cCs|jt|jƒfSr*)Ú __class__Útuplerïr-r!r!r"Ú __reduce__�szPurePath.__reduce__cCsdg}|D]N}t|tƒr"||j7}qt |¡}t|tƒrF| t|ƒ¡qtdt|ƒƒ‚q|j   |¡S)NzNargument should be a str object or an os.PathLike object returning str, not %r) Ú isinstancerrïroÚfspathrnr7Ú TypeErrorr×Ú_flavourrA)rÐrýr;rµr!r!r"Ú _parse_args’s    þÿzPurePath._parse_argsTcCs<t |¡}| |¡\}}}||_||_||_|r8| ¡|Sr*)ÚobjectrþrrírîrïÚ_init)rÐrýÚinitr.r<r=r;r!r!r"rü¦s zPurePath._from_partscCs,t |¡}||_||_||_|r(| ¡|Sr*)rrþrírîrïr)rÐr<r=r;r r.r!r!r"rò³s zPurePath._from_parsed_partscCs4|s|r$|||j |dd…¡S|j |¡SdSry)rr,)rÐr<r=r;r!r!r"Ú_format_parsed_parts½szPurePath._format_parsed_partscCsdSr*r!r-r!r!r"rÄszPurePath._initcCs@| |¡\}}}|j |j|j|j|||¡\}}}| |||¡Sr*)rrrDrírîrïrò)r.rýr<r=r;r!r!r"Ú _make_childÈsÿ zPurePath._make_childcCsBz|jWStk r<| |j|j|j¡p.d|_|jYSXdS)z[Return the string representation of the path, suitable for passing to system calls.r1N)røÚAttributeErrorr rírîrïr-r!r!r"Ú__str__Îs ÿÿzPurePath.__str__cCst|ƒSr*)rnr-r!r!r"Ú __fspath__ØszPurePath.__fspath__cCs|j}t|ƒ |jd¡S)zNReturn the string representation of the path with forward (/) slashes.rK)rrnr4r+©r.Úfr!r!r"rÛszPurePath.as_posixcCs t |¡S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)roÚfsencoder-r!r!r"Ú __bytes__ászPurePath.__bytes__cCsd |jj| ¡¡S)Nz{}({!r}))rõrÿrErr-r!r!r"röæszPurePath.__repr__cCs| ¡stdƒ‚|j |¡S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)r rÊrrƒr-r!r!r"Úas_uriészPurePath.as_uricCs8z|jWStk r2|j |j¡|_|jYSXdSr*)rûr rrdrïr-r!r!r"Ú_cpartsïs zPurePath._cpartscCs&t|tƒstS|j|jko$|j|jkSr*)rrÚNotImplementedrr©r.Úotherr!r!r"Ú__eq__øs zPurePath.__eq__cCs8z|jWStk r2tt|jƒƒ|_|jYSXdSr*)rùr Úhashrrr-r!r!r"Ú__hash__ýs zPurePath.__hash__cCs&t|tƒr|j|jk rtS|j|jkSr*©rrrrrrr!r!r"Ú__lt__szPurePath.__lt__cCs&t|tƒr|j|jk rtS|j|jkSr*rrr!r!r"Ú__le__ szPurePath.__le__cCs&t|tƒr|j|jk rtS|j|jkSr*rrr!r!r"Ú__gt__szPurePath.__gt__cCs&t|tƒr|j|jk rtS|j|jkSr*rrr!r!r"Ú__ge__szPurePath.__ge__ríz.The drive prefix (letter or UNC path), if any.)ÚdocrîzThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)rírî)r.Úanchorr!r!r"r!s zPurePath.anchorcCs.|j}t|ƒ|js|jrdndkr&dS|dS)z!The final path component, if any.rBrr0rR)rïrVrírîrcr!r!r"rŽ$sz PurePath.namecCsD|j}| d¡}d|kr,t|ƒdkr.rBN)rŽr•rXr6©r.rŽr!r!r"Úsuffixes:s   zPurePath.suffixescCsD|j}| d¡}d|kr,t|ƒdkrd?„Z d@dA„Z!dmdBdC„Z"dDdE„Z#dFdG„Z$dHdI„Z%dJdK„Z&dndLdM„Z'dNdO„Z(dPdQ„Z)dRdS„Z*dTdU„Z+dVdW„Z,dXdY„Z-dZd[„Z.d\d]„Z/d^d_„Z0d`da„Z1dbdc„Z2dS)ora¡PurePath 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©r z$cannot instantiate %r on your system) rrorŽrrrürr�r¯rEr)rÐrýÚkwargsr.r!r!r"rþsÿz Path.__new__NcCs"d|_|dk r|j|_nt|_dSr¢)r<rŸÚ_normal_accessor)r.Útemplater!r!r"rs z Path._initcCs|j|g}| |j|j|¡Sr*)rïròrírî)r.r?r;r!r!r"rÞ#s zPath._make_child_relpathcCs|jr| ¡|Sr*)r<Ú _raise_closedr-r!r!r"Ú __enter__)szPath.__enter__cCs d|_dS)NT)r<)r.ÚtÚvÚtbr!r!r"Ú__exit__.sz Path.__exit__cCs tdƒ‚dS)NzI/O operation on closed path)rÊr-r!r!r"rA1szPath._raise_closedé¶cCs|j |||¡Sr*)rŸr¼)r.rŽÚflagsr°r!r!r"Ú_opener4sz Path._openeréÿcCs|jr| ¡|j |||¡S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. )r<rArŸr¼)r.rHr°r!r!r"Ú _raw_open8szPath._raw_opencCs |t ¡ƒS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )rorp©rÐr!r!r"ÚcwdCszPath.cwdcCs||ƒj d¡ƒS)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)rrŠrLr!r!r"ÚhomeJsz Path.homecCsB| ¡}z | ¡}Wntk r2t |¡}YnXtj ||¡S)zoReturn whether other_path is the same or not as this file (as returned by os.path.samefile()). )rºr rorsÚsamestat)r.Z other_pathÚstZother_str!r!r"ÚsamefileQs  z Path.samefileccsH|jr| ¡|j |¡D](}|dkr(q| |¡V|jr| ¡qdS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. >r1r“N)r<rArŸr½rÞr&r!r!r"Úiterdir\s z Path.iterdirccs`|std |¡ƒ‚|j |f¡\}}}|s.|r6tdƒ‚tt|ƒ|jƒ}| |¡D] }|VqPdS)z‘Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern. zUnacceptable pattern: {!r}ú%Non-relative patterns are unsupportedN)rÊrõrrAr¯rÑrrÝ©r.rlr<r=rÍZselectorrar!r!r"Úglobjsz Path.globccsR|j |f¡\}}}|s|r$tdƒ‚tdt|ƒ|jƒ}| |¡D] }|VqBdS)z¡Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. rS)rÈN)rrAr¯rÑrrÝrTr!r!r"Úrglobws z Path.rglobcCsD|jr| ¡| ¡r|S|jt ¡g|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. Fr=©r@)r<rAr rürorprïr)r.Úobjr!r!r"Úabsoluteƒs 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). )rtNFr=rW) r<rArrvrºrnrYr�Únormpathrür)r.rtr`ZnormedrXr!r!r"rv•s  z Path.resolvecCs |j |¡S)zh Return the result of the stat() system call on this path, like os.stat() does. )rŸrºr-r!r!r"rº©sz Path.statcCsddl}| | ¡j¡jS)z: Return the login name of the file owner. rN)r¥r¦rºÚst_uidZpw_name)r.r¥r!r!r"Úowner°sz Path.ownercCsddl}| | ¡j¡jS)z8 Return the group name of the file gid. rN)ÚgrpZgetgrgidrºÚst_gidZgr_name)r.r]r!r!r"Úgroup·sz Path.groupÚrrRc Cs(|jr| ¡tj|||||||jd�S)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )Zopener)r<rAÚior¼rI)r.r°Ú bufferingÚencodingÚerrorsÚnewliner!r!r"r¼¾s ÿz Path.openc Cs,|jdd��}| ¡W5QR£SQRXdS)zK Open the file in bytes mode, read it, and close the file. Úrb©r°N©r¼Úreadrr!r!r"Ú read_bytesÉszPath.read_bytesc Cs0|jd||d��}| ¡W5QR£SQRXdS)zJ Open the file in text mode, read it, and close the file. r`©r°rcrdNrh)r.rcrdrr!r!r"Ú read_textÐszPath.read_textc Cs6t|ƒ}|jdd��}| |¡W5QR£SQRXdS)zO Open the file in bytes mode, write to it, and close the file. ÚwbrgN)Ú memoryviewr¼Úwrite)r.ÚdataZviewrr!r!r"Ú write_bytes×szPath.write_bytesc CsLt|tƒstd|jjƒ‚|jd||d��}| |¡W5QR£SQRXdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %sÚwrkN)rrnrrÿrEr¼ro)r.rprcrdrr!r!r"Ú write_textàs  ÿzPath.write_textTcCsr|jr| ¡|r>z|j |d¡Wntk r8YnXdStjtjB}|sX|tjO}|  ||¡}t  |¡dS)zS Create this file with the given access mode, if it doesn't exist. N) r<rArŸrÇr—roÚO_CREATÚO_WRONLYÚO_EXCLrKÚclose)r.r°Úexist_okrHÚfdr!r!r"Útouchês   z Path.touchcCsŠ|jr| ¡z|j ||¡Wndtk rd|r>|j|kr@‚|jjddd�|j|d|d�Yn"tk r„|r~| ¡s€‚YnXdS)z< Create a new directory at this given path. T)r5rxFN)r<rArŸrÁrrr4r—rØ)r.r°r5rxr!r!r"rÁs z Path.mkdircCs |jr| ¡|j ||¡dS)zF Change the permissions of the path, like os.chmod(). N)r<rArŸr¿©r.r°r!r!r"r¿sz 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)r<rArŸr­r{r!r!r"r­sz Path.lchmodcCs>|jr| ¡z|j |¡Wntk r8|s4‚YnXdS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)r<rArŸrÂrr)r.Z missing_okr!r!r"rÂ%sz Path.unlinkcCs|jr| ¡|j |¡dS)zF Remove this directory. The directory must be empty. N)r<rArŸrÄr-r!r!r"rÄ2sz 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. )r<rArŸr»r-r!r!r"r»:sz Path.lstatcCs&|jr| ¡|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. )r<rArŸrÅrÿr²r!r!r"rÅCs z Path.renamecCs&|jr| ¡|j ||¡| |¡S)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. )r<rArŸr4rÿr²r!r!r"r4Rs z Path.replacecCs"|jr| ¡|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)r<rArŸr¸)r.ršr·r!r!r"Ú symlink_toaszPath.symlink_tocCs |jr| ¡|j ||¡dS)aQ 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. N)r<rArŸr³r²r!r!r"r³js z Path.link_toc CsXz | ¡WnFtk r>}zt|ƒs(‚WY¢dSd}~XYntk rRYdSXdS)z+ Whether this path exists. FNT)rºr—r#rÊ©r.r›r!r!r"rÙzs z Path.existsc Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)z3 Whether this path is a directory. FN)r rºÚst_moder—r#rÊr}r!r!r"r؉sz Path.is_dirc Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). FN)r rºr~r—r#rÊr}r!r!r"Úis_file™sz Path.is_filecCsv| ¡r| ¡sdSt|jƒ}z| ¡j}Wntk rBYdSX| ¡j}||krZdS| ¡j}| ¡j}||kS)z; Check if this path is a POSIX mount point FT)rÙrØrr4rºÚst_devr—Úst_ino)r.r4Z parent_devZdevZinoZ parent_inor!r!r"Úis_mountªs    z Path.is_mountc Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)z7 Whether this path is a symbolic link. FN)r r»r~r—r#rÊr}r!r!r"rç¿szPath.is_symlinkc Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)z6 Whether this path is a block device. FN)r rºr~r—r#rÊr}r!r!r"Úis_block_deviceÎszPath.is_block_devicec Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)z: Whether this path is a character device. FN)rrºr~r—r#rÊr}r!r!r"Úis_char_deviceÞszPath.is_char_devicec Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)z. Whether this path is a FIFO. FN)rrºr~r—r#rÊr}r!r!r"Úis_fifoîsz Path.is_fifoc Cs\zt| ¡jƒWStk rB}zt|ƒs,‚WY¢dSd}~XYntk rVYdSXdS)z0 Whether this path is a socket. FN)r rºr~r—r#rÊr}r!r!r"Ú is_socketþszPath.is_socketcCs`|js\|js\|jr\|jddd…dkr\|j |jddd…¡}| |g|jdd…¡S|S)zl Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) rNrBú~)rírîrïrrŠrü)r.Zhomedirr!r!r"Ú expandusers ÿÿzPath.expanduser)N)rG)rJ)F)r`rRNNN)NN)NN)rGT)rJFF)F)F)3rErFrGrHr÷rþrrÞrBrFrArIrKr8rMrNrQrRrUrVrYrvrºr\r_r¼rjrlrqrsrzrÁr¿r­rÂrÄr»rÅr4r|r³rÙrØrr‚rçrƒr„r…r†rˆr!r!r!r"rsj þ         ÿ       c@seZdZdZdZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. r!N)rErFrGrHr÷r!r!r!r"rsc@s,eZdZdZdZdd„Zdd„Zdd„Zd S) rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. r!cCs tdƒ‚dS)Nz*Path.owner() is unsupported on this systemr®r-r!r!r"r\(szWindowsPath.ownercCs tdƒ‚dS)Nz*Path.group() is unsupported on this systemr®r-r!r!r"r_+szWindowsPath.groupcCs tdƒ‚dS)Nz-Path.is_mount() is unsupported on this systemr®r-r!r!r"r‚.szWindowsPath.is_mountN)rErFrGrHr÷r\r_r‚r!r!r!r"r!s )ArgÚ functoolsrarŒrorªrer8Ú_collections_abcrrrrrrrÚoperatorrrºr r r r r rrZ urllib.parserr€rÆrŽrZgetwindowsversionrÚ__all__rr r#r(rr)rIr’r;r:r«r¬r?rÑrÀrÒrÓrÖrÌrËrÉrërÚPathLikeÚregisterrrrrrr!r!r!r"Ús|  $  þ ?&i8  ,t