Ë
    F^(h—   ã                   óš   — 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 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d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                 ó*  — || _         |j                  |«      | _        |j                  t        j                  |d«      «      d d | _        |€t        t        t        f}|| _	        || _
        || _        |r6| j                   j                  |«      s| j                   j                  |«       |rg| j                   j                  |«      st        d|› d�«      ‚| j                   j                  |dz   «       | j                   j!                  |dz   «       y y )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         úL/var/www/skyplay_api_hub/venv/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óð ð �G‰G�M‰M˜$ ™+Ô&Ø�G‰G�J‰J�t˜d‘{Õ#ð ó    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.dirfsB   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.clearI   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   Úkeysr.   ÚkÚkeys2ÚoeÚoutÚeÚvÚkeyÚk2s              r   ÚgetitemszFSMap.getitemsR   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)r4   r/   Úmaybe_convertr   Úpipe)r   Úvalues_dictr9   r>   Úvaluess        r   ÚsetitemszFSMap.setitemsx   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   r/   )r   r8   r9   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 TypeErrorú/)	r1   ÚstrÚwarningsÚwarnÚDeprecationWarningÚlistÚtupler   Úrstrip)r   r?   s     r   r/   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 nameNrK   )Ú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)r/   r   r0   r   r3   )r   r?   Údefaultr9   ÚresultÚexcs         r   Ú__getitem__zFSMap.__getitem__—   s^   € à×Ñ˜SÓ!ˆð	)Ø—W‘W—[‘[ “^ˆFð
 ˆøð	 ×&Ñ&ò 	)ØÐ"Ø•Ü˜3“- SÐ(ûð	)ús    “0 °A¿AÁAÁAÁAc                 óR   — | j                  ||«      }	 | |= |S # t        $ r Y |S w xY w)zPop data)r\   r3   )r   r?   rY   rZ   s       r   Úpopz	FSMap.pop¢   s@   € à×!Ñ! # wÓ/ˆð	Ø�S�	ð ˆøô ò 	ØØˆð	ús   ” ™	&¥&c                 óÜ   — | j                  |«      }| j                  j                  | j                  j                  |«      d¬«       | j                  j	                  |t        |«      «       y)zStore value in keyT)Úexist_okN)r/   r   ÚmkdirsÚ_parentÚ	pipe_filerC   )r   r?   Ú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)rW   )Ú.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 rh   )rT   r   rk   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   r/   Ú	Exceptionr3   )r   r?   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?)r/   r   Úisfile)r   r?   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)r,   rh   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r%   r*   rA   rG   rI   r/   rW   r\   r^   re   rl   rn   rq   rt   rv   © r   r   r   r      sk   „ ñó6$ð2 ñ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)r1   ÚarrayÚhasattrr~   ÚkindÚviewr2   Ú
memoryview)rd   s    r   rC   rC   Ç   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   rM   Úcollections.abcr   Ú	functoolsr   Úfsspec.corer   Ú	getLoggerr'   r   rC   r‹   r{   r   r   ú<module>r’      sZ   ðÛ Û Û Û Ý *Ý %å !à	ˆ×	Ñ	Ð+Ó	,€ôwRˆNô wRòtð 	Ø
ØØØô)Qr   