grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/20263 ¥ fV¿ã@sVddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejd krêddlZej ƒdd …d5kràdd lm!Z!qîd ZdZ!ndZddddddgZ"dd„Z#Gdd„de$ƒZ%Gdd„de%ƒZ&Gdd„de%ƒZ'e&ƒZ(e'ƒZ)Gdd„dƒZ*Gdd„de*ƒZ+e+ƒZ,d d!„Z-e.ed"ƒ�r†ej/ƒe-ƒZ-Gd#d$„d$ƒZ0Gd%d&„d&ƒZ1Gd'd(„d(e0ƒZ2Gd)d*„d*e0ƒZ3Gd+d,„d,e0ƒZ4Gd-d.„d.e ƒZ5Gd/d„de$ƒZ6ej7j8e6ƒGd0d„de6ƒZ9Gd1d„de6ƒZ:Gd2d„de6ƒZ;Gd3d„de;e9ƒZwsz_WindowsFlavour.ÚaÚzr8ccs|]}t|ƒVqdS)N)rB)rCr6rrrrDxsÚAÚZz\\?\ZCONZPRNZAUXZNULcCsh|] }d|’qS)zCOM%dr)rCÚirrrú ~sz_WindowsFlavour.é cCsh|] }d|’qS)zLPT%dr)rCrIrrrrJsc Csb|dd…}|dd…}||krP||krP|j|ƒ\}}|dd…}|dd…}nd}|dd…}||kov||kov||k�r|j|dƒ}|dk�r|j||dƒ}||dk�r|dkr¾t|ƒ}|rä||d|…|||dd…fS|d|…|||dd…fSd} } |dk�r<||jk�r<|dd…} |dd…}|}||k�rT|} |j|ƒ}|| | |fS) Nrr8rr&éú:éÿÿÿÿrN)Ú_split_extended_pathÚfindÚlenÚ drive_lettersÚlstrip) r$r5r"ÚfirstÚsecondÚprefixZthirdÚindexZindex2r2r3rrrr+ˆs6      "    z_WindowsFlavour.splitrootcCs|jƒS)N)Úlower)r$Úsrrrr9¯sz_WindowsFlavour.casefoldcCsdd„|DƒS)NcSsg|] }|jƒ‘qSr)rX)rCÚprrrú ³sz2_WindowsFlavour.casefold_parts..r)r$r1rrrÚcasefold_parts²sz_WindowsFlavour.casefold_partsFc Cs¨t|ƒ}|stjƒSd}tdk r¤|r2|jt|ƒƒSg}xly|jt|ƒƒ}Wn>tk rˆ|}tjj|ƒ\}}|j|ƒ||kr„|SYq8Xtjj |ft |ƒžŽSq8WdS)N) ÚstrÚosÚgetcwdrÚ_ext_to_normalÚFileNotFoundErrorÚpathr,r-r#r))r$rbÚstrictrYZ previous_sZ tail_partsÚtailrrrÚresolveµs&  z_WindowsFlavour.resolvecCsXd}|j|ƒrP|dd…}|dd…}|jdƒrP||dd…7}d|dd…}||fS)Nr&ézUNC\rLr@)Ú startswith)r$rYZ ext_prefixrVrrrrOÍs    z$_WindowsFlavour._split_extended_pathcCs|j|ƒdS)Nr8)rO)r$rYrrrr`×sz_WindowsFlavour._ext_to_normalcCs6|sdS|djdƒrdS|djdƒdjƒ|jkS)NFrz\\r8r'rN)rgÚ partitionÚupperÚreserved_names)r$r1rrrÚ is_reservedÛs z_WindowsFlavour.is_reservedcCsd|j}t|ƒdkrJ|ddkrJ|jƒdd…jdƒ}d|t|jdƒƒfSdt|jƒjdƒƒSdS)Nrr8rMrAz file:///%s/%szutf-8zfile:)ÚdriverQÚas_posixrSÚurlquote_from_bytesÚencode)r$rbrlÚrestrrrÚmake_uriçs z_WindowsFlavour.make_uric Csòdtjkrtjd}n`dtjkr,tjd}nJdtjkrnytjd}Wntk r\d}YnX|tjd}ntdƒ‚|rîtjd|krî|j|fƒ\}}}|d tjdkr¸td |ƒ‚||d <|sÈ|rä|||j|dd…ƒ}n |j|ƒ}|S) NÚHOMEZ USERPROFILEZHOMEPATHZ HOMEDRIVEr&zCan't determine home directoryZUSERNAMEr8z%Can't determine home directory for %rrNrN)r^ÚenvironÚKeyErrorÚ RuntimeErrorr7r#)r$ÚusernameÚuserhomer2r3r1rrrÚ gethomedirós,       z_WindowsFlavour.gethomedirN)F)r;r<r=r"r(Úhas_drvÚntpathÚpathmodr^ÚnameÚ is_supportedÚsetÚrangeÚordrRZext_namespace_prefixrjr+r9r\rerOr`rkrqrxrrrrr?ks& "& '    r?c@sdeZdZdZdZdZeZej dkZ efdd„Z dd„Z d d „Z dd d „Zd d„Zdd„Zdd„ZdS)Ú _PosixFlavourrAr&FrcCsV|rH|d|krH|j|ƒ}t|ƒt|ƒdkr._resolver&)r"Ú _accessorÚ is_absoluter^r_r])r$rbrcÚbaser)rŠr‹rŒr"rcrre/s &z_PosixFlavour.resolvecCsdS)NFr)r$r1rrrrk\sz_PosixFlavour.is_reservedcCst|ƒ}dt|ƒS)Nzfile://)Úbytesrn)r$rbZbpathrrrrq_sz_PosixFlavour.make_uric Cst|s:y tjdStk r6ddl}|jtjƒƒjSXn6ddl}y |j|ƒjStk rntd|ƒ‚YnXdS)Nrrrz%Can't determine home directory for %r) r^rsrtÚpwdÚgetpwuidÚgetuidÚpw_dirÚgetpwnamru)r$rvr‘rrrrxes  z_PosixFlavour.gethomedirN)F)r;r<r=r"r(ryÚ posixpathr{r^r|r}r+r9r\rerkrqrxrrrrr�s   -r�c@seZdZdZdS)Ú _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)r;r<r=r>rrrrr—ysr—c@säeZdZdd„Zdd„ZeejƒZeejƒZeejƒZeej ƒZ eej ƒZ eej ƒZ e edƒrjeej ƒZ ndd„Z eejƒZeejƒZeejƒZeejƒZeejƒZerÂer¸eejƒZqÎdd „Zn ed d „ƒZeejƒZd d „Zd S)Ú_NormalAccessorcstjˆƒ‡fdd„ƒ}t|ƒS)Ncsˆt|ƒf|žŽS)N)r])ÚpathobjÚargs)ÚstrfuncrrÚwrapped�sz._NormalAccessor._wrap_strfunc..wrapped)Ú functoolsÚwrapsÚ staticmethod)r›rœr)r›rÚ _wrap_strfunc€sz_NormalAccessor._wrap_strfunccstjˆƒ‡fdd„ƒ}t|ƒS)Ncsˆt|ƒt|ƒf|žŽS)N)r])ZpathobjAZpathobjBrš)r›rrrœ‡sz5_NormalAccessor._wrap_binary_strfunc..wrapped)r�ržrŸ)r›rœr)r›rÚ_wrap_binary_strfunc†sz$_NormalAccessor._wrap_binary_strfuncÚlchmodcCs tdƒ‚dS)Nz%lchmod() not available on this system)ÚNotImplementedError)r$r™Úmoderrrr¢›sz_NormalAccessor.lchmodcCs tdƒ‚dS)Nz&symlink() not available on this system)r£)rEÚbÚtarget_is_directoryrrrÚsymlink¬sz_NormalAccessor.symlinkcCstjt|ƒt|ƒƒS)N)r^r§r])rEr¥r¦rrrr§°scCs tj|ƒS)N)r^rƒ)r$rbrrrrƒ·sz_NormalAccessor.readlinkN)r;r<r=r r¡r^ÚstatÚlstatÚopenÚlistdirÚscandirÚchmodÚhasattrr¢ÚmkdirÚunlinkÚrmdirÚrenamer*rÚsupports_symlinksr§rŸÚutimerƒrrrrr˜~s.                 r˜cCsP|d}|dd…}|dkr"t}n$d|kr4tdƒ‚nt|ƒrBt}nt}|||ƒS)Nrr8z**z:Invalid pattern: '**' can only be an entire path component)Ú_RecursiveWildcardSelectorÚ ValueErrorr Ú_WildcardSelectorÚ_PreciseSelector)Ú pattern_partsrÚ child_partsÚclsrrrÚ_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.cCs.||_|rt|ƒ|_d|_ntƒ|_d|_dS)NTF)rºr¼Ú successorÚdironlyÚ_TerminatingSelector)r$rºrrrr%×s  z_Selector.__init__cCs<t|ƒ}|j}|j}|jj}||ƒs,tgƒS|j||||ƒ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¬rrrÚ select_fromàsz_Selector.select_fromN)r;r<r=r>r%rÈrrrrr¾Ós r¾c@seZdZdd„ZdS)rÁccs |VdS)Nr)r$rÇrÃrÄr¬rrrrÆîsz!_TerminatingSelector._select_fromN)r;r<r=rÆrrrrrÁìsrÁc@seZdZdd„Zdd„ZdS)r¸cCs||_tj||ƒdS)N)r|r¾r%)r$r|rºrrrr%ôsz_PreciseSelector.__init__c cs^yD|j|jƒ}|jr|n||ƒrBx |jj||||ƒD] }|Vq4WWntk rXdSXdS)N)Ú_make_child_relpathr|rÀr¿rÆÚPermissionError)r$rÇrÃrÄr¬rbrZrrrrÆøs z_PreciseSelector._select_fromN)r;r<r=r%rÆrrrrr¸òsr¸c@seZdZdd„Zdd„ZdS)r·cCs"tjtj|ƒƒ|_tj||ƒdS)N)ÚreÚcompileÚfnmatchÚ translaterr¾r%)r$rrºrrrr%sz_WildcardSelector.__init__c cs–y||jj}t||ƒƒ}xb|D]Z}|j s0|jƒr|j}||ƒ} |jj| ƒr|j|ƒ} x |j j | |||ƒD] } | VqhWqWWnt k r�dSXdS)N) Ú_flavourr9ÚlistrÀrÃr|rÚmatchrÉr¿rÆrÊ) r$rÇrÃrÄr¬ÚcfÚentriesÚentryr|Z casefoldedrbrZrrrrÆs    z_WildcardSelector._select_fromN)r;r<r=r%rÆrrrrr·sr·c@s$eZdZdd„Zdd„Zdd„ZdS)rµcCstj||ƒdS)N)r¾r%)r$rrºrrrr%sz#_RecursiveWildcardSelector.__init__c csz|VyZt||ƒƒ}xH|D]@}|jƒr|jƒ r|j|jƒ}x|j|||ƒD] }|VqLWqWWntk rtdSXdS)N)rÐrÃÚ is_symlinkrÉr|Ú_iterate_directoriesrÊ)r$rÇrÃr¬rÓrÔrbrZrrrrÖs   z/_RecursiveWildcardSelector._iterate_directoriesc cs„yjtƒ}zT|jj}xF|j|||ƒD]4}x.|||||ƒD]}||kr6|V|j|ƒq6Wq"WWd|jƒXWntk r~dSXdS)N)r~r¿rÆrÖÚaddÚclearrÊ) r$rÇrÃrÄr¬ZyieldedZsuccessor_selectZstarting_pointrZrrrrÆ*sz'_RecursiveWildcardSelector._select_fromN)r;r<r=r%rÖrÆrrrrrµs rµc@s4eZdZdZdZdd„Zdd „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)rÂrÚrÛrÜrÝ)r$rbrrrr%Cs z_PathParents.__init__cCs(|js |jrt|jƒdSt|jƒSdS)Nr8)rÛrÜrQrÝ)r$rrrÚ__len__Js z_PathParents.__len__cCs@|dks|t|ƒkrt|ƒ‚|jj|j|j|jd| d…ƒS)Nrr8)rQÚ IndexErrorrÚÚ_from_parsed_partsrÛrÜrÝ)r$ÚidxrrrÚ __getitem__Psz_PathParents.__getitem__cCsdj|jjƒS)Nz <{}.parents>)ÚformatrÚr;)r$rrrÚ__repr__Vsz_PathParents.__repr__N)rÚrÛrÜrÝ) r;r<r=r>Ú __slots__r%rÞrârärrrrrÙ>s rÙc@sœeZdZdZdZZd d „Zd d „Zed d„ƒZed[dd„ƒZ ed\dd„ƒZ edd„ƒZ dd„Z dd„Z dd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zed&d'„ƒZd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd2d3„Zeedƒd4d5�Zeedƒd6d5�Zed7d8„ƒZed9d:„ƒZ ed;d<„ƒZ!ed=d>„ƒZ"ed?d@„ƒZ#dAdB„Z$dCdD„Z%dEdF„Z&edGdH„ƒZ'dIdJ„Z(dKdL„Z)dMdN„Z*edOdP„ƒZ+edQdR„ƒZ,dSdT„Z-dUdV„Z.dWdX„Z/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. rÛrÜrÝÚ_strÚ_hashÚ_ppartsÚ_cached_cpartscGs$|tkrtjdkrtnt}|j|ƒ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)rr^r|rrÚ _from_parts)r»ršrrrÚ__new__hszPurePath.__new__cCs|jt|jƒfS)N)Ú __class__ÚtuplerÝ)r$rrrÚ __reduce__rszPurePath.__reduce__cCshg}xV|D]N}t|tƒr$||j7}q tj|ƒ}t|tƒrH|jt|ƒƒq tdt|ƒƒ‚q W|j j |ƒS)NzNargument should be a str object or an os.PathLike object returning str, not %r) Ú isinstancerrÝr^Úfspathr]r-Ú TypeErrorrÂrÏr7)r»ršr1rErrrÚ _parse_argsws     zPurePath._parse_argsTcCs<tj|ƒ}|j|ƒ\}}}||_||_||_|r8|jƒ|S)N)ÚobjectrëròrÛrÜrÝÚ_init)r»ršÚinitr$r2r3r1rrrrê‹s zPurePath._from_partscCs,tj|ƒ}||_||_||_|r(|jƒ|S)N)rórërÛrÜrÝrô)r»r2r3r1rõr$rrrrà˜s zPurePath._from_parsed_partscCs4|s|r$|||jj|dd…ƒS|jj|ƒSdS)Nr8)rÏr#)r»r2r3r1rrrÚ_format_parsed_parts¢szPurePath._format_parsed_partscCsdS)Nr)r$rrrrô©szPurePath._initcCs@|j|ƒ\}}}|jj|j|j|j|||ƒ\}}}|j|||ƒS)N)ròrÏr:rÛrÜrÝrà)r$ršr2r3r1rrrÚ _make_child­szPurePath._make_childc Cs<y|jStk r6|j|j|j|jƒp,d|_|jSXdS)z[Return the string representation of the path, suitable for passing to system calls.r'N)ræÚAttributeErrorrörÛrÜrÝ)r$rrrÚ__str__³s  zPurePath.__str__cCst|ƒS)N)r])r$rrrÚ __fspath__½szPurePath.__fspath__cCs|j}t|ƒj|jdƒS)zNReturn the string representation of the path with forward (/) slashes.rA)rÏr]r*r")r$ÚfrrrrmÀszPurePath.as_posixcCstjt|ƒƒS)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)r^Úfsencoder])r$rrrÚ __bytes__ÆszPurePath.__bytes__cCsdj|jj|jƒƒS)Nz{}({!r}))rãrìr;rm)r$rrrräËszPurePath.__repr__cCs|jƒstdƒ‚|jj|ƒS)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)rŽr¶rÏrq)r$rrrÚas_uriÎszPurePath.as_uric Cs2y|jStk r,|jj|jƒ|_|jSXdS)N)rérørÏr\rÝ)r$rrrÚ_cpartsÔs zPurePath._cpartscCs&t|tƒstS|j|jko$|j|jkS)N)rïrÚNotImplementedrÿrÏ)r$ÚotherrrrÚ__eq__Ýs zPurePath.__eq__c Cs2y|jStk r,tt|jƒƒ|_|jSXdS)N)rçrøÚhashrírÿ)r$rrrÚ__hash__âs zPurePath.__hash__cCs(t|tƒ s|j|jk rtS|j|jkS)N)rïrrÏrrÿ)r$rrrrÚ__lt__észPurePath.__lt__cCs(t|tƒ s|j|jk rtS|j|jkS)N)rïrrÏrrÿ)r$rrrrÚ__le__îszPurePath.__le__cCs(t|tƒ s|j|jk rtS|j|jkS)N)rïrrÏrrÿ)r$rrrrÚ__gt__ószPurePath.__gt__cCs(t|tƒ s|j|jk rtS|j|jkS)N)rïrrÏrrÿ)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 ''.)rÛrÜ)r$Úanchorrrrr s zPurePath.anchorcCs.|j}t|ƒ|js|jrdndkr&dS|dS)z!The final path component, if any.r8rr&rN)rÝrQrÛrÜ)r$r1rrrr| sz PurePath.namecCsD|j}|jdƒ}d|ko*t|ƒdknr<||d…SdSdS)z*The final component's last suffix, if any.r'rr8Nr&)r|ÚrfindrQ)r$r|rIrrrÚsuffixs    zPurePath.suffixcCs:|j}|jdƒrgS|jdƒ}dd„|jdƒdd…DƒS)z1A list of the final component's suffixes, if any.r'cSsg|] }d|‘qS)r'r)rCr rrrr["sz%PurePath.suffixes..r8N)r|ÚendswithrSr,)r$r|rrrÚsuffixess   zPurePath.suffixescCsD|j}|jdƒ}d|ko*t|ƒdknr<|d|…S|SdS)z0The final path component, minus its last suffix.r'rr8N)r|r rQ)r$r|rIrrrÚstem$s    z PurePath.stemcCsˆ|jstd|fƒ‚|jj|fƒ\}}}| sZ|d|jj|jjgksZ|sZ|sZt|ƒdkrftd|ƒ‚|j|j|j |j dd…|gƒS)z-Return a new path with the file name changed.z%r has an empty namer8zInvalid name %rNrNrN) r|r¶rÏr7r"r(rQràrÛrÜrÝ)r$r|r2r3r1rrrÚ with_name.s  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…|gƒS)zÀReturn 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 nameNr8rN) rÏr"r(r¶rgr|r rQràrÛrÜrÝ)r$r rûr|Z old_suffixrrrÚ with_suffix9s    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|| d…ƒS)zÌReturn 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 argumentr8Nrz{!r} does not start with {!r}r&) rñrÝrÛrÜròrQrÏr\rör¶rãr]rà) r$rr1r2r3Z abs_partsZto_drvZto_rootZto_partsZ to_abs_partsÚnrÒZ formattedrrrÚ relative_toNs( (zPurePath.relative_toc Cs.y|jStk r(t|jƒ|_|jSXdS)zZAn object providing sequence-like access to the components in the filesystem path.N)rèrørírÝ)r$rrrr1ns  zPurePath.partscGs |j|ƒS)zîCombine 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$ršrrrÚjoinpathzszPurePath.joinpathcCs |j|fƒS)N)r÷)r$ÚkeyrrrÚ __truediv__‚szPurePath.__truediv__cCs|j|g|jƒS)N)rêrÝ)r$rrrrÚ __rtruediv__…szPurePath.__rtruediv__cCs@|j}|j}|j}t|ƒdkr*|s&|r*|S|j|||dd…ƒS)zThe logical parent of the path.r8NrN)rÛrÜrÝrQrà)r$r2r3r1rrrÚparentˆs zPurePath.parentcCst|ƒS)z*A sequence of this path's logical parents.)rÙ)r$rrrÚparents’szPurePath.parentscCs|js dS|jj pt|jƒS)zSTrue if the path is absolute (has both a root and, if applicable, a drive).F)rÜrÏryÚboolrÛ)r$rrrrŽ—szPurePath.is_absolutecCs|jj|jƒS)zaReturn True if the path contains one of the special names reserved by the system, if any.)rÏrkrÝ)r$rrrrkžszPurePath.is_reservedc CsÔ|jj}||ƒ}|jj|fƒ\}}}|s0tdƒ‚|rF|||jƒkrFdS|r\|||jƒkr\dS|j}|sj|rŒt|ƒt|ƒkr~dS|dd…}nt|ƒt|ƒkr dSx.tt |ƒt |ƒƒD]\}}t j ||ƒs´dSq´WdS)zE Return True if this path matches the given pattern. z empty patternFr8NT) rÏr9r7r¶rÛrÜrÿrQÚzipr)rÍZ fnmatchcase) r$Z path_patternrÒr2r3Z pat_partsr1r5rrrrrÑ£s( zPurePath.matchN)rÛrÜrÝrærçrèré)T)T)0r;r<r=r>rårërîÚ classmethodròrêràrörôr÷rùrúrmrýrärþÚpropertyrÿrrrrrrrrlr3r r|r rrrrrr1rrrrrrŽrkrÑrrrrrZs^            c@seZdZdZeZfZdS)rz¼PurePath 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_flavourrÏrårrrrrÁsc@seZdZdZeZfZdS)rzºPurePath 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_flavourrÏrårrrrrËsc@sˆeZdZdZdaZdd„Zdbdd„Zd d „Zd d „Zd d„Z dd„Z dcdd„Z dddd„Z e dd„ƒZe dd„ƒZdd„Zdd„Zdd „Zd!d"„Zd#d$„Zded&d'„Zd(d)„Zd*d+„Zd,d-„Zdgd0d1„Zd2d3„Zdhd4d5„Zd6d7„Zdid8d9„Zdjd;d<„Zdkd=d>„Zd?d@„Z dAdB„Z!dCdD„Z"dEdF„Z#dGdH„Z$dIdJ„Z%dKdL„Z&dldMdN„Z'dOdP„Z(dQdR„Z)dSdT„Z*dUdV„Z+dWdX„Z,dYdZ„Z-d[d\„Z.d]d^„Z/d_d`„Z0dS)mra¡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ƒ‚|j ƒ|S)NrF)rõz$cannot instantiate %r on your system) rr^r|rrrêrÏr}r£r;rô)r»ršÚkwargsr$rrrrëæs z Path.__new__NcCs"d|_|dk r|j|_nt|_dS)NF)r r�Ú_normal_accessor)r$Útemplaterrrrôðs z Path._initcCs|j|g}|j|j|j|ƒS)N)rÝràrÛrÜ)r$r5r1rrrrÉús zPath._make_child_relpathcCs|jr|jƒ|S)N)r Ú _raise_closed)r$rrrÚ __enter__szPath.__enter__cCs d|_dS)NT)r )r$ÚtÚvÚtbrrrÚ__exit__sz Path.__exit__cCs tdƒ‚dS)NzI/O operation on closed path)r¶)r$rrrr$szPath._raise_closedé¶cCs|jj|||ƒS)N)r�rª)r$r|Úflagsr¤rrrÚ_opener sz Path._openeréÿcCs|jr|jƒ|jj|||ƒS)zm Open the file pointed by this path and return a file descriptor, as os.open() does. )r r$r�rª)r$r+r¤rrrÚ _raw_openszPath._raw_opencCs |tjƒƒS)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )r^r_)r»rrrÚcwdszPath.cwdcCs||ƒjjdƒƒS)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)rÏrx)r»rrrÚhome!sz 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()). )r¨rør^rbÚsamestat)r$Z other_pathÚstZother_strrrÚsamefile(s  z Path.samefileccsL|jr|jƒx8|jj|ƒD](}|dkr*q|j|ƒV|jr|jƒqWdS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. r'ú..N>r'r4)r r$r�r«rÉ)r$r|rrrÚiterdir3s z Path.iterdirccsl|stdj|ƒƒ‚|jj|ƒ}|jj|fƒ\}}}|s:|rBtdƒ‚tt|ƒƒ}x|j|ƒD] }|VqZWdS)zˆIterate 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) r¶rãrÏr9r7r£r¼rírÈ)r$Úpatternr2r3r¹ÚselectorrZrrrÚglobAs  z Path.globccs^|jj|ƒ}|jj|fƒ\}}}|s(|r0tdƒ‚tdt|ƒƒ}x|j|ƒD] }|VqLWdS)z�Recursively yield all existing files (of any kind, including directories) matching the given pattern, anywhere in this subtree. z%Non-relative patterns are unsupportedú**N)r9)rÏr9r7r£r¼rírÈ)r$r6r2r3r¹r7rZrrrÚrglobOs z Path.rglobcCsD|jr|jƒ|jƒr|S|jtjƒ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. F)rõ)r#)r r$rŽrêr^r_rÝrô)r$ÚobjrrrÚabsolute[s z Path.absoluteFcCsh|jr|jƒ|jj||d�}|dkr:|jƒt|jƒƒ}|jjj|ƒ}|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). )rcNF)rõ)r#) r r$rÏrer¨r]r<r{Únormpathrêrô)r$rcrYZnormedr;rrrrems  z Path.resolvecCs |jj|ƒS)zh Return the result of the stat() system call on this path, like os.stat() does. )r�r¨)r$rrrr¨�sz Path.statcCsddl}|j|jƒjƒjS)z: Return the login name of the file owner. rN)r‘r’r¨Úst_uidZpw_name)r$r‘rrrÚownerˆsz Path.ownercCsddl}|j|jƒjƒjS)z8 Return the group name of the file gid. rN)ÚgrpZgetgrgidr¨Úst_gidZgr_name)r$r@rrrÚgroup�sz Path.groupÚrr8c Cs,|jr|jƒtjt|ƒ||||||jd�S)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )Úopener)r r$Úiorªr]r,)r$r¤Ú bufferingÚencodingÚerrorsÚnewlinerrrrª–sz Path.openc Cs |jdd�� }|jƒSQRXdS)zK Open the file in bytes mode, read it, and close the file. Úrb)r¤N)rªÚread)r$rûrrrÚ read_bytes¡szPath.read_bytesc Cs$|jd||d�� }|jƒSQRXdS)zJ Open the file in text mode, read it, and close the file. rC)r¤rGrHN)rªrK)r$rGrHrûrrrÚ read_text¨szPath.read_textc Cs*t|ƒ}|jdd�� }|j|ƒSQRXdS)zO Open the file in bytes mode, write to it, and close the file. Úwb)r¤N)Ú memoryviewrªÚwrite)r$ÚdataZviewrûrrrÚ write_bytes¯szPath.write_bytesc Cs@t|tƒstd|jjƒ‚|jd||d�� }|j|ƒSQRXdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %sÚw)r¤rGrHN)rïr]rñrìr;rªrP)r$rQrGrHrûrrrÚ write_text¸s   zPath.write_textTc Csr|jr|jƒ|r>y|jj|dƒWntk r8YnXdStjtjB}|sX|tjO}|j ||ƒ}tj |ƒdS)zS Create this file with the given access mode, if it doesn't exist. N) r r$r�r´r„r^ÚO_CREATÚO_WRONLYÚO_EXCLr.Úclose)r$r¤Úexist_okr+ÚfdrrrÚtouchÂs   z Path.touchc Cs�|jr|jƒy|jj||ƒWnjtk rf| s@|j|krB‚|jjddd�|j|d|d�Yn&tk rŠ| s„|jƒ r†‚YnXdS)z< Create a new directory at this given path. T)rrYFN)r r$r�r¯rarr„rÃ)r$r¤rrYrrrr¯Ùsz Path.mkdircCs |jr|jƒ|jj||ƒdS)zF Change the permissions of the path, like os.chmod(). N)r r$r�r­)r$r¤rrrr­ìsz 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)r r$r�r¢)r$r¤rrrr¢ôsz Path.lchmodcCs|jr|jƒ|jj|ƒdS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)r r$r�r°)r$rrrr°ýsz Path.unlinkcCs|jr|jƒ|jj|ƒdS)zF Remove this directory. The directory must be empty. N)r r$r�r±)r$rrrr±sz 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. )r r$r�r©)r$rrrr©sz Path.lstatcCs |jr|jƒ|jj||ƒdS)z5 Rename this path to the given path. N)r r$r�r²)r$rˆrrrr²sz Path.renamecCs |jr|jƒ|jj||ƒdS)zo Rename this path to the given path, clobbering the existing destination if it exists. N)r r$r�r*)r$rˆrrrr*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)r r$r�r§)r$rˆr¦rrrÚ symlink_to(szPath.symlink_tocCsBy |jƒWn0tk r<}z|jttfkr.‚dSd}~XnXdS)z+ Whether this path exists. FNT)r¨r„r…rr)r$r‰rrrrÄ3s z Path.existscCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)z3 Whether this path is a directory. FN)rr¨Úst_moder„r…rr)r$r‰rrrrÃ?s z Path.is_dircCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). FN)r r¨r]r„r…rr)r$r‰rrrÚis_fileLs z Path.is_filecCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)z7 Whether this path is a symbolic link. FN)r r©r]r„r…rr)r$r‰rrrrÕZs zPath.is_symlinkcCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)z6 Whether this path is a block device. FN)r r¨r]r„r…rr)r$r‰rrrÚis_block_devicefs zPath.is_block_devicecCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)z: Whether this path is a character device. FN)r r¨r]r„r…rr)r$r‰rrrÚis_char_devicess zPath.is_char_devicecCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)z. Whether this path is a FIFO. FN)rr¨r]r„r…rr)r$r‰rrrÚis_fifo€s z Path.is_fifocCsDyt|jƒjƒStk r>}z|jttfkr0‚dSd}~XnXdS)z0 Whether this path is a socket. FN)r r¨r]r„r…rr)r$r‰rrrÚ is_socket�s zPath.is_socketcCsb|jp |j r^|jr^|jddd…dkr^|jj|jddd…ƒ}|j|g|jdd…ƒS|S)zl Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) rNr8ú~)rÛrÜrÝrÏrxrê)r$ZhomedirrrrÚ expanduseršs zPath.expanduser)r�r )N)r*)r-)FrN)rCrNNNN)NN)NN)r*T)r-FF)F)1r;r<r=r>rårërôrÉr%r)r$r,r.rr/r0r3r5r8r:r<rer¨r?rBrªrLrMrRrTr[r¯r­r¢r°r±r©r²r*r\rÄrÃr^rÕr_r`rarbrdrrrrrØs^                      c@seZdZdZfZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. N)r;r<r=r>rårrrrr¦sc@s$eZdZdZfZdd„Zdd„ZdS)rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. cCs tdƒ‚dS)Nz*Path.owner() is unsupported on this system)r£)r$rrrr?´szWindowsPath.ownercCs tdƒ‚dS)Nz*Path.group() is unsupported on this system)r£)r$rrrrB·szWindowsPath.groupN)r;r<r=r>rår?rBrrrrr­s)rr)>rÍr�rErzr^r–rËr.Ú collectionsrÚ contextlibrr…rrrÚoperatorrr¨rr r r r r rZ urllib.parserrnr³r|rZgetwindowsversionrÚ__all__r rór!r?r�rrr—r˜r"r¼r®r½r¾rÁr¸r·rµrÙrÚPathLikeÚregisterrrrrrrrrrÚsl   $   ?(c=  %f   Q