o
    Ni                     @   sP   d dl Z d dlmZmZ d dlmZmZmZmZm	Z	 d dl
Z
G dd deZdS )    N)ABCabstractmethod)ClassVarOptionalTupleTypeUnionc                   @   s   e Zd ZU dZejjejjfZe	e
ee df  ed< 	 e Ze	eee
edf f  ed< 	 deddfdd	Zedee fd
dZedee fddZedejddfddZdededefddZdS )SchemeClienta  
    A client used for caching remote resources corresponding to URLs with a particular scheme.

    Subclasses must define the :attr:`scheme` class variable and implement
    :meth:`get_etag()` and :meth:`get_resource()`.

    .. important::
        Take care when implementing subclasses to raise the right error types
        from :meth:`get_etag()` and :meth:`get_resource()`.
    .recoverable_errorsschemeresourcereturnNc                 C   s
   || _ d S )N)r   )selfr    r   U/home/ubuntu/.local/lib/python3.10/site-packages/cached_path/schemes/scheme_client.py__init__%   s   
zSchemeClient.__init__c                 C      t )a  
        Get the Etag or an equivalent version identifier associated with the resource.

        Returns
        -------
        ``Optional[str]``
            The ETag as a ``str`` or ``None`` if there is no ETag associated with
            the resource.

        Raises
        ------
        ``FileNotFoundError``
            If the resource doesn't exist.

        ``Recoverable error``
            Any error type defined in ``SchemeClient.recoverable_errors`` will
            be treated as a recoverable error.

            This means that when of these is caught by ``cached_path()``,
            it will look for cached versions of the given resource and return the
            latest version if there are any.

            Otherwise the error is propogated.

        ``Other errors``
            Any other error type can be raised. These errors will be treated non-recoverable
            and will be propogated immediately by ``cached_path()``.
        NotImplementedErrorr   r   r   r   get_etag(   s   zSchemeClient.get_etagc                 C   r   )a  
        Get the size of the resource in bytes (if known).

        Returns
        -------
        ``Optional[int]``
            The size (in bytes).

        Raises
        ------
        ``FileNotFoundError``
            If the resource doesn't exist.

        ``Recoverable error``
            Any error type defined in ``SchemeClient.recoverable_errors`` will
            be treated as a recoverable error.

            This means that when of these is caught by ``cached_path()``, the size
            will be ignored.

        ``Other errors``
            Any other error type can be raised. These errors will be treated non-recoverable
            and will be propogated immediately by ``cached_path()``.
        r   r   r   r   r   get_sizeH   s   zSchemeClient.get_size	temp_filec                 C   r   )ah  
        Download the resource to the given temporary file.

        Raises
        ------
        ``FileNotFoundError``
            If the resource doesn't exist.

        ``Other errors``
            Any other error type can be raised. These errors will be treated non-recoverable
            and will be propagated immediately by ``cached_path()``.
        r   )r   r   r   r   r   get_resourced   s   zSchemeClient.get_resourceindexlengthc                 C   s   ~~t )a  
        Get a sequence of ``length`` bytes from the resource, starting at ``index`` bytes.

        If a scheme provides a direct way of downloading a bytes range, the scheme client
        should implement that. Otherwise the entire file has to be downloaded.
        r   )r   r   r   r   r   r   get_bytes_ranget   s   zSchemeClient.get_bytes_range)__name__
__module____qualname____doc__requests
exceptionsConnectionErrorTimeoutr
   r   r   r   BaseException__annotations__tupler   r   strr   r   r   r   intr   ioBufferedWriterr   bytesr   r   r   r   r   r	      s    
 "r	   )r*   abcr   r   typingr   r   r   r   r   r!   r	   r   r   r   r   <module>   s
    