← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/fsspec/__pycache__/mapping.cpython-312.pyc

119 lines

�

c�bj� ���ddlZddlZddlZddlZddlmZddlmZddlm	Z	ejd�ZGd�de�Zd�Z
					d
d	�Zy)�N)�MutableMapping)�cached_property)�	url_to_fszfsspec.mappingc��eZdZdZdd�Zed��Zd�Zdd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
dd�Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�FSMapa�Wrap a FileSystem instance as a mutable wrapping.

    The keys of the mapping become files under the given root, and the
    values (which must be bytes) the contents of those files.

    Parameters
    ----------
    root: string
        prefix for all the files
    fs: FileSystem instance
    check: bool (=True)
        performs a touch at the location, to check for write access.

    Examples
    --------
    >>> fs = FileSystem(**parameters)  # doctest: +SKIP
    >>> d = FSMap('my-data/path/', fs)  # doctest: +SKIP
    or, more likely
    >>> d = fs.get_mapper('my-data/path/')

    >>> d['loc1'] = b'Hello World'  # doctest: +SKIP
    >>> list(d.keys())  # doctest: +SKIP
    ['loc1']
    >>> d['loc1']  # doctest: +SKIP
    b'Hello World'
    Nc�*�||_|j|�|_|jtj|d��dd|_|�tttf}||_	||_
||_|r6|jj|�s|jj|�|rg|jj|�std|�d���|jj|dz�|jj!|dz�yy)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�
ValueError�touch�rm)�selfr
rrrrs      �e/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/fsspec/mapping.py�__init__zFSMap.__init__)s�������&�&�t�,��	� "� 2� 2�9�>�>�$��3L� M�c�r� R����%�!�!�"�"��
#5�����
������7�7�>�>�$�'����
�
�d�#���7�7�>�>�$�'� ��D�6�"8�9���
�G�G�M�M�$��+�&��G�G�J�J�t�d�{�#��c�J�ddlm}||j|j��S)z@dirfs instance that can be used with the same keys as the mapper�)�
DirFileSystem)�pathr)�implementations.dirfsr"rr)rr"s  r�dirfszFSMap.dirfsBs��	9��$�"7�"7�D�G�G�D�Drc���tjd|j�	|jj	|jd�|jj|j�y#YyxYw)z0Remove all keys below root - empties out mappingzClear mapping at %sTN)�logger�infor
rrr�rs r�clearzFSMap.clearIsN�����)�4�9�9�5�	��G�G�J�J�t�y�y�$�'��G�G�M�M�$�)�)�$��	��s�AA.�.A2c�T�|D�cgc]}|j|���}}|dk(r|nd}	|jj||��}t|t�r|d|i}|j�D��cic](\}}|t||j
�r
t
�n|��*}}}t||�D�	�
cic]C\}	}
|dk(st||
t�s&|	|dk(r||
n|j|
t
|
����Ec}
}	Scc}w#|j
$r}t|�d}~wwxYwcc}}wcc}
}	w)a�Fetch multiple items from the store

        If the backend is async-able, this might proceed concurrently

        Parameters
        ----------
        keys: list(str)
            They keys to be fetched
        on_error : "raise", "omit", "return"
            If raise, an underlying exception will be raised (converted to KeyError
            if the type is in self.missing_exceptions); if omit, keys with exception
            will simply not be included in the output; if "return", all keys are
            included in the output, but the value will be bytes or an exception
            instance.

        Returns
        -------
        dict(key, bytes|exception)
        �raise�return)�on_errorrN)�_key_to_strr�cat�
isinstance�bytesr�KeyError�items�zip�
BaseException�get)r�keysr.�k�keys2�oe�out�e�v�key�k2s           r�getitemszFSMap.getitemsRs8��(/3�3�d���!�!�!�$�d��3�!�W�,�X�(��	"��'�'�+�+�e�b�+�1�C��#�u�%��Q�x��o��
�	�	��
�#���1�
�j��D�,C�,C�D��
�!�K�#�	�
��t�U�+�
�+���R��8�#�:�c�"�g�}�+M�
�H��/��R��S�W�W�R��"��5N�N�+�
�	
��4���&�&�	"���!��	"��
��
s)�C;�4D�0-D�/AD$�D�D�Dc��|j�D��cic] \}}|j|�t|���"}}}|jj	|�ycc}}w)z�Set the values of multiple items in the store

        Parameters
        ----------
        values_dict: dict(str, bytes)
        N)r4r/�
maybe_convertr�pipe)r�values_dictr9r>�valuess     r�setitemszFSMap.setitemsxsT��EP�DU�DU�DW�X�DW�D�A�q�$�"�"�1�%�}�Q�'7�7�DW��X������V���Ys�%Ac�~�|jj|D�cgc]}|j|���c}�ycc}w)z#Remove multiple keys from the storeN)rrr/)rr8r9s   r�delitemszFSMap.delitems�s/�����
�
��6��A�D�$�$�Q�'��6�7��6s�:c���t|t�s@tjdt�t|t
�rt
|�}t|�}|j�|��jd�S)zGenerate full path for the keyzAfrom fsspec 2023.5 onward FSMap non-str keys will raise TypeError�/)	r1�str�warnings�warn�DeprecationWarning�list�tupler�rstrip)rr?s  rr/zFSMap._key_to_str�s]���#�s�#��M�M�S�"�
��#�t�$��C�j���c�(�C��'�'�(���.�5�5�c�:�:rc�P�|t|j�djd�S)zStrip path of to leave key nameNrK)�lenr
�lstrip)r�ss  r�_str_to_keyzFSMap._str_to_key�s#����T�Y�Y��!�"�)�)�#�.�.rc��|j|�}	|jj|�}|S#|j$r}|�|cYd}~St	|�|�d}~wwxYw)z
Retrieve dataN)r/rr0rr3)rr?�defaultr9�result�excs      r�__getitem__zFSMap.__getitem__�s^�����S�!��	)��W�W�[�[��^�F�
�
��	�&�&�	)��"����3�-�S�(��	)�s �0�A�A�A�A�Ac�R�|j||�}	||=|S#t$rY|SwxYw)zPop data)r\r3)rr?rYrZs    r�popz	FSMap.pop�s@���!�!�#�w�/��	��S�	��
���	���
�	�s��	&�&c���|j|�}|jj|jj|�d��|jj	|t|��y)zStore value in keyT)�exist_okN)r/r�mkdirs�_parent�	pipe_filerC)rr?�values   r�__setitem__zFSMap.__setitem__�sL�����s�#�������t�w�w���s�+�d��;������#�}�U�3�4rc�`���fd��jj�j�D�S)Nc3�@�K�|]}�j|����y�w�N)rW)�.0r	rs  �r�	<genexpr>z!FSMap.__iter__.<locals>.<genexpr>�s�����E�-D��� � ��#�-D�s�)r�findr
r)s`r�__iter__zFSMap.__iter__�s���E�T�W�W�\�\�$�)�)�-D�E�Erc�^�t|jj|j��Srh)rTrrkr
r)s r�__len__z
FSMap.__len__�s���4�7�7�<�<��	�	�*�+�+rc��	|jj|j|��y#t$r}t|�d}~wwxYw)z
Remove keyN)rrr/�	Exceptionr3)rr?r[s   r�__delitem__zFSMap.__delitem__�s:��	$��G�G�J�J�t�'�'��,�-���	$���#��	$�s�*-�	A�=�Ac�Z�|j|�}|jj|�S)zDoes key exist in mapping?)r/r�isfile)rr?r#s   r�__contains__zFSMap.__contains__�s%������$���w�w�~�~�d�#�#rc�X�t|j|jdd|jffS)NF)rr
rrr)s r�
__reduce__zFSMap.__reduce__�s&���t�y�y�$�'�'�5�%��9P�9P�Q�Q�Qr)FFN)r,rh)�__name__�
__module__�__qualname__�__doc__rrr%r*rArGrIr/rWr\r^rerlrnrqrtrv�rrrr
sk���6$�2�E��E��$
�L�8�;�/�	��5�F�,�$�$�
Rrrc���t|tj�st|d�rIt|d�r)|jjdvr|jd�}t
t|��}|S)N�	__array__�dtype�Mm�int64)r1�array�hasattrr~�kind�viewr2�
memoryview)rds rrCrC�sX���%����%����)D��5�'�"�u�{�{�'7�'7�4�'?��J�J�w�'�E��j��'�(���Lrc�L�t|fi|��\}}|�|n|}t|||||��S)a�Create key-value interface for given URL and options

    The URL will be of the form "protocol://location" and point to the root
    of the mapper required. All keys will be file-names below this location,
    and their values the contents of each key.

    Also accepts compound URLs like zip::s3://bucket/file.zip , see ``fsspec.open``.

    Parameters
    ----------
    url: str
        Root URL of mapping
    check: bool
        Whether to attempt to read from the location before instantiation, to
        check that the mapping does exist
    create: bool
        Whether to make the directory corresponding to the root before
        instantiating
    missing_exceptions: None or tuple
        If given, these exception types will be regarded as missing keys and
        return KeyError when trying to read data. By default, you get
        (FileNotFoundError, IsADirectoryError, NotADirectoryError)
    alternate_root: None or str
        In cases of complex URLs, the parser may fail to pick the correct part
        for the mapper root, so this arg can override

    Returns
    -------
    ``FSMap`` instance, the dict-like key-value store.
    )r)rr)	�urlrrr�alternate_root�kwargsr�urlpathr
s	         r�
get_mapperr��s8��N�C�*�6�*�K�B��+�7�>�W�D���r�5�&�=O�P�Pr)�FFNN)r��loggingrrM�collections.abcr�	functoolsr�fsspec.corer�	getLoggerr'rrCr�r{rr�<module>r�sZ������*�%�!�	��	�	�+�	,��wR�N�wR�t�	�
����)Qr