ó
    Ð]j—   ã                   óœ   • S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SKJ	r	  \R                  " S5      r " S S\5      rS r     S
S	 jrg)é    N)ÚMutableMapping)Úcached_property)Ú	url_to_fszfsspec.mappingc                   ó’   • \ rS rSrSrSS jr\S 5       rS rSS jr	S r
S	 rS
 rS rSS jrSS jrS rS rS rS rS rS rSrg)ÚFSMapé   a   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                 óN  • X l         UR                  U5      U l        UR                  [        R                  " US5      5      S S U l        Uc  [        [        [        4nXPl	        X0l
        X@l        U(       a;  U R                   R                  U5      (       d  U R                   R                  U5        U(       al  U R                   R                  U5      (       d  [        SU S35      eU R                   R                  US-   5        U R                   R!                  US-   5        g g )NÚxéÿÿÿÿzPath 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   r   r   r   r   s         ÚK/home/mande/repo/quber/.venv/lib/python3.13/site-packages/fsspec/mapping.pyÚ__init__ÚFSMap.__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                 óD   • SSK Jn  U" U R                  U R                  S9$ )z@dirfs instance that can be used with the same keys as the mapperé   )ÚDirFileSystem)Úpathr   )Úimplementations.dirfsr$   r   r   )r   r$   s     r   ÚdirfsÚFSMap.dirfsB   s   € õ 	9á $×"7Ñ"7¸D¿G¹GÑDÐDr!   c                 óê   • [         R                  SU R                  5         U R                  R	                  U R                  S5        U R                  R                  U R                  5        g!    g= f)z0Remove all keys below root - empties out mappingzClear mapping at %sTN)ÚloggerÚinfor   r   r   r   ©r   s    r   ÚclearÚFSMap.clearI   sN   € ä�‰Ð)¨4¯9©9Ô5ð	Ø�G‰G�J‰J�t—y‘y $Ô'Ø�G‰G�M‰M˜$Ÿ)™)Õ$øð	Ùús   ¢AA. Á.A2c                 óx  • U Vs/ s H  o0R                  U5      PM     nnUS:X  a  UOSn U R                  R                  XES9n[        U[        5      (       a  US   U0nUR                  5        VVs0 s H,  u  p8U[        X€R
                  5      (       a
  [        5       OU_M.     nnn[        X5       V	V
s0 s HI  u  pšUS:X  d  [        Xj   [        5      (       a  M$  X’S:X  a  Xj   OUR                  U
[        U
5      5      _MK     sn
n	$ s  snf ! U R
                   a  n[        UeSnAff = fs  snnf s  sn
n	f )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   Úkeysr2   ÚkÚkeys2ÚoeÚoutÚeÚvÚkeyÚk2s              r   ÚgetitemsÚFSMap.getitemsR   s/  € ñ( /3Ó3ªd¨×!Ñ! !Ö$©dˆÐ3Ø! WÓ,‰X°(ˆð	"Ø—'‘'—+‘+˜e�+Ð1ˆCÜ˜#œu×%Ñ%Ø˜Q‘x �o�ð
 Ÿ	™	œô
â#‘�ð œj¨×,CÑ,C×DÑD””
È!ÒKÙ#ð 	ñ 
ô ˜tÔ+ô
â+‘�Ø˜8Ó#¬:°c±g¼}×+Mó OˆC¨Ó/�’°S·W±W¸RÄÈ"ÃÓ5NÒNÙ+ò
ð 	
ùò 4øð ×&Ñ&ó 	"Ü Ð!ûð	"üó
ùó
s.   …D¬5D Á43D0Â8#D6Ã)D6ÄD-Ä!D(Ä(D-c                 óÀ   • UR                  5        VVs0 s H   u  p#U R                  U5      [        U5      _M"     nnnU R                  R	                  U5        gs  snnf )zcSet the values of multiple items in the store

Parameters
----------
values_dict: dict(str, bytes)
N)r8   r3   Úmaybe_convertr   Úpipe)r   Úvalues_dictr=   rB   Úvaluess        r   ÚsetitemsÚFSMap.setitemsx   sR   € ð EP×DUÑDUÔDWÔXÒDW¹D¸A�$×"Ñ" 1Ó%¤}°QÓ'7Ò7ÑDWˆÑXØ�‰�‰�VÕùó Ys   ”'Ac                 ó‚   • U R                   R                  U Vs/ s H  o R                  U5      PM     sn5        gs  snf )z#Remove multiple keys from the storeN)r   r   r3   )r   r<   r=   s      r   ÚdelitemsÚFSMap.delitems‚   s-   € à�‰�
‰
±Ó6²¨A×$Ñ$ QÖ'±Ñ6Õ7ùÒ6s   š<c                 óö   • [        U[        5      (       dF  [        R                  " S[        5        [        U[
        5      (       a  [        U5      n[        U5      nU R                   U 3R                  S5      $ )zGenerate full path for the keyzAfrom fsspec 2023.5 onward FSMap non-str keys will raise TypeErrorÚ/)	r5   ÚstrÚwarningsÚwarnÚDeprecationWarningÚlistÚtupler   Úrstrip)r   rC   s     r   r3   ÚFSMap._key_to_str†   sc   € ä˜#œs×#Ñ#ä�MŠMØSÜ"ôô ˜#œt×$Ñ$Ü˜C“j�Ü�c“(ˆCØ×'Ñ'Ð(¨¨Ð.×5Ñ5°cÓ:Ð:r!   c                 óP   • U[        U R                  5      S R                  S5      $ )zStrip path of to leave key nameNrR   )Úlenr   Úlstrip)r   Úss     r   Ú_str_to_keyÚFSMap._str_to_key“   s#   € à”�T—Y‘Y“Ð!Ð"×)Ñ)¨#Ó.Ð.r!   c                 ó¼   • U R                  U5      n U R                  R                  U5      nU$ ! U R                   a  nUb  Us SnA$ [	        U5      UeSnAff = f)zRetrieve dataN)r3   r   r4   r   r7   )r   rC   Údefaultr=   ÚresultÚexcs         r   Ú__getitem__ÚFSMap.__getitem__—   s^   € à×Ñ˜SÓ!ˆð	)Ø—W‘W—[‘[ “^ˆFð
 ˆøð	 ×&Ñ&ó 	)ØÑ"Ø•Ü˜3“- SÐ(ûð	)ús!   “0 °AÁ AÁAÁ
AÁAc                 óP   • U R                  X5      n X	 U$ ! [         a     U$ f = f)zPop data)re   r7   )r   rC   rb   rc   s       r   ÚpopÚ	FSMap.pop¢   s<   € à×!Ñ! #Ó/ˆð	Ø�	ð ˆøô ó 	ØØˆð	ús   “ —
%¤%c                 óÖ   • U R                  U5      nU R                  R                  U R                  R                  U5      SS9  U R                  R	                  U[        U5      5        g)zStore value in keyT)Úexist_okN)r3   r   ÚmkdirsÚ_parentÚ	pipe_filerH   )r   rC   Úvalues      r   Ú__setitem__ÚFSMap.__setitem__«   sL   € à×Ñ˜sÓ#ˆØ�‰�‰�t—w‘w—‘ sÓ+°dˆÑ;Ø�‰×Ñ˜#œ}¨UÓ3Õ4r!   c                 ób   ^ • U 4S jT R                   R                  T R                  5       5       $ )Nc              3   óF   >#   • U  H  nTR                  U5      v •  M     g 7f©N)r_   )Ú.0r
   r   s     €r   Ú	<genexpr>Ú!FSMap.__iter__.<locals>.<genexpr>²   s!   øé € ÐEÒ-D¨�× Ñ  ×#Ð#Ò-Dùs   ƒ!)r   Úfindr   r,   s   `r   Ú__iter__ÚFSMap.__iter__±   s   ø€ ÜE¨T¯W©W¯\©\¸$¿)¹)Ô-DÓEÐEr!   c                 ó^   • [        U R                  R                  U R                  5      5      $ rt   )r\   r   rx   r   r,   s    r   Ú__len__ÚFSMap.__len__´   s   € Ü�4—7‘7—<‘< §	¡	Ó*Ó+Ð+r!   c                 óŒ   •  U R                   R                  U R                  U5      5        g! [         a  n[        UeSnAff = f)z
Remove keyN)r   r   r3   Ú	Exceptionr7   )r   rC   rd   s      r   Ú__delitem__ÚFSMap.__delitem__·   s:   € ð	$Ø�G‰G�J‰J�t×'Ñ'¨Ó,Õ-øÜó 	$Ü Ð#ûð	$ús   ‚*- ­
A·>¾Ac                 óZ   • U R                  U5      nU R                  R                  U5      $ )zDoes key exist in mapping?)r3   r   Úisfile)r   rC   r%   s      r   Ú__contains__ÚFSMap.__contains__¾   s%   € à×Ñ Ó$ˆØ�w‰w�~‰~˜dÓ#Ð#r!   c                 óX   • [         U R                  U R                  SSU R                  44$ )NF)r   r   r   r   r,   s    r   Ú
__reduce__ÚFSMap.__reduce__Ã   s&   € Ü�t—y‘y $§'¡'¨5°%¸×9PÑ9PÐQÐQÐQr!   )r   r   r   r   r   r   )FFN)r0   rt   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r'   r-   rE   rL   rO   r3   r_   re   rh   rp   ry   r|   r€   r„   r‡   Ú__static_attributes__© r!   r   r   r      sk   † ñô6$ð2 ñEó ðEòô$
òLò8ò;ò/ô	ôò5òFò,ò$ò$õ
Rr!   r   c                 ó  • [        U [        R                  5      (       d  [        U S5      (       aP  [        U S5      (       a+  U R                  R                  S;   a  U R                  S5      n [        [        U 5      5      n U $ )NÚ	__array__ÚdtypeÚMmÚint64)r5   ÚarrayÚhasattrr’   ÚkindÚviewr6   Ú
memoryview)ro   s    r   rH   rH   Ç   sa   € Ü�%œŸ™×%Ñ%¬°¸×)DÑ)Dä�5˜'×"Ñ" u§{¡{×'7Ñ'7¸4Ó'?ð —J‘J˜wÓ'ˆEÜ”j Ó'Ó(ˆØ€Lr!   c                 óB   • [        U 40 UD6u  pgUb  UOUn[        X†XUS9$ )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Ÿ   Ò   s2   € ôN ˜CÑ* 6Ñ*�K€BØ+Ñ7‰>¸W€DÜ�˜5Ð=OÑPÐPr!   )Ú FFNN)r•   Úloggingr   rT   Úcollections.abcr   Ú	functoolsr   Úfsspec.corer   Ú	getLoggerr*   r   rH   rŸ   r�   r!   r   Ú<module>r¦      sX   ðÛ Û Û Û Ý *Ý %å !à	×	Ò	Ð+Ó	,€ôwRˆNô wRòtð 	Ø
ØØØõ)Qr!   