Ë
    ãš¾jY!  ã                   ó°   — d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
  ej                  d«      Z e«       Z G d„ de«      Zd„ Z	 	 	 	 	 d
d	„Zy)é    N)ÚMutableMapping)Úcached_property)Ú	url_to_fszfsspec.mappingc                   ó„   — e Zd ZdZdd„Zed„ «       Zd„ Zdd„Zd„ Z	d„ Z
d	„ Zd
„ Zdd„Zefd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)Ú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                 ód  — || _         |j                  |«      | _        |j                  t        j                  |d«      «      d d | _        |€t        t        t        f}|| _	        || _
        || _        |r6| j                   j                  |«      s| j                   j                  |«       |r„| j                   j                  |«      st        d|› d�«      ‚|› dt        j                   «       j"                  › �}| j                   j%                  |«       | j                   j'                  |«       y y )NÚxéÿÿÿÿzPath z9 does not exist. Create  with the ``create=True`` keywordú/)ÚfsÚ_strip_protocolÚrootÚ	posixpathÚjoinÚ_root_key_to_strÚFileNotFoundErrorÚIsADirectoryErrorÚNotADirectoryErrorÚmissing_exceptionsÚcheckÚcreateÚexistsÚmkdirÚ
ValueErrorÚuuidÚuuid4ÚhexÚtouchÚrm)Úselfr   r   r   r   r   Ú
check_paths          úX/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/fsspec/mapping.pyÚ__init__zFSMap.__init__+   s  € ØˆŒØ×&Ñ& tÓ,ˆŒ	Ø "× 2Ñ 2´9·>±>À$ÈÓ3LÓ MÈcÈrÐ RˆÔØÐ%ä!Ü!Ü"ð"Ðð
 #5ˆÔØˆŒ
ØˆŒÙØ—7‘7—>‘> $Ô'Ø—‘—‘˜dÔ#ÙØ—7‘7—>‘> $Ô'Ü Ø˜D˜6ð "8ð 9óð ð !˜6 ¤4§:¡:£<×#3Ñ#3Ð"4Ð5ˆJØ�G‰G�M‰M˜*Ô%Ø�G‰G�J‰J�zÕ"ð ó    c                 óJ   — ddl m}  || j                  | j                  ¬«      S )z@dirfs instance that can be used with the same keys as the mapperé   )ÚDirFileSystem)Úpathr   )Úimplementations.dirfsr'   r   r   )r    r'   s     r"   ÚdirfszFSMap.dirfsE   s   € õ 	9á $×"7Ñ"7¸D¿G¹GÔDÐDr$   c                 óê   — t         j                  d| j                  «       	 | j                  j	                  | j                  d«       | j                  j                  | j                  «       y#  Y yxY w)z0Remove all keys below root - empties out mappingzClear mapping at %sTN)ÚloggerÚinfor   r   r   r   ©r    s    r"   ÚclearzFSMap.clearL   sN   € ä�‰Ð)¨4¯9©9Ô5ð	Ø�G‰G�J‰J�t—y‘y $Ô'Ø�G‰G�M‰M˜$Ÿ)™)Õ$øð	Ùús   ¢AA. Á.A2c                 óT  — |D �cg c]  }| j                  |«      ‘Œ }}|dk(  r|nd}	 | j                  j                  ||¬«      }t        |t        «      r|d   |i}|j                  «       D ��ci c](  \  }}|t        || j
                  «      r
t        «       n|“Œ* }}}t        ||«      D �	�
ci c]C  \  }	}
|dk(  st        ||
   t        «      s&|	|dk(  r||
   n|j                  |
t        |
«      «      “ŒE c}
}	S c c}w # | j
                  $ r}t        |‚d}~ww xY wc c}}w c c}
}	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_errorr   N)Ú_key_to_strr   ÚcatÚ
isinstanceÚbytesr   ÚKeyErrorÚitemsÚzipÚBaseExceptionÚget)r    Úkeysr3   ÚkÚkeys2ÚoeÚoutÚeÚvÚkeyÚk2s              r"   ÚgetitemszFSMap.getitemsU   s/  € ð( /3Ö3¨�×!Ñ! !Õ$Ð3ˆÐ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Â/AD$Ä DÄDÄDc                 ó¼   — |j                  «       D ��ci c]   \  }}| j                  |«      t        |«      “Œ" }}}| j                  j	                  |«       yc c}}w )zƒSet the values of multiple items in the store

        Parameters
        ----------
        values_dict: dict(str, bytes)
        N)r9   r4   Úmaybe_convertr   Úpipe)r    Úvalues_dictr>   rC   Úvaluess        r"   ÚsetitemszFSMap.setitems{   sQ   € ð EP×DUÑDUÓDW×X¹D¸A¸q�$×"Ñ" 1Ó%¤}°QÓ'7Ñ7ÐXˆÑXØ�‰�‰�VÕùó Ys   ”%Ac                 ó~   — | j                   j                  |D �cg c]  }| j                  |«      ‘Œ c}«       yc c}w )z#Remove multiple keys from the storeN)r   r   r4   )r    r=   r>   s      r"   ÚdelitemszFSMap.delitems…   s+   € à�‰�
‰
°Ö6¨A�D×$Ñ$ QÕ'Ò6Õ7ùÒ6s   š:c                 óà   — t        |t        «      s@t        j                  dt        «       t        |t
        «      rt        |«      }t        |«      }| j                  › |› �j                  d«      S )zGenerate full path for the keyzAfrom fsspec 2023.5 onward FSMap non-str keys will raise TypeErrorr   )	r6   ÚstrÚwarningsÚwarnÚDeprecationWarningÚlistÚtupler   Úrstrip)r    rD   s     r"   r4   zFSMap._key_to_str‰   s]   € ä˜#œsÔ#ä�M‰MØSÜ"ôô ˜#œtÔ$Ü˜C“j�Ü�c“(ˆCØ×'Ñ'Ð(¨¨Ð.×5Ñ5°cÓ:Ð:r$   c                 óP   — |t        | j                  «      d j                  d«      S )zStrip path of to leave key nameNr   )Úlenr   Úlstrip)r    Úss     r"   Ú_str_to_keyzFSMap._str_to_key–   s#   € à”�T—Y‘Y“Ð!Ð"×)Ñ)¨#Ó.Ð.r$   c                 ó¸   — | j                  |«      }	 | j                  j                  |«      }|S # | j                  $ r}|�|cY d}~S t	        |«      |‚d}~ww xY w)zRetrieve dataN)r4   r   r5   r   r8   )r    rD   Údefaultr>   ÚresultÚexcs         r"   Ú__getitem__zFSMap.__getitem__š   s^   € à×Ñ˜SÓ!ˆð	)Ø—W‘W—[‘[ “^ˆFð
 ˆøð	 ×&Ñ&ò 	)ØÐ"Ø•Ü˜3“- SÐ(ûð	)ús    “0 °A¿AÁAÁAÁAc                 ón   — 	 | |   }	 | |= |S # t         $ r |t        u r‚ |cY S w xY w# t         $ r Y |S w xY w)zPop data)r8   Ú_MISSING)r    rD   r]   r^   s       r"   Úpopz	FSMap.pop¥   s\   € ð	Ø˜#‘YˆFð
	Ø�S�	ð ˆøô ò 	Øœ(Ñ"ØØŠNð	ûô ò 	ØØˆð	ús   ‚ ˆ' �$£$§	4³4c                 óÜ   — | j                  |«      }| j                  j                  | j                  j                  |«      d¬«       | j                  j	                  |t        |«      «       y)zStore value in keyT)Úexist_okN)r4   r   ÚmkdirsÚ_parentÚ	pipe_filerH   )r    rD   Úvalues      r"   Ú__setitem__zFSMap.__setitem__³   sL   € à×Ñ˜sÓ#ˆØ�‰�‰�t—w‘w—‘ sÓ+°dˆÔ;Ø�‰×Ñ˜#œ}¨UÓ3Õ4r$   c                 ó`   ‡ — ˆ fd„‰ j                   j                  ‰ j                  «      D «       S )Nc              3   ó@   •K  — | ]  }‰j                  |«      –— Œ y ­w©N)r[   )Ú.0r	   r    s     €r"   ú	<genexpr>z!FSMap.__iter__.<locals>.<genexpr>º   s   øè ø€ ÒE¨�× Ñ  ×#ÑEùs   ƒ)r   Úfindr   r.   s   `r"   Ú__iter__zFSMap.__iter__¹   s   ø€ ÛE¨T¯W©W¯\©\¸$¿)¹)Ó-DÔEÐEr$   c                 ó^   — t        | j                  j                  | j                  «      «      S rm   )rX   r   rp   r   r.   s    r"   Ú__len__zFSMap.__len__¼   s   € Ü�4—7‘7—<‘< §	¡	Ó*Ó+Ð+r$   c                 óŠ   — 	 | j                   j                  | j                  |«      «       y# t        $ r}t        |‚d}~ww xY w)z
Remove keyN)r   r   r4   Ú	Exceptionr8   )r    rD   r_   s      r"   Ú__delitem__zFSMap.__delitem__¿   s:   € ð	$Ø�G‰G�J‰J�t×'Ñ'¨Ó,Õ-øÜò 	$Ü Ð#ûð	$ús   ‚*- ­	A¶=½Ac                 óZ   — | j                  |«      }| j                  j                  |«      S )zDoes key exist in mapping?)r4   r   Úisfile)r    rD   r(   s      r"   Ú__contains__zFSMap.__contains__Æ   s%   € à×Ñ Ó$ˆØ�w‰w�~‰~˜dÓ#Ð#r$   c                 óX   — t         | j                  | j                  dd| j                  ffS )NF)r   r   r   r   r.   s    r"   Ú
__reduce__zFSMap.__reduce__Ë   s&   € Ü�t—y‘y $§'¡'¨5°%¸×9PÑ9PÐQÐQÐQr$   )FFN)r1   rm   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r   r*   r/   rF   rL   rN   r4   r[   r`   rb   rc   rj   rq   rs   rv   ry   r{   © r$   r"   r   r      sp   „ ñó6#ð4 ñEó ðEòó$
òLò8ò;ò/ó	ð  (ó ò5òFò,ò$ò$ó
Rr$   r   c                 óä   — t        | t        j                  «      st        | d«      rIt        | d«      r)| j                  j                  dv r| j                  d«      } t        t        | «      «      } | S )NÚ	__array__ÚdtypeÚMmÚint64)r6   ÚarrayÚhasattrrƒ   ÚkindÚviewr7   Ú
memoryview)ri   s    r"   rH   rH   Ï   sX   € Ü�%œŸ™Ô%¬°¸Ô)Dä�5˜'Ô" u§{¡{×'7Ñ'7¸4Ñ'?ð —J‘J˜wÓ'ˆEÜ”j Ó'Ó(ˆØ€Lr$   c                 óL   — t        | fi |¤Ž\  }}|�|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   )r   r   )	Úurlr   r   r   Úalternate_rootÚkwargsr   Úurlpathr   s	            r"   Ú
get_mapperr�   Ú   s8   € ôN ˜CÑ* 6Ñ*�K€BˆØ+Ð7‰>¸W€DÜ��r˜5 &Ð=OÔPÐPr$   )Ú FFNN)r†   Úloggingr   r   rQ   Úcollections.abcr   Ú	functoolsr   Úfsspec.corer   Ú	getLoggerr,   Úobjectrb   r   rH   r�   r€   r$   r"   ú<module>r˜      sd   ðÛ Û Û Û Û Ý *Ý %å !à	ˆ×	Ñ	Ð+Ó	,€Ù‹8€ô}RˆNô }Rò@ð 	Ø
ØØØô)Qr$   