Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
spec.cpython-313.pyc968 linesDownload Raw Back to __pycache__
1�

2�j�/��V�SSKJr SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J3r4 SSKJr SSK
Jr SSKJrJr SSKJr SS	KJrJr SS5KJr SSKJr SSKJrJrJrJrJ r J!r!J"r" \RF"S
5r$Sr%"SS\&5r'"SS\'S9r("SS\RR5r*Sr+g)�)�annotationsN)�ESPIPE)�	has_magic)�sha256)�Any�ClassVar�)�DEFAULT_CALLBACK)�apply_config�conf)�DirCache)�Transaction)�_unstrip_protocol�glob_translate�6isfilelike�other_paths�7read_block�stringify_path�tokenize�fsspecc��U"U0UD6$�N�)�cls�args�kwargss   �QD:\code\apps\devtools\python\user_packages\Python313\site-packages\fsspec/spec.py�
make_instancer s��������c�8^�\rSrSrSrU4SjrU4SjrSrU=r$)�_Cached�$a�8Metaclass for caching file system instances.9 10Notes11-----12Instances are cached according to13 14* The values of the class attributes listed in `_extra_tokenize_attributes`15* The arguments passed to ``__init__``.16 17This creates an additional reference to the filesystem, which prevents the18filesystem from being garbage collected when all *user* references go away.19A call to the :meth:`AbstractFileSystem.clear_instance_cache` must *also*20be made for a filesystem instance to be garbage collected.21c��>�[TU]"U0UD6 [R"S5(a[R22"5UlO0Ul[R"5Ul	g)N�weakref_instance_cache)23�super�__init__r�get�weakref�WeakValueDictionary�_cache�os�getpid�_pid)rrr�	__class__s   �rr&�_Cached.__init__5sK���
���$�)�&�)��8�8�,�-�-� �4�4�6�C�J��C�J��9�9�;��rc�>^�[TU5n[U4SjTR55nTRVs0sHoDU;dM24XBR	U5_M nn[TTR[R"5/UQUQ70UD6nUR	SS5n[R"5TR:wa4TRR5 [R"5TlU(d7TR(a&UTR;aUTlTRU$[T25T]@"U0UDUD6nXhlXlX(lUR((aUR*(aSSKJn	 U	"U5 TR(aU(dUTlUTRU'U$s snf)Nc3�>># �UHn[TUS5v� M g7fr��getattr)�.0�attrrs  �r�	<genexpr>�#_Cached.__call__.<locals>.<genexpr>Cs!����26�1O��G�C��t�$�$�1O�s��skip_instance_cacheFr	)�mirror_sync_methods)r�tuple�_extra_tokenize_attributes�_strip_tokenize_options�poprr-�	threading�	get_identr+r,r*�clear�cachable�_latestr%�__call__�27_fs_token_�storage_args�storage_options�28async_implr9�asyn)rrr�extra_tokens�k�strip_tokenize_options�token�skip�objr9r.s`         �rrC�_Cached.__call__Ast����c�6�*���29�14�1O�1O�30�31��'*�&A�&A�"32�&A��&�[��A�z�z�!�}��&A�	�"33������9�.�.�0�34�37�35�:F�36�JP�37���z�z�/��7��
�9�9�;�#�(�(�"��J�J�����y�y�{�C�H������#�*�*�)<��C�K��:�:�e�$�$��'�"�D�M�F�M�6L�M�C�"�N�#��"(���~�~�#�"9�"9�5�#�C�(��|�|�D�#���$'��38�39�5�!��J��7"40s�	F;�	F;r)	�__name__�41__module__�__qualname__�__firstlineno__�__doc__r&rC�__static_attributes__�
__classcell__)r.s@rr!r!$s���� 42� � rr!c���\rSrSr%SrSrSrSrSrSr	S\43S	'S44rSrSr
Sr\rSrSrS
\45S'S\46S'Sr\S5r\S5rSrSrSrSr\S5rSgSjr\S5r\S5r \S5r!Sr"Sr#ShSjr$SiS jr%SjS!jr&S"r'SiS#jr(S$r)SkS%jr*SlS&jr+SmS'jr,ShS(jr-S)r.S*r/S+r0S,r1S-r2S.r3S/r4S0r5SnS1jr6SnS2jr7SoS3jr8SpS5jr9ShS6jr:SqS7jr;SrS8jr<\=S474S9jr>S\=S484S:jr?\=S44S;jr@S\=S494S<jrASsS=jrBSsS>jrCS?rDStS@jrESuSAjrFSuSBjrGSCrHSDrISuSEjrJ\SF5rKSvSGjrLSwSHjrMSiSIjrNSJrOShSKjrPSSL.SxSMjjrQ\SySNj5rRSSL.SzSOjjrS\S{SPj5rTSQrUS|SRjrV\SS5rWSTrXSUrYS}S~SVjjrZSoSWjr[SXr\SiSYjr]SjSZjr^SiS[jr_S\r`S]raS^rbSS_jrcS`rdSuSajreSjSbjrfSjScjrgS�SdjrhSeriSfrjg50)��AbstractFileSystem�dz�51An abstract super-class for pythonic file-systems52 53Implementations are expected to be compatible with or, better, subclass54from here.55TFi@�/�abstractzClassVar[str | tuple[str, ...]]�protocolN�rztuple[Any, ...]rE�dict[str, Any]rFc�V�UR(agSUlSUlSUl/Ul[	S0UD6UlUR
SS5(a[R"S[5 UR
SS5(a[R"S[5 SUl56g)	a+Create and configure file-system instance57 58Instances may be cachable, so if similar enough arguments are seen59a new instance is not required. The token attribute exists to allow60implementations to cache instances if they wish.61 62A reasonable default should be provided if there are no arguments.63 64Subclasses should call this method.65 66Parameters67----------68use_listings_cache, listings_expiry_time, max_paths:69    passed to ``DirCache``, if the implementation supports70    directory listing caching. Pass use_listings_cache=False71    to disable such caching.72skip_instance_cache: bool73    If this is a cachable implementation, pass True here to force74    creating a new instance even if a matching instance exists, and prevent75    storing this instance.76asynchronous: bool77loop: asyncio-compatible IOLoop or None78NTF�add_docsz add_docs is no longer supported.�add_aliaseszadd_aliases has been removed.r)�_cached�_intrans�_transaction�"_invalidated_caches_in_transactionr
�dircacher=�warnings�warn�
FutureWarningrD)�selfrrFs   rr&�AbstractFileSystem.__init__�s���0�<�<�������
� ���24��/� �3�?�3��
����z�4�0�0��M�M�<�m�L����}�d�3�3��M�M�9�=�I���rc��[e)zRPersistent filesystem id that can be used to compare filesystems79across sessions.80��NotImplementedError�rjs r�fsid�AbstractFileSystem.fsid�s81��82"�!rc��UR$r)rDros r�	_fs_token�AbstractFileSystem._fs_token�s�����rc��UR$r)rsros r�__dask_tokenize__�$AbstractFileSystem.__dask_tokenize__�s���~�~�rc�.�[URS5$)N�)�intrsros r�__hash__�AbstractFileSystem.__hash__�s���4�>�>�2�&�&rc�l�[U[U55=(a URUR:H$r)�83isinstance�typers�rj�others  r�__eq__�AbstractFileSystem.__eq__�s%���%��d��,�R����5�?�?�1R�Rrc�R�[[U5URUR44$r)rrrErFros r�84__reduce__�AbstractFileSystem.__reduce__�s$���t�D�z�4�+<�+<�d�>R�>R�S�S�Src��[U[5(a!UVs/sHo RU5PM sn$[U5n[UR[855(a
UR4OURnUH[nUR
US-5(aU[U5S-SnM/UR
US-5(dMJU[U5S-SnM] URS5nU=(d UR$s snf)z}Turn path from fully-qualified to file-system-specific86 87May require FS-specific handling, e.g., for relative paths or links.88�://�Nz::�rZ)89r~�list�_strip_protocolrr\�str�90startswith�len�rstrip�root_marker)r�path�p�protosr\s     rr��"AbstractFileSystem._strip_protocol�s����d�D�!�!�48�9�D�q�'�'��*�D�9�9��d�#��$.�s�|�|�S�$A�$A�#�,�,��s�|�|���H����x�%�/�0�0��C��M�A�-�/�0������D��1�1��C��M�A�-�/�0��	�91�{�{�3����&�s���&��:s�Dc���[UR[5(a
UR4OURnUH nURUS35(dMUs $ USSU3$)z6Format FS-specific path to generic, including protocolr�r)r~r\r�r�)rj�namer�r\s    r�unstrip_protocol�#AbstractFileSystem.unstrip_protocol�s`��%/��
�
�s�%C�%C�$�-�-�!������H����(��3�/�0�0������)��C��v�&�&rc��0$)a>If kwargs can be encoded in the paths, extract them here92 93This should happen before instantiation of the class; incoming paths94then should be amended to strip the options in methods.95 96Examples may look like an sftp path "sftp://user@host:/my/path", where97the user and host should become kwargs and later get stripped.98r)r�s r�_get_kwargs_from_urls�(AbstractFileSystem._get_kwargs_from_urls�s	���	rc�v�URUR;aURUR$U"5$)zqReturn the most recently instantiated FileSystem99 100If no instance has been created, then create one with defaults101)rBr*�rs r�current�AbstractFileSystem.current�s.���;�;�#�*�*�$��:�:�c�k�k�*�*��u�rc�`�URcURU5UlUR$)z�A context within which files are committed together upon exit102 103Requires the file class to implement `.commit()` and `.discard()`104for the normal and exception cases.105)rd�transaction_typeros r�transaction�AbstractFileSystem.transaction�s/�����$� $� 5� 5�d� ;�D��� � � rc�T�SUlURU5UlUR$)z@Begin write transaction for deferring files, non-context versionT)rcr�rdr�ros r�start_transaction�$AbstractFileSystem.start_transaction�s(����
� �1�1�$�7������rc���URR5 SUlURHnUR	U5 M URR5 g)z-Finish write transaction, non-context versionN)r��completerdre�invalidate_cacher@�rjr�s  r�end_transaction�"AbstractFileSystem.end_transactionsL�����!�!�#� ����;�;�D��!�!�$�'�<��/�/�5�5�7rc�^�UR(aURRU5 gg)z�106Discard any cached directory information107 108Parameters109----------110path: string or None111    If None, clear all listings cached else listings at or under given112    path.113N)rcre�appendr�s  rr��#AbstractFileSystem.invalidate_caches$���=�=��3�3�:�:�4�@�rc��g)a.114Create directory entry at path115 116For systems that don't have true directories, may create an for117this instance only and not touch the real filesystem118 119Parameters120----------121path: str122    location123create_parents: bool124    if True, this is equivalent to ``makedirs``125kwargs:126    may be permissions, etc.127Nr�rjr��create_parentsrs    r�mkdir�AbstractFileSystem.mkdirs�� 	
rc��g)a2Recursively make directories128 129Creates directory at path and any intervening required directories.130Raises exception if, for instance, the path already exists but is a131file.132 133Parameters134----------135path: str136    leaf directory name137exist_ok: bool (False)138    If False, will error if the target already exists139Nr�rjr��exist_oks   r�makedirs�AbstractFileSystem.makedirs/s��	
rc��g)zRemove a directory, if emptyNrr�s  r�rmdir�AbstractFileSystem.rmdir?���rc��[e)a�List objects at path.140 141This should include subdirectories and files at that location. The142difference between a file and a directory must be clear when details143are requested.144 145The specific keys, or perhaps a FileInfo class, or similar, is TBD,146but must be consistent across implementations.147Must include:148 149- full path to the entry (without protocol)150- size of the entry, in bytes. If the value cannot be determined, will151  be ``None``.152- type of entry, "file", "directory" or other153 154Additional information155may be present, appropriate to the file-system, e.g., generation,156checksum, etc.157 158May use refresh=True|False to allow use of self._ls_from_cache to159check for a saved listing and avoid calling the backend. This would be160common where listing may be expensive.161 162Parameters163----------164path: str165detail: bool166    if True, gives a list of dictionaries, where each is the same as167    the result of ``info(path)``. If False, gives a list of paths168    (str).169kwargs: may have additional backend-specific options, such as version170    information171 172Returns173-------174List of strings if detail is False, or list of directory information175dicts if detail is True.176rm�rjr��detailrs    r�ls�AbstractFileSystem.lsCs��N"�!rc��URU5nURURS5$![a Of=fURUVs/sH3nUSU:Xd%USURS5:XdM&USS:XdM1UPM5 Os snfnn[	U5S:Xa[U5eU$![a gf=f)z�Check cache for listing177 178Returns listing, if found (may be empty list for a directly that exists179but contains nothing), None if not in cache.180rZr�r�	directoryrN)�_parentrfr��KeyErrorr��FileNotFoundError)rjr��parent�f�filess     r�_ls_from_cache�!AbstractFileSystem._ls_from_cachels������d�#��	��=�=����S�!1�2�2���	��	��	����v�.��.�A��V�9��$��f�I����S�!1�1��78��i�;�6N��.���E���5�z�Q��'��-�-��L���	��	�s6�1�181>�>�B1�%B�<B�B�
#B1�1182B>�=B>c+��# �UbUS:a[S5eURU5n0n0n0nURSS5n	UR"U4SS0UD6n183U184HSnUSRS	5n
U
RS	S5S185nUSS:XaX�:wa186X�U'X�U'MDX�:XaX�S
'MOX�U'MU U	(d[U5n[U5nU(aXU4v� UbUS-nUS:aU(dXU4v� gUH$nUR"Xo4UU	US.UD6Shv�N M& U(dXU4v� gg![[1874a)nUS:Xae[
U5(aU"U5 SnAgSnAff=fNS7f)a�Return all files under the given path.188 189List all files, recursing into subdirectories; output is iterator-style,190like ``os.walk()``. For a simple list of files, ``find()`` is available.191 192When topdown is True, the caller can modify the dirnames list in-place (perhaps193using del or slice assignment), and walk() will194only recurse into the subdirectories whose names remain in dirnames;195this can be used to prune the search, impose a specific order of visiting,196or even to inform walk() about directories the caller creates or renames before197it resumes walk() again.198Modifying dirnames when topdown is False has no effect. (see os.walk)199 200Note that the "files" outputted will include anything that is not201a directory, such as links.202 203Parameters204----------205path: str206    Root to recurse into207maxdepth: int208    Maximum recursion depth. None means limitless, but not recommended209    on link-based file-systems.210topdown: bool (True)211    Whether to walk the directory tree from the top downwards or from212    the bottom upwards.213on_error: "omit", "raise", a callable214    if omit (default), path with exception will simply be empty;215    If raise, an underlying exception will be raised;216    if callable, it will be called with a single OSError instance as argument217kwargs: passed to ``ls``218Nr	�maxdepth must be at least 1r�FT�raiser�rZ�����rr�r])�maxdepthr��topdown)�219ValueErrorr�r=r�r��OSError�callabler��rsplitr��walk)rjr�r�r��on_errorr�	full_dirs�dirsr�r��listing�e�info�pathnamer��ds                rr��AbstractFileSystem.walk�s����B��H�q�L��:�;�;��#�#�D�)���	��������H�e�,��	��g�g�d�:�4�:�6�:�G��D��F�|�*�*�3�/�H��?�?�3��*�2�.�D��F�|�{�*�x�/?�"*�$��!�T�220��!� �b�	�"�d������:�D���K�E���e�#�#�����M�H��!�|���e�+�+���A��y�y����!���	�221��
�
����e�#�#���]"�7�+�	��7�"����!�!������	��L
�s<�>E,�D.�CE,�E*�E,�.E'�>E"�E,�"E'�'E,c	��URU5n0nU(a/US:wa)URU5(aURU5Xa'UR"X4SS0UD6HVupxn	U(aU	R	U5 UR	U	R5V222Vs0sHup�USU_M
 snn2235 MX U(dUR
U5(a0Xa'[U5nU(dU$UV224s0sHo�Xj_M	 sn225$s snn226fs sn227f)aeList all files below path.228 229Like posix ``find`` command without conditions230 231Parameters232----------233path : str234maxdepth: int or None235    If not None, the maximum number of levels to descend236withdirs: bool237    Whether to include directory paths in the output. This is True238    when used by glob, but users usually only want files.239kwargs are passed to ``ls``.240r]r�Tr�)r��isdirr�r��update�items�isfile�sorted)
rjr�r��withdirsr�r�out�_r�r�r�r��namess
             r�find�AbstractFileSystem.find�s��� �#�#�D�)�������241�t�z�z�$�'7�'7��	�	�$��C�I�"�i�i��N�t�N�v�N�N�A�U�����T�"��J�J�U�[�[�]�K�]�z�t��V��d�*�]�K�L�O��t�{�{�4�(�(��C�I��s�����L�05�6���#�)�O��6�6��L��7s�D�2D	c�(�0nU(a1URU5(aURU5nUSXgS'UR"U4X4S.UD6HnURU5nUSXgS'M  U(a[UR	55$U$)a�Space used by files and optionally directories within a path242 243Directory size does not include the size of its contents.244 245Parameters246----------247path: str248total: bool249    Whether to sum all the file sizes250maxdepth: int or None251    Maximum number of directory levels to descend, None for unlimited.252withdirs: bool253    Whether to include directory paths in the output.254kwargs: passed to ``find``255 256Returns257-------258Dict of {path: size} if total=False, or int otherwise, where numbers259refer to bytes used.260�sizer�)r�r�)r�r�r��sum�values)	rjr��totalr�r�r�sizesr�r�s	         r�du�AbstractFileSystem.du	s���*����261�262�4�(�(��9�9�T�?�D�"&�v�,�E�v�,�����4�P�(�P��P�A��9�9�Q�<�D�"&�v�,�E�v�,��Q���u�|�|�~�&�&��Lrc�`�UbUS:a[S5eSSKn[RR(a4[RR263[RR4O[RR2644nUR
U5nURU5nU=(d! UR
[SU555nURS5S:�aURS5O265[U5nURS5S:�aURS5O266[U5n	URS5S:�aURS5O267[U5n268[X�U2695nURS	S2705nURSS5n
[U5(dAUR"U40UD6(aU(dU/$XR"U40UD60$U(d/$0$S
USU;a6USUR!S
5nUSUS-nXS-SR#S
5S-nOSnXS-SR#S
5S-nSU;a6Ub1URS5nUUSR#S
5S-nUU-271U-nOSnUR"U4X�SS.UD6n[%X(aS
OS-5nUR'U5n[)UR+55VVs0sH6unnUR-U(aUSS:XaUS
-OU5(dM3UU_M8 nnnU(aU$[/U5$s snnf)a4Find files by glob-matching.272 273Pattern matching capabilities for finding files that match the given pattern.274 275Parameters276----------277path: str278    The glob pattern to match against279maxdepth: int or None280    Maximum depth for ``'**'`` patterns. Applied on the first ``'**'`` found.281    Must be at least 1 if provided.282kwargs:283    Additional arguments passed to ``find`` (e.g., detail=True)284 285Returns286-------287List of matched paths, or dict of paths and their info if detail=True288 289Notes290-----291Supported patterns:292- '*': Matches any sequence of characters within a single directory level293- ``'**'``: Matches any number of directory levels (must be an entire path component)294- '?': Matches exactly one character295- '[abc]': Matches any character in the set296- '[a-z]': Matches any character in the range297- '[!abc]': Matches any character NOT in the set298 299Special behaviors:300- If the path ends with '/', only folders are returned301- Consecutive '*' characters are compressed into a single '*'302- Empty brackets '[]' never match anything303- Negated empty brackets '[!]' match any single character304- Special characters in character classes are escaped properly305 306Limitations:307- ``'**'`` must be a complete path component (e.g., ``'a/**/b'``, not ``'a**b'``)308- No brace expansion ('{a,b}.txt')309- No extended glob patterns ('+(pattern)', '!(pattern)')310Nr	r�rc3�*# �UH	oS-v� M g7f)�**Nr)r4�seps  rr6�*AbstractFileSystem.glob.<locals>.<genexpr>]s���-����*��s��*�?�[r�Fr�TrZr]r��r�r�r�rr�)r��rer+r��altsepr��endswithr�r:r�r��minr=r�existsr��rindex�countr�compiler�r��matchr�)rjr�r�rr��seps�
ends_with_sep�append_slash_to_dirname�idx_star�	idx_qmark�	idx_brace�min_idxr�r��root�depth�idx_double_stars�depth_double_stars�allpaths�patternr�r�r�s                       r�glob�AbstractFileSystem.glob+s���R��H�q�L��:�;�;��02����������R�W�W�^�^�,�R�W�W�[�[�N���
�
�d�+�
��#�#�D�)��"/�#311�4�=�=��-��-�-�4312��&*�Y�Y�s�^�q�%8�4�9�9�S�>�c�$�i��&*�i�i��n��&9�D�I�I�c�N�s�4�y�	�&*�i�i��n��&9�D�I�I�c�N�s�4�y�	��h�9�5�����H�e�,���:�:�j�$�/�������{�{�4�*�6�*�� �6�M� �)�)�D�";�F�";�<�<���I��I�
�D��'�N�
"��8�G�n�+�+�C�0�G��
�'�A�+�&�D��1���'�-�-�c�2�Q�6�E��D��1���'�-�-�c�2�Q�6�E��4�<��#�#'�9�9�T�?� �%)�*:�*;�%<�%B�%B�3�%G�!�%K�"�� 2�2�X�=�����9�9��313� �D�314�DJ�315��!��
��2�!F�G���*�*�W�%��"�(�.�.�"2�3�316�3���4��}�}�*�t�F�|�{�/J��C����
�A�t�G�3�	�317���J���9���318s�2L*�L*c�:�UR"U40UD6 g! g=f)z!Is there a file at the given pathTF�r��rjr�rs   rr�AbstractFileSystem.exists�s%��	��I�I�d�%�f�%���	��s��c�$�URU5$)z=If there is a file at the given path (including319broken links))rrs   r�lexists�AbstractFileSystem.lexists�s���{�{�4� � rc�(�URU5nUR"URU54SS0UD6nUVs/sHoDSRS5U:XdMUPM  nnU(aUS$UR"U4SS0UD6nURS5nUVs/sHoDSRS5U:XdMUPM  nn[	U5S:XaSUS;aSUSS'US$[	U5S:�dU(aUSS	S320.$[U5es snfs snf)aGive details of entry at path321 322Returns a single dictionary, with exactly the same information as ``ls``323would with ``detail=True``.324 325The default implementation calls ls and could be overridden by a326shortcut. kwargs are passed on to ```ls()``.327 328Some file systems might not be able to measure the file's size, in329which case, the returned dict will include ``'size': None``.330 331Returns332-------333dict with keys: name (full path in the FS), size (in bytes), type (file,334directory, or something else) and other FS-specific keys.335r�Tr�rZrr	r�Nr�)r�r�r)r�r�r�r�r�r�)rjr�rr��o�out1s      rr��AbstractFileSystem.info�s��"�#�#�D�)���g�g�d�l�l�4�(�@��@��@���?�#�Q�6��!1�!1�#�!6�$�!>�q�#��?���q�6�M��g�g�d�2�4�2�6�2���{�{�3����@�3�a�F�)�"2�"2�3�"7�4�"?��3��@��t�9��>��T�!�W�$�"&��Q������7�N�
��Y��]�c� �!�[�A�A�#�D�)�)��@��336As�D337�D338�D�6Dc�J�[[URU55S5$)arUnique value for current version of file339 340If the checksum is the same from one moment to another, the contents341are guaranteed to be the same. If the checksum changes, the contents342*might* have changed.343 344This should normally be overridden; default will probably capture345creation/modification timestamp (which would be good) or maybe346access timestamp (which would be bad)347ry)rzrr�r�s  r�checksum�AbstractFileSystem.checksum�s���8�D�I�I�d�O�,�b�1�1rc�D�URU5RSS5$)zSize in bytes of filer�N)r�r'r�s  rr��AbstractFileSystem.size�s���y�y���"�"�6�4�0�0rc�N�UVs/sHo RU5PM sn$s snf)z-Size in bytes of each file in a list of paths)r�)rj�pathsr�s   rr��AbstractFileSystem.sizes�s ��&+�,�e��	�	�!��e�,�,��,s�"c�R�URU5SS:H$![a gf=f)zIs this entry directory-like?rr�F)r�r�r�s  rr��AbstractFileSystem.isdir�s1��	��9�9�T�?�6�*�k�9�9���	��	�s��348&�&c�@�URU5SS:H$! g=f)zIs this entry file-like?r�fileFrr�s  rr��AbstractFileSystem.isfile�s)��	��9�9�T�?�6�*�f�4�4��	��s��c��UR"U4SUUUS.UD6nUR5sSSS5 $!,(df   g=f)z�Get the contents of the file as a string.349 350Parameters351----------352path: str353    URL of file on this filesystems354encoding, errors, newline: same as `open`.355�r��mode�encoding�errors�newlineN��open�read)rjr�r3r4r5rr�s       r�	read_text�AbstractFileSystem.read_text�sL���Y�Y��356�����357��
358���6�6�8�359�360�361�s	�3�362Ac��UR"U4SUUUS.UD6nURU5sSSS5 $!,(df   g=f)z�Write the text to the given file.363 364An existing file will be overwritten.365 366Parameters367----------368path: str369    URL of file on this filesystems370value: str371    Text to write.372encoding, errors, newline: same as `open`.373�wr1N)r7�write)rjr��valuer3r4r5rr�s        r�374write_text�AbstractFileSystem.write_text�sN���Y�Y��375�����376��
377���7�7�5�>�378�379�380�s	�4�381Ac��UR"US40UD6nUb@US:�aURU5 O(UR[SURU-55 Ub?US:aURU-nUR	X5R5-3825sSSS5 $UR	5sSSS5 $!,(df   g=f)a Get the content of a file383 384Parameters385----------386path: URL of file on this filesystems387start, end: int388    Bytes limits of the read. If negative, backwards from end,389    like usual python slices. Either can be None for start or390    end of file, respectively391kwargs: passed to ``open()``.392�rbNr)r7�seek�maxr�r8�tell)rjr��start�endrr�s      r�cat_file�AbstractFileSystem.cat_files����Y�Y�t�T�
,�V�
,��� ��A�:��F�F�5�M��F�F�3�q�!�&�&�5�.�1�2�����7��&�&�3�,�C��v�v�c�F�F�H�n�-�-�
,��6�6�8�-�
,�
,�s�A<B4�B4�4393C�	overwritec���US:XaURU5(a[eUR"US40UD6nURU5 SSS5 g!,(df   g=f)zSet the bytes of given file�create�wbN)r�FileExistsErrorr7r=)rjr�r>r2rr�s      r�	pipe_file�AbstractFileSystem.pipe_file1sL���8�����D� 1� 1�"�!�
�Y�Y�t�T�
,�V�
,��
�G�G�E�N�-�
,�
,�s�A�394A c�.�[U[5(a$UR"URU5U40UD6 g[U[5(a=UR5H(upEUR"URU5U40UD6 M* g[
S5e)aOPut value into path395 396(counterpart to ``cat``)397 398Parameters399----------400path: string or dict(str, bytes)401    If a string, a single remote location to put ``value`` bytes; if a dict,402    a mapping of {path: bytesvalue}.403value: bytes, optional404    If using a single path, these are the bytes to put there. Ignored if405    ``path`` is a dict406zpath must be str or dictN)r~r�rOr��dictr�r�)rjr�r>rrJ�vs      r�pipe�AbstractFileSystem.pipe:sz���d�C� � ��N�N�4�/�/��5�u�G��G�
��d�
#�
#��407�408�������t�3�3�A�6��D�V�D�%��7�8�8rc��Ub[e[U[5(d[e[U[5(dU/[	U5-n[U[5(dU/[	U5-n[	U5[	U5:wd[	U5[	U5:wa[409e/n[
XU5H(up�n410URURX�U41155 M* U$![a#n412US:XaURU4135 Sn414A415MUeSn416A417ff=f)aGet the contents of byte ranges from one or more files418 419Parameters420----------421paths: list422    A list of of filepaths on this filesystems423starts, ends: int or list424    Bytes limits of the read. If using a single int, the same value will be425    used to read all the specified files.426N�return)427rnr~r��	TypeErrorr�r��zipr�rH�	Exception)rjr(�starts�ends�max_gapr�rr�r��sr�s           r�428cat_ranges�AbstractFileSystem.cat_rangesPs�����%�%��%��&�&��O��&�$�'�'��X��E�429�*�F��$��%�%��6�C��J�&�D��v�;�#�e�*�$��D�	�S��Z�(?������5�$�/�G�A�!�
��430�431�4�=�=��q�1�2�0��432���
��x�'��J�J�q�M�M���	
�s�8!C�433D�)D�D�Dc�t�UR"U4SU0UD6n[U5S:�d-[U[5(dUSUR	U5:wa#0nUHnUR434"U40UD6Xa'M U$UR435"US40UD6$![a"nUS:XaeUS:Xa436XvU'SnAMVSnAM\SnAff=f)a�Fetch (potentially multiple) paths' contents437 438Parameters439----------440recursive: bool441    If True, assume the path(s) are directories, and get all the442    contained files443on_error : "raise", "omit", "return"444    If raise, an underlying exception will be raised (converted to KeyError445    if the type is in self.missing_exceptions); if omit, keys with exception446    will simply not be included in the output; if "return", all keys are447    included in the output, but the value will be bytes or an exception448    instance.449kwargs: passed to cat_file450 451Returns452-------453dict of {path: contents} if there are multiple paths454or the path has been otherwise expanded455�	recursiver	rr�rWN)�expand_pathr�r~r�r�rHrZ)rjr�rbr�rr(r�r�s        r�cat�AbstractFileSystem.catrs���*� � ��E��E�f�E����J��N��$��%�%��Q�x�4�/�/��5�5��C���&� $�
�
�d� =�f� =�C�I���J��=�=��q��4�V�4�4��!�&��7�*���8�+�$%�D�	�,��&�s�B�456B7�B2�2B7c���SSKJn [U5(aUnO,URU5(a[R457"USS9 gU"SS9nURUR
U5SS9 UR"US40UD6nUc[US5nUR[US	S55 Sn	U	(aTURUR5n	URU	5n458U459c[U	5n460URU4615 U	(aMT[U5(dUR5 SSS5 g![U5(dUR5 ff=f!,(df   g=f)462z Copy single remote file to localr	)�LocalFileSystemT�r�N)�463auto_mkdirrBrMr�)�implementations.localrgrr�r+r�r�r7�set_sizer3r8�	blocksizer=r��relative_update�close)rj�rpath�lpath�callback�outfilerrg�fs�f1�data�segment_lens           r�get_file�AbstractFileSystem.get_file�s*��:��e����G�
�Z�Z��
�
��K�K���-��
��
-��464���B�J�J�u�%���5�
�Y�Y�u�d�
-�f�
-�����u�d�+��
$��!�!�'�"�f�d�";�<�����7�7�4�>�>�2�D�")�-�-��"5�K�"�*�&)�$�i���,�,�[�9��d�"�%�(�(��M�M�O�.�
-��"�%�(�(��M�M�O�)��.�
-�s%�?E�A7D2�	 E�2#E�E�465E&c���[U[5(a[U[5(aUnUnGOISSKJn	Jn466Jn [U[5nUR"U4X5S.UD6nU(aJU(aUb@UV
s/sH+o�"U
5(aMURU
5(aM)U
PM- nn
U(dg[U[5(aU467"U5n[U5S:Hn[U[5=(a% U"U5=(d U	"5RU5nU=(aH [U5=(a U=(d- [U5(+=(a U=(a
 U"U5(+n[UUUU(+S9nUR[U55 UR[X�55H4up!URX5nUR "X4SU0UD6 SSS5 M6 gs sn
f!,(df   MM=f)a$Copy file(s) to local.468 469Copies a specific file or tree of files (if recursive=True). If lpath470ends with a "/", it will be assumed to be a directory, and target files471will go within. Can submit a list of paths, which may be glob-patterns472and will be expanded.473 474Calls get_file for each source.475r	�rg�make_path_posix�trailing_sep�rbr�N�r�flattenrq)r~r�rjrgr{r|r�rcr�r�rrrk�wraprY�branchedrw)rjrorprbrqr�r�rpaths�lpathsrgr{r|�
source_is_strr��source_is_file�dest_is_dirr�childs                  rr'�AbstractFileSystem.get�s���$�e�T�"�"�z�%��'>�'>��F��F�
�
�'�u�c�2�M��%�%���!*��AG��F��i�8�3G�%+�V�V��L��O�!�t�z�z�RS�}�!�V��V����%��%�%�'��.�� ��[�A�-�N�$�U�C�0���U�#�E��'8�'>�'>�u�'E�
�#���5�!�4�n�V�!�%�(�(�T�[�T��e�AT�=T�
�!����)�)�	�F�	���#�f�+�&�$�M�M�#�f�*=�>�L�E��"�"�5�0�E��
�
�e�E�U�E�f�E�1�0�?��1W�21�0�s�5G'�	G'�!G'�G,�,476G;	c��US:XaURU5(a[e[RR	U5(aURUSS9 g[
US5nURSS5nURU5 URS5 URUR[R"U55SS9 UR"US40UD6nUR5U:aaURUR5n	URU	5n477U478c[!U	5n479UR#U4805 UR5U:aMaSSS5 SSS5 g!,(df   N=f!,(df   g=f)	zCopy single file to remoterLTrhNrBrr�rM)rrNr+r�r�r�r7rCrk�mkdirsr��fspathrEr8rlr=r�rm)rjrprorqr2rrtr��f2rurvs           r�put_file�AbstractFileSystem.put_file�s*���8�����E� 2� 2�!�!�
�7�7�=�=�����M�M�%�$�M�/��
�%��
�"��7�7�1�a�=�D����d�#��G�G�A�J��K�K����R�Y�Y�u�%5�6��K�F����5�$�1�&�1�R��g�g�i�$�&��7�7�4�>�>�2�D�"$�(�(�4�.�K�"�*�&)�$�i���,�,�[�9��g�g�i�$�&�2�
�
�2�1��
�
�s&�$A<E8� A4E'�E8�'481E5	�1E8�8482Fc�|�[U[5(a[U[5(aUnUnGO�SSKJn	Jn483Jn [U[5nU(aU484"U5nU	"5n
U
R"U4X5S.UD6nU(aJU(aUb@UVs/sH+o�"U5(aMU
RU5(aM)UPM- nnU(dg[U5S:Hn[U[5=(a  U"U5=(d URU5n[U[5(aURU5O UVs/sHo�RU5PM snnU=(aH [U5=(a U=(d- [U5(+=(a U=(a
 U"U5(+n[UUUU(+S9nUR[U55 UR[X�55H4upUR!X5nUR""X4SU0UD6 SSS5 M6 gs snfs snf!,(df   MR=f)z�Copy file(s) from local.485 486Copies a specific file or tree of files (if recursive=True). If rpath487ends with a "/", it will be assumed to be a directory, and target files488will go within.489 490Calls put_file for each source.491r	rzr}Nr~rq)r~r�rjrgr{r|r�rcr�r�r�rrrkr�rYr�r�)rjrprorbrqr�rr�r�rgr{r|r�rsr�r�r�rr�s                   r�put�AbstractFileSystem.puts���"�e�T�"�"�z�%��'>�'>��F��F�
�
�'�u�c�2�M��'��.�� �"�B��^�^���!*��AG��F��i�8�3G�%+�T�V��L��O�!�r�x�x�PQ�{�!�V��T��� ��[�A�-�N�$�U�C�0���U�#�8�t�z�z�%�'8�
��e�S�)�)��$�$�U�+�7<�=�u�!�*�*�1�-�u�=�
�492#���5�!�4�n�V�!�%�(�(�T�[�T��e�AT�=T�
�!����)�)�	�F�	���#�f�+�&�$�M�M�#�f�*=�>�L�E��"�"�5�0�E��
�
�e�E�U�E�f�E�1�0�?��5U��>�1�0�s$�H"�H"�7H"�6H'�?H,�,493H;	c�~�URUS5nURU5sSSS5 $!,(df   g=f)z&Get the first ``size`` bytes from filerBNr6�rjr�r�r�s    r�head�AbstractFileSystem.headTs)��
�Y�Y�t�T�
"�a��6�6�$�<�#�
"�
"�s�.�494<c���URUS5nUR[U*UR*5S5 UR	5sSSS5 $!,(df   g=f)z%Get the last ``size`` bytes from filerBr�N)r7rCrDr�r8r�s    r�tail�AbstractFileSystem.tailYsD��
�Y�Y�t�T�
"�a�
�F�F�3��u�q�v�v�g�&��*��6�6�8�#�
"�
"�s�8A�495A#c��[errm�rj�path1�path2rs    r�cp_file�AbstractFileSystem.cp_file_s��!�!rc�\�Uc496U(aSnOUcSn[U[5(a[U[5(aUnUnGO#SSKJn	 [U[5n497UR498"U4X4S.UD6nU499(aJU(aUb@UVs/sH+o�"U5(aMUR
U5(aM)UPM- nnU(dg[U5S:Hn[U[5=(a  U	"U5=(d UR
U5n
U500=(aH [U5=(a U=(d- [U5(+=(a U
=(a
 U	"U5(+n[UUUU501(+S9n[Xx5HunnUR"UU40UD6 M gs snf![a US:XaeM9f=f)aCopy within two locations in the filesystem502 503on_error : "raise", "ignore"504    If raise, any not-found exceptions will be raised; if ignore any505    not-found exceptions will cause the path to be skipped; defaults to506    raise unless recursive is true, where the default is ignore507N�ignorer�r	)r|r}r~)
r~r�rjr|r�rcr�r�rrrYr�r�)rjr�r�rbr�r�r�paths1�paths2r|r�r�r�r�r�p1�p2s                 r�copy�AbstractFileSystem.copybs�����	��H�
�
��H��e�T�"�"�z�%��'>�'>��F��F�;�&�u�c�2�M��%�%���!*��AG��F��i�8�3G�%+�V�V��L��O�!�t�z�z�RS�}�!�V��V��� ��[�A�-�N�$�U�C�0���U�#�8�t�z�z�%�'8�
�#���5�!�4�n�V�!�%�(�(�T�[�T��e�AT�=T�
�!����)�)�	�F��&�)�F�B��
����R��.�v�.�*��)W��.%�
��w�&��'�
�s$�F�F�/F�8F�F+�*F+c508���UbUS:a[S5e[U[[R45(aUR509"U/X#40UD6nGO[
5nUVs/sHo`RU5PM nnUH�n[U5(ai[
UR"U4SU0UD65nXW-nU(a>UbUS::aMGU[
UR510"[U54UUbUS-511OSS.UD65-nM|U(a$[
UR"U4USSS.UD65nXX-nXe;dM�USLdURU5(dM�URU5 M� U(d[U5e[U5$s snf)	z�Turn one or more globs or directories into a list of all matching paths512to files or directories.513 514kwargs are passed to ``glob`` or ``find``, which may in turn call ``ls``515Nr	r�r�r}TFr�)r�r~r�r+�PathLikerc�setr�rrr�r�r�addr�r�)	rjr�rbr�rr�r��bit�recs	         rrc�AbstractFileSystem.expand_path�s�����H�q�L��:�;�;��d�S�"�+�+�.�/�/��"�"�D�6�9�I�&�I�C��%�C�59�:�T��(�(��+�T�D�:����Q�<�<��d�i�i��G�H�G��G�H�C��J�C� �$�/�H��M�$��s� �,�,� $�S�	��*3�9A�9M��A��SW��#)�	� �������	�	���(0�4���QW���C�516�J�C��<�Y�%�%7�4�;�;�q�>�>��G�G�A�J�9�:�#�D�)�)��c�{���A;s�E:c�|�X:Xa[RSU5 gURXX4SS9 URXS9 g)z)Move file(s) from one location to anotherz6%s mv: The paths are the same, so no files were moved.r�)rbr��onerror)rbN)�logger�debugr��rm)rjr�r�rbr�rs      r�mv�AbstractFileSystem.mv�sA���>��L�L�Q�SW�X�
�I�I��	�g�
�
�
�G�G�E�G�/rc�&�URU5 g)z
Delete a fileN)�_rmr�s  r�rm_file�AbstractFileSystem.rm_file�s
������rc��[e)zDelete one filermr�s  rr��AbstractFileSystem._rm�s517��"�!rc�j�URXUS9n[U5HnURU5 M g)asDelete files.518 519Parameters520----------521path: str or list of str522    File(s) to delete.523recursive: bool524    If file(s) are directories, recursively delete contents and then525    also remove the directory526maxdepth: int or None527    Depth to pass to walk for finding files to delete, if recursive.528    If None, there will be no limit and infinite recursion may be529    possible.530r}N)rc�reversedr�)rjr�rbr�r�s     rr��AbstractFileSystem.rm�s2������H��M���$��A��L�L��O� rc���URU5nSU;a=URSS5SRUR5nURU-$UR$)NrZr	r)r�r��lstripr�)rr�r�s   rr��AbstractFileSystem._parent�sV���"�"�4�(���$�;��[�[��a�(��+�2�2�3�?�?�C�F��?�?�V�+�+��?�?�"rc�&�[UUUUU4SU0UD6$)z4Return raw bytes-mode file-like from the file-system�
cache_options)�AbstractBufferedFile)rjr�r2�531block_size�532autocommitr�rs       r�_open�AbstractFileSystem._open�s4��$������533�(�
534��535�	536rc	�0�SSKnURU5nSU;afURSS5S-nSVs0sHnX�;dM537X�RU5_M n	nUR"UR538"UU4UUUS.UD640U	D6$URSUR(+5n539UR"U4UUU540US	.UD6nUb!SS541KJ	n SSK542Jn
 U
"X5nX�nU"X�SS9nU543(d+S
U;a%URRRU5 U$s snf)a[544Return a file-like object from the filesystem545 546The resultant instance must function correctly in a context ``with``547block.548 549Parameters550----------551path: str552    Target file553mode: str like 'rb', 'w'554    See builtin ``open()``555    Mode "x" (exclusive write) may be implemented by the backend. Even if556    it is, whether  it is checked up front or on commit, and whether it is557    atomic is implementation-dependent.558block_size: int559    Some indication of buffering - this is a value in bytes560cache_options : dict, optional561    Extra arguments to pass through to the cache.562compression: string or None563    If given, open file using compression codec. Can either be a compression564    name (a key in ``fsspec.compression.compr``) or "infer" to guess the565    compression from the filename suffix.566encoding, errors, newline: passed on to TextIOWrapper for text mode567rN�b�tr])r3r4r5)r�r��compressionr�)r2r�r�r�)�compr)�get_compression)r2r0)�ior��replacer=�
TextIOWrapperr7rcr��fsspec.compressionr��fsspec.corer�r�r�r�)rjr�r2r�r�r�rr�rJ�text_kwargs�acr�r�r��compresss               rr7�AbstractFileSystem.opensT��D	��#�#�D�)���d�?��<�<��R�(�3�.�D�;��:�A��;�!��:�:�a�=� �:�
��568�#�#��	�	���� *�"/� +���
�569��570�571
����L�d�m�m�*;�<�B��572�573����%��+���
�A��&�4�7�-�d�@�� �-���Q�!�W�-���#�T�/�� � �&�&�-�-�a�0��H��Is�	D�Dc��U(dURU5(dUR"US40UD6 SSS5 g[e!,(df   g=f)z�Create empty file, or update timestamp574 575Parameters576----------577path: str578    file location579truncate: bool580    If True, always set file size to 0; if False, update timestamp and581    leave file unchanged, if backend allows this582rMN)rr7rn)rjr��truncaters    r�touch�AbstractFileSystem.touch\sD���4�;�;�t�,�,����4��0��0��1�0�&�%�1�0�s�A�583Ac��[[URU55R55R	5$)z2Hash of file properties, to tell if it has changed)rr�r��encode�	hexdigestr�s  r�ukey�AbstractFileSystem.ukeyms,���c�$�)�)�D�/�*�1�1�3�4�>�>�@�@rc��URUS5nURnUcUnUbX#-U:�aXb-584n[XRX45sSSS5 $!,(df   g=f)a2Read a block of bytes from585 586Starting at ``offset`` of the file, read ``length`` bytes.  If587``delimiter`` is set then we ensure that the read starts and stops at588delimiter boundaries that follow the locations ``offset`` and ``offset589+ length``.  If ``offset`` is zero then we start at zero.  The590bytestring returned WILL include the end delimiter string.591 592If offset+length is beyond the eof, reads to eof.593 594Parameters595----------596fn: string597    Path to filename598offset: int599    Byte offset to start read600length: int601    Number of bytes to read. If None, read to end.602delimiter: bytes (optional)603    Ensure reading starts and stops at delimiter bytestring604 605Examples606--------607>>> fs.read_block('data/file.csv', 0, 13)  # doctest: +SKIP608b'Alice, 100\nBo'609>>> fs.read_block('data/file.csv', 0, 13, delimiter=b'\n')  # doctest: +SKIP610b'Alice, 100\nBob, 200\n'611 612Use ``length=None`` to read to the end of the file.613>>> fs.read_block('data/file.csv', 0, None, delimiter=b'\n')  # doctest: +SKIP614b'Alice, 100\nBob, 200\nCharlie, 300'615 616See Also617--------618:func:`fsspec.utils.read_block`619rBN)r7r�r)rj�fn�offset�length�	delimiterr�r�s       rr�AbstractFileSystem.read_blockqsT��J�Y�Y�r�4�
 �A��6�6�D��~�����F�O�d�$:�����a��;�
!�
 �
 �s�,A	�	620A)�include_passwordc	�T�SSKJn [R"U[SU4SU05S9$)az621JSON representation of this filesystem instance.622 623Parameters624----------625include_password: bool, default True626    Whether to include the password (if any) in the output.627 628Returns629-------630JSON string with keys ``cls`` (the python location of this class),631protocol (text name of this class's protocol, first one in case of632multiple), ``args`` (positional args, usually empty), and all other633keyword arguments as their own keys.634 635Warnings636--------637Serialized filesystems may contain sensitive information which have been638passed to the constructor, such as passwords and tokens. Make sure you639store and send them in a secure environment!640r	��FilesystemJSONEncoder�_FilesystemJSONEncoderr�r�)�jsonr��dumpsr)rjr�r�s   r�to_json�AbstractFileSystem.to_json�s5��,	0��z�z���(�&�(�#�%5�6��641�	642rc�6�SSKJn [R"XS9$)a�643Recreate a filesystem instance from JSON representation.644 645See ``.to_json()`` for the expected structure of the input.646 647Parameters648----------649blob: str650 651Returns652-------653file system instance, not necessarily of this particular class.654 655Warnings656--------657This can import arbitrary modules (as determined by the ``cls`` key).658Make sure you haven't installed any modules that may execute malicious code659at import time.660r	��FilesystemJSONDecoderr�)r�r��loads)�blobr�s  r�	from_json�AbstractFileSystem.from_json�s��*	0��z�z�$�:�:rc	��SSKJn U"5n[U5nURn[	UR6615nU(dUR
SS5 [	SURSUR3[U[[45(aUSOUURUR5S.URU5D6$)	a�662JSON-serializable dictionary representation of this filesystem instance.663 664Parameters665----------666include_password: bool, default True667    Whether to include the password (if any) in the output.668 669Returns670-------671Dictionary with keys ``cls`` (the python location of this class),672protocol (text name of this class's protocol, first one in case of673multiple), ``args`` (positional args, usually empty), and all other674keyword arguments as their own keys.675 676Warnings677--------678Serialized filesystems may contain sensitive information which have been679passed to the constructor, such as passwords and tokens. Make sure you680store and send them in a secure environment!681r	r��passwordN�:r)rr\rr)r�r�rr\rRrFr=rQrPr~r:r��make_serializablerE)rjr�r��json_encoderr�protorFs       r�to_dict�AbstractFileSystem.to_dict�s���,	0�,�.���4�j���
�
���t�3�3�4������682�D�1��683��>�>�"�!�C�L�L�>�2�!+�E�E�4�=�!A�!A�U�1�X�u��/�/��0A�0A�B�684��,�,�_�=�	685�	686rc�$�SSKJn U"5n[U5nURU5nUc[	S5eURSS5 URSS5 U"UR
URSS550UR
U5D6$)	a�687Recreate a filesystem instance from dictionary representation.688 689See ``.to_dict()`` for the expected structure of the input.690 691Parameters692----------693dct: Dict[str, Any]694 695Returns696-------697file system instance, not necessarily of this particular class.698 699Warnings700--------701This can import arbitrary modules (as determined by the ``cls`` key).702Make sure you haven't installed any modules that may execute malicious code703at import time.704r	r�Nz#Not a serialized AbstractFileSystemrr\rr)r�r�rR�try_resolve_fs_clsr�r=�unmake_serializable)�dctr��json_decoderrs    r�	from_dict�AbstractFileSystem.from_dicts���*	0�,�.���3�i��#�6�6�s�;���;��B�C�C�����t�����705�D�!��
�
-�
-�c�g�g�f�b�.A�
B�706��.�.�s�3�707�	708rc��U$)zG709Make a version of the FS instance which will be acceptable to pyarrow710rros r�_get_pyarrow_filesystem�*AbstractFileSystem._get_pyarrow_filesystem's	��711�rc�"�SSKJn U"UUUUUS9$)z�Create key/value store based on this file-system712 713Makes a MutableMapping interface to the FS at the given root path.714See ``fsspec.mapping.FSMap`` for further details.715r	)�FSMap)�checkrL�missing_exceptions)�mappingr	)rjrr716rLrr	s      r�717get_mapper�AbstractFileSystem.get_mapper.s#��	#������1�718�	719rc�8�URR5 g)al720Clear the cache of filesystem instances.721 722Notes723-----724Unless overridden by setting the ``cachable`` class attribute to False,725the filesystem class stores a reference to newly created instances. This726prevents Python's normal rules around garbage collection from working,727since the instances refcount will not drop to zero until728``clear_instance_cache`` is called.729N)r*r@r�s r�clear_instance_cache�'AbstractFileSystem.clear_instance_cache>s��	�730�731���rc��[e)z=Return the created timestamp of a file as a datetime.datetimermr�s  r�created�AbstractFileSystem.createdM���!�!rc��[e)z>Return the modified timestamp of a file as a datetime.datetimermr�s  r�modified�AbstractFileSystem.modifiedQrrc	��S#Sjn	/n732U(aU733RU5 U(Ga�SU-nURUSS9nURSS9 Ub#[U5U:�aUSUn
[U5U-734nOUn
Sn[	U
5GH�unnU[U
5S	-735:H=(a US:HnU(aS736SUS-737--O738S
SUS-739--nUS-
nUU(aUO740SSUS	-741---n[742RRURSS55nU(a�URS5S:Xa�URURSS5SS9n[SU55n[SU55nUS:Xa	US:XaSnO�US:XaSUSUS	:�aSOSS3nOsUS:XaSUSUS	:�aSOSS3nO[SUSUS	:�aSOSSUSUS	:�aSOSS3	nO;U(a2URS5S:XaSU	"URSS55S3nOSnU743RUUUU35 URS5S:XdGM�US:�dGM�U744RURURSS5US	-745UUUUSUS95 GM� US:�a&US 3nU746RUS747SUS-748--SU35 S!RS"U74955$)$ai750Return a tree-like structure of the filesystem starting from the given path as a string.751 752Parameters753----------754    path: Root path to start traversal from755    recursion_limit: Maximum depth of directory traversal756    max_display: Maximum number of items to display per directory757    display_size: Whether to display file sizes758    prefix: Current line prefix for visual tree structure759    is_last: Whether current item is last in its level760    first: Whether this is the first call (displays root path)761    indent_size: Number of spaces by indent762 763Returns764-------765    str: A string representing the tree structure.766 767Example768-------769    >>> from fsspec import filesystem770 771    >>> fs = filesystem('ftp', host='test.rebex.net', user='demo', password='password')772    >>> tree = fs.tree(display_size=True, recursion_limit=3, indent_size=8, max_display=10)773    >>> print(tree)774c�N�SHupUSU-:�dMX-SSUS3s $ US3$)zFormat bytes as text.))�Pl )�Tl)�Gi@)�Mi)rJ�g�������?z.2f� r��Br)�n�prefixrJs   r�format_bytes�-AbstractFileSystem.tree.<locals>.format_bytes{sA���	����a��<��e�C�[��&���3�3���S��7�Nrr T)r�c�N�URS5S:gURSS54$)Nrr�r�r]�r')�xs r�<lambda>�)AbstractFileSystem.tree.<locals>.<lambda>�s!��q�u�u�V�}��;�Q�U�U�6�2�=N�Or)�keyNrr	u└u─r�u├u│r�r]rr�c3�R# �UHoRS5S:XdMSv� M g7f)rr-r	Nr'�r4�sub_items  rr6�*AbstractFileSystem.tree.<locals>.<genexpr>�s$���$�*6�h�,�,�v�:N�RX�:X���,�s�'�	'c3�T# �UHnURS5S:XdMSv� M  g7f)rr�r	Nr'r-s  rr6r/�s*���&�(4�H�#�<�<��/�;�>���(4�s�(�	(z (empty folder)z (z775 subfolderr^�)z file�, r-r�F)r��recursion_limit�max_display�display_sizer#�is_last�first�indent_sizez more item(s) not displayed.�776c3�6# �UHo(dMUv� M g7frr)r4r�s  rr6r/�s���0�F�q�a���F�s�777�	)r"rzrWr�)r�r��sortr��	enumerater+r��basenamer'r��tree�join)rjr�r3r4r5r#r6r7r8r$�result�indent�contents�displayed_contents�remaining_count�i�item�is_last_item�branch�778new_prefixr��sub_contents�	num_files�num_foldersr��more_messages                          rr>�AbstractFileSystem.treeUs`��L	�����M�M�$����;�&�F��w�w�t�D�w�1�H��M�M�O�
�
��&�3�x�=�;�+F�%-�l�{�%;�"�"%�h�-�+�"=��%-�"�"#��$�%7�8���4� !�S�);�%<�q�%@� @� �#�q�(��$��U�k�A�o�6�7��%�;��?�";�<��779�#�
��#�*�F���{�Q��8O�0O��780��w�w�'�'������(<�=���D�H�H�V�$4��$C�#'�7�7�4�8�8�F�B�+?��7�#M�L� #�$�*6�$�!�I�#&�&�(4�&�#�K�!�A�~�+��*:�0��"�a��!#�K�=�781�+�PQ�/�3�WY�:Z�Z[�\��$��)�!#�I�;�e�9�q�=�C�b�3Q�QR�S��!#�I�;�e�9�q�=�C�b�3Q�QS�T_�S`�`j�r}�AB�sB�kn�HJ�kK�KL� M��!�d�h�h�v�&6�&�&@���T�X�X�f�a�-@� A�B�!�D�D��D��
�
�������t�f�=�>��8�8�F�#�{�2���7J��M�M��	�	�!%���&�"�!5�,;�a�,?�(3�)5�#-�$0�"'�(3�"�	��Y9�r��"�"1�!2�2N�O���
�
��h�u���q��(A�B�C�1�\�N�S���y�y�0�F�0�0�0rc�,�UR"U4X#S.UD6$)z'Alias of `AbstractFileSystem.cat_file`.�rFrG)rH)rjr�rFrGrs     r�782read_bytes�AbstractFileSystem.read_bytes�s���}�}�T�B��B�6�B�Brc�*�UR"X40UD6 g)z(Alias of `AbstractFileSystem.pipe_file`.N)rO)rjr�r>rs    r�write_bytes�AbstractFileSystem.write_bytes�s�����t�-�f�-rc�,�UR"U4SU0UD6$)z$Alias of `AbstractFileSystem.mkdir`.r�)r�r�s    r�makedir�AbstractFileSystem.makedir�s���z�z�$�H�~�H��H�Hrc� �URXS9$)z'Alias of `AbstractFileSystem.makedirs`.rh)r�r�s   rr��AbstractFileSystem.mkdirs�s���}�}�T�}�5�5rc�,�UR"U4SU0UD6$)z!Alias of `AbstractFileSystem.ls`.r�)r�r�s    r�listdir�AbstractFileSystem.listdir�s���w�w�t�5�F�5�f�5�5rc�(�UR"X40UD6$)z#Alias of `AbstractFileSystem.copy`.)r�r�s    r�cp�AbstractFileSystem.cp�s���y�y��0��0�0rc�(�UR"X40UD6$�z!Alias of `AbstractFileSystem.mv`.�r�r�s    r�move�AbstractFileSystem.move�����w�w�u�.�v�.�.rc�(�UR"U40UD6$)z#Alias of `AbstractFileSystem.info`.rrs   r�stat�AbstractFileSystem.stat�s���y�y��(��(�(rc�,�UR"U4X#S.UD6$)z!Alias of `AbstractFileSystem.du`.)r�r�)r�)rjr�r�r�rs     r�783disk_usage�AbstractFileSystem.disk_usage�s���w�w�t�F�5�F�v�F�Frc�(�UR"X40UD6$rbrcr�s    r�rename�AbstractFileSystem.renamerfrc�"�URXUS9$)z!Alias of `AbstractFileSystem.rm`.r})r�)rjr�rbr�s    r�delete�AbstractFileSystem.deletes���w�w�t�8�w�D�Drc�,�UR"X4SU0UD6$)z"Alias of `AbstractFileSystem.put`.rb)r�)rjrprorbrs     r�upload�AbstractFileSystem.upload����x�x��D�	�D�V�D�Drc�,�UR"X4SU0UD6$)z"Alias of `AbstractFileSystem.get`.rbr')rjrorprbrs     r�download�AbstractFileSystem.downloadrvrc��[S5e)a�Create a signed URL representing the given path784 785Some implementations allow temporary URLs to be generated, as a786way of delegating credentials.787 788Parameters789----------790path : str791     The path on the filesystem792expiration : int793    Number of seconds to enable the URL for (if supported)794 795Returns796-------797URL : str798    The signed URL799 800Raises801------802NotImplementedError : if method is not implemented for a filesystem803z+Sign is not implemented for this filesystemrm)rjr��804expirationrs    r�sign�AbstractFileSystem.signs��,"�"O�P�Prc��g)NFrros r�_isfilestore�AbstractFileSystem._isfilestore+s��805r)rbrDrcrerdrf)r�r�rWr�r)T�F)NT�omit)NFF)TNF)NNN)NN)rJ)NrW)Fr�)r)FNN)FN)rBNTN)rBNNN)r��boolrWr�)r�r�rWrX)r�r�rWr^)rr^rWrX)r]FFN)rZr��Fr]TT�)r�r�r3rzr4rzr5r�r#r�r6r�r7r�r8rzrWr�)TN)rY)krPrQrRrSrTrArbrlr�r\�__annotations__rBrGr9r�rr�r;r<r&�propertyrprsrvr{r�r��classmethodr�r��staticmethodr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr�r#r�r�r�r�r9r?rHrOrTr_rdr806rwr'r�r�r�r�r�r�rcr�r�r�r�r�r�r7r�r�rr�r�r�rrr
rrrr>rQrTrWr�r\r_rdrhrkrnrqrtrxr|rrUrrrrXrXds�����H��G��I�807
�C�0:�H�-�:��G��J����K�"��"$�� ��"�!�#�#�'�R�"��"������'�S�T��'��'�$'��808��809������!��!� �8�A�"
�$
� 
�'"�R�2\$�|$7�L �Dl�\�!�810 *�D2�1�-����(@D�"�2�2�9�.;C� �D&5�P/?��$�D�!��
>F�B&6�K�:�8�!��
BF�H �811�"�FJ�6�p.�`	0��"�812�&�#��#�����
813�.����
L�\&�"A�+<�Z37�814�B�;��;�037�&815�P�$816��$817�L�818� ����"�"�� ��"�����E1��E1��E1��	E1�819�E1��
E1��E1��E1��E1�820
�E1�TC�.�I�6�6�1�/�)�G�/�E�E�E�Q�0rrX)�	metaclassc�t�\rSrSrSrSrSrS)Sjr\S5r	\	RS5r	\S5r\S	5r\RS8215rSr
SrS
rSrSrSrS*SjrSrS+SjrS+SjrSrSrS,SjrSrS-SjrSrSrSrSrSr Sr!S r"S!r#S"r$S#r%S$r&S%r'\'r(S&r)S'r*S(r+g).r�i3a+Convenient class to derive from to provide buffering822 823In the case that the backend does not provide a pythonic file-like object824already, this class contains much of the logic to build one. The only825methods that need to be overridden are ``_upload_chunk``,826``_initiate_upload`` and ``_fetch_range``.827iPNc	�T�SSKJn828 X lXlX0lUS;aUR829OUUlSUlXPlSUl	SUl830SUlUc0nSU	;a/[R"S[5 U	RS5US'X�lUS	;a[#S8315eUS:XaOUbX�lOUR&SUlX�"URUR(UR$40UD6Ulg[,R."5UlSUlSUlSUlg)
a_832Template for files with buffered reading and writing833 834Parameters835----------836fs: instance of FileSystem837path: str838    location in file-system839mode: str840    Normal file modes. Currently only 'wb', 'ab' or 'rb'. Some file841    systems may be read-only, and some may not support append.842block_size: int843    Buffer size for reading or writing, 'default' for class default844autocommit: bool845    Whether to write to final destination; may only impact what846    happens when file is being closed.847cache_type: {"readahead", "none", "mmap", "bytes"}, default "readahead"848    Caching policy in read mode. See the definitions in ``core``.849cache_options : dict850    Additional options passed to the constructor for the cache specified851    by `cache_type`.852size: int853    If given and in read mode, suppressed having to look up the file size854kwargs:855    Gets stored as self.kwargs856r	)�caches)�defaultNrNF�trimzyPassing 'trim' to control the cache behavior has been deprecated. Specify it within the 'cache_options' argument instead.>�abrBrM�xbzFile mode not supportedrBr�)�corer�r�rsr2�DEFAULT_BLOCK_SIZErl�locr�rGrF�closedrgrhrir=rrnr��details�_fetch_range�cacher��BytesIO�bufferr��forced�location)rjrsr�r2r�r��857cache_typer�r�rr�s           rr&�AbstractBufferedFile.__init__?s��L	!��	����	�'1�5F�'F�D�#�#�J�	
�����$�������858����� ��M��V���M�M�J��
�859%+�J�J�v�$6�M�&�!����/�/�%�&?�@�@��4�<��� �	� �L�L��0��	��+����� 1� 1�4�9�9��@M��D�J��*�*�,�D�K��D�K��D�K� �D�Mrc��URc*URRUR5UlUR$r)�_detailsrsr�r�ros rr��AbstractBufferedFile.details�s.���=�=� � �G�G�L�L����3�D�M��}�}�rc�$�XlUSUlg)Nr�)r�r�)rjr>s  rr�r��s���
��&�M��	rc�B�[URUR5$r)rr�rsros r�	full_name�AbstractBufferedFile.full_name�s�� ����D�G�G�4�4rc��[USS5$)N�_closedTr2ros rr��AbstractBufferedFile.closed�s���t�Y��-�-rc��Xlgr)r�)rj�cs  rr�r��s���rc�v�SUR;a[U5$[[UR5S5$)Nr<ry)r2�idrzrr�ros rr{�AbstractBufferedFile.__hash__�s-���$�)�)���d�8�O��x����-�r�2�2rc���XLag[U[U55=(aC URS:H=(a- URS:H=(a [U5[U5:H$)zAFiles are equal if they have the same checksum, only in read modeTrB)r~rr2�hashr�s  rr��AbstractBufferedFile.__eq__�sV���=���u�d�4�j�)�
*��	�	�T�!�
*��860�861�d�"�
*��T�862�d�5�k�)�		863rc��g)z#Move from temp to final destinationNrros r�commit�AbstractBufferedFile.commit���rc��g)zThrow away temporary fileNrros r�discard�AbstractBufferedFile.discard�r�rc�Z�UR5(aUR$[S5e)z File information about this pathz Info not available while writing)�readabler�r�ros rr��AbstractBufferedFile.info�s#���=�=�?�?��<�<���?�@�@rc��UR$)zCurrent file location)r�ros rrE�AbstractBufferedFile.tell�s���x�x�rc�&�[U5nURS:Xd[[S5eUS:XaUnO;US:XaURU-nO%US:XaUR864U-nO[
SUS35eUS:a[
S5eX0lUR$)	z�Set current file location865 866Parameters867----------868loc: int869    byte location870whence: {0, 1, 2}871    from start of file, current location or end of file, resp.872rBz Seek only available in read moderr	r�zinvalid whence (z, should be 0, 1 or 2)zSeek before start of file)rzr2r�rr�r�r�)rjr��whence�nlocs    rrC�AbstractBufferedFile.seek�s����#�h���y�y�D� ��&�"D�E�E��Q�;��D�
�q�[��8�8�c�>�D�
�q�[��9�9�s�?�D��/��x�7M�N�O�O��!�8��8�9�9����x�x�rc��UR5(d[S5eUR(a[S5eUR(a[S5eURRU5nU=RU-
slURR5UR:�aUR5 U$)z�873Write data to buffer.874 875Buffer only sent on flush() or if buffer is greater than876or equal to blocksize.877 878Parameters879----------880data: bytes881    Set of bytes to be written.882zFile not in write mode�I/O operation on closed file.z0This file has been force-flushed, can only close)883�writabler�r�r�r�r=r�rErl�flush)rjrur�s   rr=�AbstractBufferedFile.write�s����}�}����5�6�6��;�;��<�=�=��;�;��O�P�P��k�k����%�����C����;�;�������/��J�J�L��884rc�F�UR(a[S5eU(aUR(a[S5eU(aSUlUR5(agU(d)URR5UR:agURcSUlUR5 URUS9SLaJU=RURRSS5-
sl[R"5Ulgg! SUle=f)	a3885Write buffered data to backend store.886 887Writes the current buffer, if it is larger than the block-size, or if888the file is being closed.889 890Parameters891----------892force: bool893    When closing, write the last block even if it is smaller than894    blocks are allowed to be. Disallows further writing to this file.895zFlush on closed filez+Force flush cannot be called more than onceTNr)�finalFr�)
r�r�r�r�r�rErlr��_initiate_upload�
_upload_chunkrCr�r�)rj�forces  rr��AbstractBufferedFile.flush�s����;�;��3�4�4��T�[�[��J�K�K���D�K��=�=�?�?������)�)�+�d�n�n�<���;�;���D�K�
��%�%�'�896���E��*�%�7��K�K�4�;�;�+�+�A�q�1�1�K��*�*�,�D�K�8��	
�"����s�)D�897D c��g)z�Write one part of a multi-block file upload898 899Parameters900==========901final: bool902    This is the last block, so should complete file, if903    self.autocommit is True.904Nr)rjr�s  rr��"AbstractBufferedFile._upload_chunk'r�rc��g)zCreate remote file/uploadNrros rr��%AbstractBufferedFile._initiate_upload2r�rc�J�URRURXS9$)z*Get the specified set of bytes from remoterP)rsrHr�)rjrFrGs   rr��!AbstractBufferedFile._fetch_range6s ���w�w����	�	���@�@rc��UcSO905[U5nURS:wa[S5eUS:aURUR-906nUR907(a[S5eUS:XagURRURURU-5n[RSUURURU-URR55 U=R[U5-
slU$)z�908Return data from cache, or fetch pieces as necessary909 910Parameters911----------912length: int (-1)913    Number of bytes to read; if <0, all remaining bytes.914r�rBzFile not in read moderr�rz%s read: %i - %i %s)rzr2r�r�r�r�r��_fetchr�r��915_log_statsr�)rjr�r�s   rr8�AbstractBufferedFile.read:s����~��3�v�;���9�9����4�5�5��A�:��Y�Y����)�F��;�;��<�=�=��Q�;���j�j������$�(�(�V�*;�<�����!���H�H��H�H�v���J�J�!�!�#�	916�	
���C��H����917rc��[U5RS5nURUR5nX2S[	U5&[	U5$)zhmirrors builtin file's readinto method918 919https://docs.python.org/3/library/io.html#io.RawIOBase.readinto920r!N)�921memoryview�castr8�nbytesr�)rjr�r�rus    r�readinto�AbstractBufferedFile.readintoYsB��922��m� � ��%���y�y����$���K�c�$�i���4�y�rc��/nUR5nURU=(d UR5n[U5S:XaOjUR	U5nUS:�a@URUSU[U5-5 UR
XF-[U5-5 OURU5 M�SRU5$)aKReturn data between current position and first occurrence of char923 924char is included in the output, except if the end of the tile is925encountered first.926 927Parameters928----------929char: bytes930    Thing to find931blocks: None or int932    How much to read in each go. Defaults to file blocksize - which may933    mean a new read on every call.934rr�Nr)rEr8rlr�r�r�rCr?)rj�char�blocksr�rF�part�founds       r�	readuntil�AbstractBufferedFile.readuntilcs�������I�I�K�E��9�9�V�5�t�~�~�6�D��4�y�A�~���I�I�d�O�E��r�z��935�936�4� 3�%�#�d�)�"3�4�5��	�	�%�-�#�d�)�3�4���J�J�t����x�x��}�rc�$�URS5$)z�Read until and including the first occurrence of newline character937 938Note that, because of character encoding, this is not necessarily a939true line ending.940�941)r�ros r�readline�AbstractBufferedFile.readlines���~�~�e�$�$rc�@�UR5nU(aU$[er)r��
StopIteration)rjr�s  r�__next__�AbstractBufferedFile.__next__�s���m�m�o����J��rc��U$rrros r�__iter__�AbstractBufferedFile.__iter__�����rc��UR5nURS5nUSSVs/sHo3S-PM	 nnURS5(aU$XBS/-$s snf)zPReturn all data, split by the newline character, including the newline characterr�Nr�)r8�splitr)rjru�lines�lr�s     r�	readlines�AbstractBufferedFile.readlines�s_���y�y�{���942�943�5�!��"'���*�-�*�Q�5�y�*��-��=�=�����J���)��$�$��	.s�Ac�$�URU5$r)r�)rjr�s  r�	readinto1�AbstractBufferedFile.readinto1�s���}�}�Q��rc���[USS5(agUR(agURS:XaSUlO�UR(dURSS9 URbcURRUR5 URRURRUR55 SUlg!SUlf=f)z-Close file944 945Finalizes writes, discards cache946�_unclosableFNrBT)r�)947r3r�r2r�r�r�rsr�r�r�ros rrn�AbstractBufferedFile.close�s���948�4���.�.���;�;��	��y�y�D� �!��949��{�{��J�J�T�J�*��7�7�&��G�G�,�,�T�Y�Y�7��G�G�,�,�T�W�W�_�_�T�Y�Y�-G�H��D�K��$�D�K�s�B(C�	C c�P�SUR;=(a UR(+$)zWhether opened for readingr0�r2r�ros rr��AbstractBufferedFile.readable�s���d�i�i��3����O�3rc�"�UR5$)z'Whether is seekable (only in read mode))r�ros r�seekable�AbstractBufferedFile.seekable�s���}�}��rc�P�URS;=(a UR(+$)zWhether opened for writing>r�rMr�r�ros rr��AbstractBufferedFile.writable�s���y�y�.�.�B�t�{�{�?�Brc950�H�URS:wa[S5e[URURURUR951URURURUR(aURROSUR4	4$)NrBz*Pickling a writeable file is not supported�none)r2�RuntimeError�reopenrsr�rlr�r�r�r�r�rros rr��AbstractBufferedFile.__reduce__�sw���9�9����K�L�L���G�G��I�I��I�I��N�N��H�H��I�I��O�O�#�z�z�D�J�J�O�O�v��K�K�952953�954955�956	957rc�H�UR(dUR5 ggr)r�rnros r�__del__�AbstractBufferedFile.__del__�s���{�{��J�J�L�rc�b�S[UR5RSURS3$)Nz<File-like object r2�>)rrsrPr�ros r�__str__�AbstractBufferedFile.__str__�s*��#�D����M�$:�$:�#;�2�d�i�i�[��J�Jrc��U$rrros r�	__enter__�AbstractBufferedFile.__enter__�r�rc�$�UR5 gr)rn)rjrs  r�__exit__�AbstractBufferedFile.__exit__�s���958�959�r)r�r�r�rlr�r�r�rGr�rsrr�r�r2r�r�r�rF)rBr�T�	readaheadNN)rr�)r�)r�N),rPrQrRrSrTr�r�r&r�r��setterr�r�r{r�r�r�r�rErCr=r�r�r�r�r8r�r�r�r�r�r�r�rnr�r�r�r�r	r
�__repr__rrrUrrrr�r�3s8���#���H������
�O!�b����960
�^�^�"��"��5��5��.��.�961�]�]����3�	962�2�(�A���4�0('�T�
�A��>��8%���%� ��,4��C�963� �K��H��rr�c		�f�UR"U4UUUUUS.UD6n	US:�aU	RU5 U	$)N)r2r�r�r�r�r)r7rC)964rsr�r2rlr�r�r�r�rr-s965          rrr�sJ��
�7�7���
����
�
���D��Q�w��	�	�#���Kr),�966__future__rr�r��loggingr+r>rgr(�errnorrr�hashlibr�typingrr�	callbacksr967�configrrrfr
r�r�utilsrrrrrrr�	getLoggerr�rrr!rX�IOBaser�rrrr�<module>r#s���"�	���	������� �'�&��$����968�	�	�8�	$�� �=�d�=�@L�7�L�^6j�2�9�9�j�Z
r
codekingpro/portable-devtools · Team Ai