← back to Atmos Game

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

164 lines

�

c�bj�4����ddlmZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZddl
mZmZmZmZiZej&d�Zd�Zdd	�Z						dd
�ZGd�de�Z	dd
�Zdd�Zd�Zy)�)�annotationsN�)�AsyncFileSystem�_run_coros_in_chunks�sync_wrapper)�DEFAULT_CALLBACK)�
filesystem�get_filesystem_class�split_protocol�	url_to_fszfsspec.genericc�*�t|fi|��t|<y)z4Populate the dict used for method=="generic" lookupsN)r	�_generic_fs)�protocol�storage_optionss  �e/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/fsspec/generic.py�set_generic_fsrs��&�x�C�?�C�K���c�P�t|ttf�r|dn|}|xst|�d}|xsi}|dk(rt	|�S|dk(r	t
|S|dk(rt
|�}|j�S|dk(r!t|fi|j|i���\}}|Std|����)zPick instance of backend FSr�default�generic�current�optionszUnknown FS resolution method: )�
isinstance�list�tuplerr	rr
rr�get�
ValueError)�url�methodrr�cls�fs�_s       r�_resolve_fsr#s����s�T�5�M�2�#�a�&��C��1�>�#�.�q�1�H�%�+��O�
����(�#�#�
����8�$�$�
���"�8�,���{�{�}��
����#�C��!4�!4�X�r�!B�C���A��	�
�5�f�X�>�
?�?rc	���|xstdi|xsi��}|j|�}|j|�}|j|dd��}	|j|�st	d��|j|dd��}
|	j�D��cgc]#\}}|ddk(r|j
||�|
vr|��%}
}}tjt|
��d��|
r1|j|
D�cgc]}|j
||���c}d��|	j�D��cic]\}}|ddk(s�||��}	}}tjt|	��d	��|
j�D��cgc]#\}}|j
||�|	vr
|ddk(r|��%}}}|	j�j�D]�\}}|j
||�}||
vrz|d
k(r||	|<�'|dk(r|	j|��>|dk(s�Dt|�r||�n||}|
|}t|�r||�n||}||k7r||	|<��|	j|���||	|<��tjt|	��d
��|	r-t|	j��\}}|j||fi|��tjt|��d��|r|r|j!|�|	Scc}}wcc}wcc}}wcc}}w)aUSync files between two directory trees

    (experimental)

    Parameters
    ----------
    source: str
        Root of the directory tree to take files from. This must be a directory, but
        do not include any terminating "/" character
    destination: str
        Root path to copy into. The contents of this location should be
        identical to the contents of ``source`` when done. This will be made a
        directory, and the terminal "/" should not be included.
    delete_missing: bool
        If there are paths in the destination that don't exist in the
        source and this is True, delete them. Otherwise, leave them alone.
    source_field: str | callable
        If ``update_field`` is "different", this is the key in the info
        of source files to consider for difference. Maybe a function of the
        info dict.
    dest_field: str | callable
        If ``update_field`` is "different", this is the key in the info
        of destination files to consider for difference. May be a function of
        the info dict.
    update_cond: "different"|"always"|"never"
        If "always", every file is copied, regardless of whether it exists in
        the destination. If "never", files that exist in the destination are
        not copied again. If "different" (default), only copy if the info
        fields given by ``source_field`` and ``dest_field`` (usually "size")
        are different. Other comparisons may be added in the future.
    inst_kwargs: dict|None
        If ``fs`` is None, use this set of keyword arguments to make a
        GenericFileSystem instance
    fs: GenericFileSystem|None
        Instance to use if explicitly given. The instance defines how to
        to make downstream file system instances from paths.

    Returns
    -------
    dict of the copy operations that were performed, {source: destination}
    T)�withdirs�detailzCan only rsync on a directory�type�	directoryz directories to create��exist_ok�filez files to consider for copy�always�never�	differentz files to copyz files to delete�)�GenericFileSystem�_strip_protocol�find�isdirr�items�replace�logger�debug�len�make_many_dirs�copy�pop�callable�zip�cp�rm)�source�destination�delete_missing�source_field�
dest_field�update_cond�inst_kwargsr!�kwargs�allfiles�
otherfiles�a�v�dirs�dirn�o�	to_delete�k�	otherfile�inf1�v2�inf2�source_files�target_filess                        r�rsyncrW(s���h
�	7� �7�K�$5�2�7�B�
�
�
��
'�F��$�$�[�1�K��w�w�v��T�w�:�H�
�8�8�F���8�9�9�����t�D��A�J��N�N�$��$�D�A�q��V�9��#��	�	�&�+�(F�j�(X�	
�$�	��
�L�L�C��I�;�4�5�6��
���;?�@�4�4�T�\�\�&�+�
.�4�@�4�	�	
�"*���!1�I�!1���A�Q�v�Y�&�5H��1��!1�H�I�
�L�L�C��M�?�"=�>�?��$�$�&��&�D�A�q��9�9�[�&�)��9�a��i�6�>Q�	
�&���
�
�
��%�%�'���1��I�I�f�k�2�	��
�"��h�&�'������'����Q����+�*2�<�*@�|�A��a��o���	�*��)1�*�)=�z�"�~�2�j�>���4�<�"+�H�Q�K��L�L��O�$�H�Q�K�'(�(�L�L�C��M�?�.�1�2��%(�(�.�.�*:�%;�"��l�
����l�L�3�F�3�
�L�L�C�	�N�#�#3�4�5��)�
���i���O��Y��
A��I��s�
(K�*K �K%�0K%�,(K+c����eZdZdZdZd�fd�	Zd�Zd�Zdd�Zd�Z		dd	�Z
d
�Zd�Zd�Z
dd
�Zd�Zdedf	dd�Zdd�Zee�Z					d													dd�Z�xZS)r0a^Wrapper over all other FS types

    <experimental!>

    This implementation is a single unified interface to be able to run FS operations
    over generic URLs, and dispatch to the specific implementations using the URL
    protocol prefix.

    Note: instances of this FS are always async, even if you never use it with any async
    backend.
    rNc�@��||_||_t�|�di|��y)a�

        Parameters
        ----------
        default_method: str (optional)
            Defines how to configure backend FS instances. Options are:
            - "default": instantiate like FSClass(), with no
              extra arguments; this is the default instance of that FS, and can be
              configured via the config system
            - "generic": takes instances from the `_generic_fs` dict in this module,
              which you must populate before use. Keys are by protocol
            - "options": expects storage_options, a dict mapping protocol to
              kwargs to use when constructing the filesystem
            - "current": takes the most recently instantiated version of each FS
        Nr/)r�st_opts�super�__init__)�self�default_methodrrG�	__class__s    �rr\zGenericFileSystem.__init__�s#��� %���&���
���"�6�"rc��t||j|j��}|j|j	|��S�N�r)r#rrZ�unstrip_protocol�_parent�r]�pathr!s   rrdzGenericFileSystem._parent�s2��
��t�{�{�D�L�L�
I���"�"�2�:�:�d�#3�4�4rc��t||j|j��}|j|j	|��Sra)r#rrZrcr1res   rr1z!GenericFileSystem._strip_protocol�s4��
��t�{�{�D�L�L�
I���"�"�2�#5�#5�d�#;�<�<rc��K�t||j|j��}|jr |j|f||dd�|���d{���}n|j
|f||dd�|��}i}|j
�D]0\}	}
|
j�}
|j|	�}||
d<|
||<�2|r|St|�S7�p�w)NrbT)�maxdepthr%r&�name)
r#rrZ�
async_impl�_findr2r4r:rcr)r]rfrir%r&rGr!�out�resultrPrKrjs            rrlzGenericFileSystem._find�s�����
��t�{�{�D�L�L�
I��
�=�=� ������'�(�4��KQ���C��"�'�'���'�(�4��KQ��C����I�I�K�D�A�q�����A��&�&�q�)�D��A�f�I��F�4�L�	 �
��M��F�|���s�A	B>�B<�A1B>c��K�t||j�}|jr|j|fi|���d{���}n|j|fi|��}|j�}|j
|d�|d<|S7�A�w)Nrj)r#rrk�_info�infor:rc)r]rrGr!rms     rrpzGenericFileSystem._info�sw����
��d�k�k�
*��
�=�=� �����/��/�/�C��"�'�'�#�(��(�C��h�h�j���)�)�#�f�+�6��F���
�0�s�9A?�A=�AA?c��pK�t||j�}|jr|j|fddi|���d{���}n|j|fddi|��}|D�cgc]}|j���}}|D]}|j
|d�|d<�|r|S|D�cgc]}|d��	c}S7�lcc}wcc}w�w)Nr&Trj)r#rrk�_ls�lsr:rc)r]rr&rGr!rmrNs       rrszGenericFileSystem._ls�s�������d�k�k�
*��
�=�=�����s�:�4�:�6�:�:�C��"�%�%��3�D�3�F�3�C�!$�%��A�q�v�v�x���%��A��+�+�A�f�I�6�A�f�I����J�'*�+�s�!�A�f�I�s�+�+�;��&��,�s-�;B6�B*�B6�B,�3(B6�B1�'B6�,
B6c��K�t||j�}|jr|j|fi|���d{���S|j|fi|��S7��w�N)r#rrk�	_cat_file�cat_file)r]rrGr!s    rrwzGenericFileSystem._cat_file�sS����
��d�k�k�
*��
�=�=�%����c�4�V�4�4�4��2�;�;�s�-�f�-�-�5�s�9A�A�Ac���K�t||j|j��}|jr|j||fi|���d{���S|j
||fi|��S7��wra)r#rrZrk�
_pipe_file�	pipe_file)r]rf�valuerGr!s     rrzzGenericFileSystem._pipe_file�s]������t�{�{�D�L�L�
I��
�=�=�&����t�U�=�f�=�=�=��2�<�<��e�6�v�6�6�>�s�AA#�A!�	A#c���K�|}t|t�r|g}t|d|j�}|jr|j
|fi|���d{���y|j|fi|��y7��w)Nr)r�strr#rrk�_rmr?)r]rrG�urlsr!s     rrzGenericFileSystem._rmsh�������d�C� ��6�D�
��a��$�+�+�
.��
�=�=��"�&�&��(��(�(�(��B�E�E�#� �� �
)�s�AA/�A-�A/c���K�tjd|�t||j|j��}|j
r|j
||���d{���y|j||��y7��w)NzMake dir %srbr))r6r7r#rrZrk�	_makedirs�makedirs)r]rfr*r!s    rr�zGenericFileSystem._makedirss\�������]�D�)�
��t�{�{�D�L�L�
I��
�=�=��,�,�t�h�,�7�7�7��K�K��x�K�0�
8�s�AA9�A7�A9c�"�t||fd|i|��y)z[Sync files between two directory trees

        See `func:rsync` for more details.
        r!N)rW)r]r@rArGs    rrWzGenericFileSystem.rsyncs��
	�f�k�5�d�5�f�5ric	��$K�t||j�}t||j�}||ur<|jr|j||fi|���d{���S|j||fi|��St||g||g|dd���d{���y7�57��w)Nr�raise��on_error)r#rrk�_copyr:�copy_file_op)	r]r�url2�	blocksize�callback�tempdirrGr!�fs2s	         r�_cp_filezGenericFileSystem._cp_files�������d�k�k�
*���$����,��
��9��}�}�%�R�X�X�c�4�:�6�:�:�:��r�w�w�s�D�3�F�3�3��2��u�c�D�6�7�A��P�P�P�;��	Q�s$�AB�B�/B�B�B�Bc��K�t|d|j�}|jr4|D�cgc]}|j||����}}t	|��d{���y|D]}|j||���ycc}w7�%�w)Nrr))r#rrkr�rr�)r]r�r*r!�u�coross      r�_make_many_dirsz!GenericFileSystem._make_many_dirs2ss����
��a��$�+�+�
.��
�=�=�AE�F��A�R�\�\�!�h�\�7��E�F�&�u�-�-�-������A���1���G�-�s�*A>�A7�A>�A<�&A>c	��K�|rtd��t|t�r|gn|}t|t�r|gn|}t||j�}	t||j�}
|	|
ur<|	j
r|	j||fi|���d{���S|	j||fi|��St|	||
||||���d{���y7�37��w)NzPlease use fsspec.generic.rsyncr�)	�NotImplementedErrorrr~r#rrkr�r:r�)r]�path1�path2�	recursiver�ri�
batch_sizer�rGr!r�s           rr�zGenericFileSystem._copy=s������%�&G�H�H�%�e�S�1���u��%�e�S�1���u��
�����
,���%����-��
��9��}�}�%�R�X�X�e�U�=�f�=�=�=��r�w�w�u�e�6�v�6�6����s�E�7�J��
�	
�	
�	>��	
�s$�BC�
C�-C�;C�<C�C)rN)NFF)T)F)r��
str | None)F�ignoreNNN)r��	list[str]r�r�r��boolr�r~ri�
int | Noner�r�r�r�)�__name__�
__module__�__qualname__�__doc__rr\rdr1rlrprsrwrzrr�rWrr�r�rr9r��
__classcell__)r_s@rr0r0�s����
��H�#�(5�=�
�(��,�&	.�
7�!�1�6��!�"�
Q��
Q�&2�"�/�2�N� � �#�!%�"�
��
��
��	
�
�
��

��
��
rr0c���K�ddl}|xs|j�}	t||�D��	cgc]N\}}	t||||	tj
j
|tj�j����P}
}}	t|
|d���d{���}tj|�|dk(r|S|dk(r|D]}t|t�s�|�yycc}	}w7�F#tj|�wxYw�w)NrT)r��return_exceptions�returnr�)�tempfile�mkdtempr=�
_copy_file_op�osrf�join�uuid�uuid4�hexr�shutil�rmtreer�	Exception)
�fs1�url1r�r�r�r�r�r��u1�u2r�rmrNs
             rr�r�]s�������+��)�)�+�G���d�D�/�	
�*���B�
����������W�d�j�j�l�&6�&6�7�
�*�	�	
�)��j�D�
�
��	�
�
�g���8���
�	�W�	��A��!�Y�'����
��#	
�
��	�
�
�g��s@�C5�C�AC�>C�C�C�6C5�C5�C�C2�2C5c��PK�|jr|j||��d{���n|j||�|jr|j||��d{���n|j	||�tj|�tjd||�y7�}7�F�w)NzCopy %s -> %s; done)	rk�	_get_file�get_file�	_put_file�put_filer��unlinkr6r7)r�r�r�r��localr�s      rr�r�{s�����
�~�~��m�m�D�%�(�(�(����T�5�!�
�~�~��m�m�E�4�(�(�(����U�D�!��I�I�e��
�L�L�&��d�3�	)��	)�s"�"B&�B"�8B&�B$�AB&�$B&c��PK�tj|�r
|�d{���S|S7��wrv)�inspect�iscoroutine)�cors r�maybe_awaitr��s&�������3���y���
��s�&�$�&)NN)F�sizer�r.NN)N�r�)r�)�
__future__rr��loggingr�r�r��asynrrr�	callbacksr�corer	r
rrr�	getLoggerr6rr#rWr0r�r�r�r/rr�<module>r�s���"���	�
��E�E�'�M�M���	��	�	�+�	,��D�
@�*������g�TH
��H
�XAI��<
4�r