o
    ²Çhu	  ã                   @  sh   d dl mZ d dlZd dlZd dlmZ G dd„ dejƒZG dd„ deƒZG dd	„ d	eƒZ	ddd„Z
dS )é    )ÚannotationsN)Úmake_path_posixc                   @  s4   e Zd ZdZejddd„ƒZdd
d„Zddd„ZdS )ÚAbstractCacheMapperzUAbstract super-class for mappers from remote URLs to local cached
    basenames.
    ÚpathÚstrÚreturnc                 C  s   d S ©N© ©Úselfr   r	   r	   úw/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/fsspec/implementations/cache_mapper.pyÚ__call__   s   zAbstractCacheMapper.__call__ÚotherÚobjectÚboolc                 C  s   t |t| ƒƒS r   )Ú
isinstanceÚtype©r   r   r	   r	   r   Ú__eq__   s   zAbstractCacheMapper.__eq__Úintc                 C  s   t t| ƒƒS r   )Úhashr   ©r   r	   r	   r   Ú__hash__   s   zAbstractCacheMapper.__hash__N©r   r   r   r   ©r   r   r   r   ©r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚabcÚabstractmethodr   r   r   r	   r	   r	   r   r   	   s    
r   c                      sF   e Zd ZdZdddd„Zdd
d„Zd‡ fdd„Zd‡ fdd„Z‡  ZS )ÚBasenameCacheMapperzóCache mapper that uses the basename of the remote URL and a fixed number
    of directory levels above this.

    The default is zero directory levels, meaning different paths with the same
    basename will have the same cached basename.
    r   Údirectory_levelsr   c                 C  s    |dk rt dƒ‚|| _d| _d S )Nr   z>BasenameCacheMapper requires zero or positive directory_levelsz_@_)Ú
ValueErrorr#   Ú
_separator)r   r#   r	   r	   r   Ú__init__$   s   ÿ
zBasenameCacheMapper.__init__r   r   r   c                 C  s2   t |ƒ}| d| jd ¡^}}|r| j |¡S |S )Nú/é   )r   Úrsplitr#   r%   Újoin)r   r   ÚprefixÚbitsr	   r	   r   r   .   s
   zBasenameCacheMapper.__call__r   r   r   c                   s   t ƒ  |¡o| j|jkS r   )Úsuperr   r#   r   ©Ú	__class__r	   r   r   6   s   zBasenameCacheMapper.__eq__c                   s   t ƒ  ¡ t| jƒA S r   )r-   r   r   r#   r   r.   r	   r   r   9   s   zBasenameCacheMapper.__hash__)r   )r#   r   r   r   r   )	r   r   r   r   r&   r   r   r   Ú__classcell__r	   r	   r.   r   r"      s    

r"   c                   @  s   e Zd ZdZddd„ZdS )	ÚHashCacheMapperz0Cache mapper that uses a hash of the remote URL.r   r   r   c                 C  s   t  | ¡ ¡ ¡ S r   )ÚhashlibÚsha256ÚencodeÚ	hexdigestr
   r	   r	   r   r   @   s   zHashCacheMapper.__call__Nr   )r   r   r   r   r   r	   r	   r	   r   r1   =   s    r1   Ú
same_namesr   r   c                 C  s   | rt ƒ S tƒ S )zŒFactory method to create cache mapper for backward compatibility with
    ``CachingFileSystem`` constructor using ``same_names`` kwarg.
    )r"   r1   )r6   r	   r	   r   Úcreate_cache_mapperD   s   r7   )r6   r   r   r   )Ú
__future__r   r    r2   Úfsspec.implementations.localr   ÚABCr   r"   r1   r7   r	   r	   r	   r   Ú<module>   s    !