
    7Th                          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xz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         F/var/www/auris/envauris/lib/python3.13/site-packages/fsspec/mapping.py__init__FSMap.__init__)   s    &&t,	 " 2 29>>$3L Mcr R%!!""
 #5
77>>$''d#77>>$'' D6 "8 9  GGMM$+&GGJJtd{#     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"7DGG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    )4995	GGJJtyy$'GGMM$))$	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[        XR
                  5      (       a
  [        5       OU_M.     nnn[        X5       V	V
s0 s HI  u  pUS:X  d  [        Xj   [        5      (       a  M$  XS: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3d!!!$d3!W,X(	"''++e+1C#u%%Qxo
 		
# j,C,CDD
!K# 	 
 t+
+8#:cg}+M OC/SWWR"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DUDUDWXDWDA$""1%}Q'77DW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##MMS" #t$$Cjc(C''(.55c::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#    TYY!"))#..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!	)WW[[^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#tww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  ##-Ds   !)r   findr   r,   s   `r   __iter__FSMap.__iter__   s    ETWW\\$))-DEEr!   c                 ^    [        U R                  R                  U R                  5      5      $ rt   )r\   r   rx   r   r,   s    r   __len__FSMap.__len__   s    477<<		*++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:    	$GGJJt'',- 	$#	$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%    $ww~~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&    tyy$''5%9P9P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'74'? JJw'Ej'(Lr!   c                 B    [        U 40 UD6u  pgUb  UOUn[        XX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*KB+7>WD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!   