Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2�j� ���SSKrSSKrSSKrSSKrSSKJr SSKJr SSKJ	r	 \R"S5r"SS\5rSr
S3S	jrg)�N)�MutableMapping)�cached_property)�	url_to_fszfsspec.mappingc��\rSrSrSrSSjr\S5rSrSSjr	Sr4S	rS5rSr
SSjrSS
jrSrSrSrSrSrSrSrg)�FSMap�
a�Wrap a FileSystem instance as a mutable wrapping.6 7The keys of the mapping become files under the given root, and the8values (which must be bytes) the contents of those files.9 10Parameters11----------12root: string13    prefix for all the files14fs: FileSystem instance15check: bool (=True)16    performs a touch at the location, to check for write access.17 18Examples19--------20>>> fs = FileSystem(**parameters)  # doctest: +SKIP21>>> d = FSMap('my-data/path/', fs)  # doctest: +SKIP22or, more likely23>>> d = fs.get_mapper('my-data/path/')24 25>>> d['loc1'] = b'Hello World'  # doctest: +SKIP26>>> list(d.keys())  # doctest: +SKIP27['loc1']28>>> d['loc1']  # doctest: +SKIP29b'Hello World'30Nc�N�X lURU5UlUR[R"US55SSUlUc[[[4nXPl	X0l31X@lU(a;URRU5(dURRU5 U(alURRU5(d[SUS35eURRUS-5 URR!US-5 gg)N�x�����zPath z9 does not exist. Create  with the ``create=True`` keywordz/a)�fs�_strip_protocol�root�	posixpath�join�_root_key_to_str�FileNotFoundError�IsADirectoryError�NotADirectoryError�missing_exceptions�check�create�exists�mkdir�32ValueError�touch�rm)�selfrrrrrs      �TD:\code\apps\devtools\python\user_packages\Python313\site-packages\fsspec/mapping.py�__init__�FSMap.__init__)s������&�&�t�,��	� "� 2� 2�9�>�>�$��3L� M�c�r� R����%�!�!�"�"��33#5���34�����7�7�>�>�$�'�'����
�
�d�#���7�7�>�>�$�'�'� ��D�6�"8�9���
�G�G�M�M�$��+�&��G�G�J�J�t�d�{�#��c�D�SSKJn U"URURS9$)z@dirfs instance that can be used with the same keys as the mapper�)�
DirFileSystem)�pathr)�implementations.dirfsr$rr)rr$s  r�dirfs�FSMap.dirfsBs��	9��$�"7�"7�D�G�G�D�Dr!c���[RSUR5 URR	URS5 URRUR5 g! g=f)z0Remove all keys below root - empties out mappingzClear mapping at %sTN)�logger�inforrrr�rs r�clear�FSMap.clearIsN�����)�4�9�9�5�	��G�G�J�J�t�y�y�$�'��G�G�M�M�$�)�)�$��	��s�AA.�.A2c�x�UVs/sHo0RU5PM nnUS:XaUOSnURRXES9n[U[5(aUSU0nUR5VVs0sH,up8U[X�R355(a36[
5OU_M. nnn[X5V	V37s0sHIup�US:Xd[Xj[5(aM$X�S:XaXjOURU38[
U3955_MK sn40n	$s snf!UR41an[UeSnAff=fs snnfs sn42n	f)a/Fetch multiple items from the store43 44If the backend is async-able, this might proceed concurrently45 46Parameters47----------48keys: list(str)49    They keys to be fetched50on_error : "raise", "omit", "return"51    If raise, an underlying exception will be raised (converted to KeyError52    if the type is in self.missing_exceptions); if omit, keys with exception53    will simply not be included in the output; if "return", all keys are54    included in the output, but the value will be bytes or an exception55    instance.56 57Returns58-------59dict(key, bytes|exception)60�raise�return)�on_errorrN)�_key_to_strr�cat�61isinstance�bytesr�KeyError�items�zip�
BaseException�get)r�keysr2�k�keys2�oe�out�e�v�key�k2s           r�getitems�FSMap.getitemsRs/��(/3�3�d��!�!�!�$�d��3�!�W�,�X�(��	"��'�'�+�+�e�+�1�C��#�u�%�%��Q�x��o��62�	�	��63�#���
�j��,C�,C�D�D��64�!�K�#�	�65��t�+�66�+����8�#�:�c�g�}�+M�
O�C��/���S�W�W�R��"��5N�N�+�67�	68��4���&�&�	"���!��	"��69��70s.�D�5D�43D0�8#D6�)D6�D-�!D(�(D-c���UR5VVs0sH up#URU5[U5_M" nnnURR	U5 gs snnf)zcSet the values of multiple items in the store71 72Parameters73----------74values_dict: dict(str, bytes)75N)r8r3�
maybe_convertr�pipe)r�values_dictr=rB�valuess     r�setitems�FSMap.setitemsxsR��EP�DU�DU�DW�X�DW�D�A�$�"�"�1�%�}�Q�'7�7�DW��X������V���Ys�'Ac��URRUVs/sHo RU5PM sn5 gs snf)z#Remove multiple keys from the storeN)rrr3)rr<r=s   r�delitems�FSMap.delitems�s-�����76�77��6��A�$�$�Q�'��6�7��6s�<c���[U[5(dF[R"S[5 [U[785(a[
U5n[U5nURU3RS5$)zGenerate full path for the keyzAfrom fsspec 2023.5 onward FSMap non-str keys will raise TypeError�/)	r5�str�warnings�warn�DeprecationWarning�list�tupler�rstrip)rrCs  rr3�FSMap._key_to_str�sc���#�s�#�#��M�M�S�"�
��#�t�$�$��C�j���c�(�C��'�'�(���.�5�5�c�:�:r!c�P�U[UR5SRS5$)zStrip path of to leave key nameNrR)�lenr�lstrip)r�ss  r�_str_to_key�FSMap._str_to_key�s#����T�Y�Y��!�"�)�)�#�.�.r!c��URU5nURRU5nU$!URanUbUsSnA$[	U5UeSnAff=f)z
Retrieve dataN)r3rr4rr7)rrC�defaultr=�result�excs      r�__getitem__�FSMap.__getitem__�s^�����S�!��	)��W�W�[�[��^�F�79�
��	�&�&�	)��"����3�-�S�(��	)�s!�0�A�A�A�80A�Ac�P�URX5nX	U$![a U$f=f)zPop data)rer7)rrCrbrcs    r�pop�	FSMap.pop�s<���!�!�#�/��	��	��
���	���
�	�s��81%�%c���URU5nURRURRU5SS9 URR	U[U55 g)zStore value in keyT)�exist_okN)r3r�mkdirs�_parent�	pipe_filerH)rrC�values   r�__setitem__�FSMap.__setitem__�sL�����s�#�������t�w�w���s�+�d��;������#�}�U�3�4r!c�b^�U4SjTRRTR55$)Nc3�F># �UHnTRU5v� M g7f�N)r_)�.0r82rs  �r�	<genexpr>�!FSMap.__iter__.<locals>.<genexpr>�s!����E�-D��� � ��#�#�-D�s�!)r�findrr,s`r�__iter__�FSMap.__iter__�s���E�T�W�W�\�\�$�)�)�-D�E�Er!c�^�[URRUR55$rt)r\rrxrr,s r�__len__�
FSMap.__len__�s���4�7�7�<�<��	�	�*�+�+r!c��URRURU55 g![an[UeSnAff=f)z83Remove keyN)rrr3�	Exceptionr7)rrCrds   r�__delitem__�FSMap.__delitem__�s:��	$��G�G�J�J�t�'�'��,�-���	$���#��	$�s�*-�84A�>�Ac�Z�URU5nURRU5$)zDoes key exist in mapping?)r3r�isfile)rrCr%s   r�__contains__�FSMap.__contains__�s%������$���w�w�~�~�d�#�#r!c�X�[URURSSUR44$)NF)rrrrr,s r�85__reduce__�FSMap.__reduce__�s&���t�y�y�$�'�'�5�%��9P�9P�Q�Q�Qr!)rrrrrr)FFN)r0rt)�__name__�86__module__�__qualname__�__firstlineno__�__doc__rrr'r-rErLrOr3r_rerhrpryr|r�r�r��__static_attributes__�r!rrr
sk���6$�2�E��E��$87�L�8�;�/�	��5�F�,�$�$�88Rr!rc��[U[R5(d[US5(aP[US5(a+URRS;aURS5n[
[U55nU$)N�	__array__�dtype�Mm�int64)r5�array�hasattrr��kind�viewr6�89memoryview)ros rrHrH�sa���%����%�%����)D�)D��5�'�"�"�u�{�{�'7�'7�4�'?��J�J�w�'�E��j��'�(���Lr!c�B�[U40UD6upgUbUOUn[X�XUS9$)a#Create key-value interface for given URL and options90 91The URL will be of the form "protocol://location" and point to the root92of the mapper required. All keys will be file-names below this location,93and their values the contents of each key.94 95Also accepts compound URLs like zip::s3://bucket/file.zip , see ``fsspec.open``.96 97Parameters98----------99url: str100    Root URL of mapping101check: bool102    Whether to attempt to read from the location before instantiation, to103    check that the mapping does exist104create: bool105    Whether to make the directory corresponding to the root before106    instantiating107missing_exceptions: None or tuple108    If given, these exception types will be regarded as missing keys and109    return KeyError when trying to read data. By default, you get110    (FileNotFoundError, IsADirectoryError, NotADirectoryError)111alternate_root: None or str112    In cases of complex URLs, the parser may fail to pick the correct part113    for the mapper root, so this arg can override114 115Returns116-------117``FSMap`` instance, the dict-like key-value store.118)r)rr)	�urlrrr�alternate_root�kwargsr�urlpathrs	         r�119get_mapperr��s2��N�C�*�6�*�K�B�+�7�>�W�D���5�=O�P�Pr!)�FFNN)r��loggingrrT�collections.abcr�	functoolsr�fsspec.corer�	getLoggerr*rrHr�r�r!r�<module>r�sX������*�%�!�	�	�	�+�	,��wR�N�wR�t�	�120����)Qr!
codekingpro/portable-devtools · Team Ai