o
    0j(                     @   sp   d Z ddlmZ ddlZddlmZmZmZmZ e	e
Zdededed	efd
dZdejd	edB fddZdS )z;Contains utilities to handle pagination on Huggingface Hub.    )IterableN   )get_sessionhf_raise_for_statushttp_backoffloggingpathparamsheadersreturnc                 c   s    t  }|j| ||d}t| | E dH  t|}|durCtd|  td||d}t| | E dH  t|}|dusdS dS )a/  Fetch a list of models/datasets/spaces and paginate through results.

    This is using the same "Link" header format as GitHub.
    See:
    - https://requests.readthedocs.io/en/latest/api/#requests.Response.links
    - https://docs.github.com/en/rest/guides/traversing-with-pagination#link-header
    )r	   r
   Nz+Pagination detected. Requesting next page: GET)r
   )r   getr   json_get_next_pageloggerdebugr   )r   r	   r
   sessionrZ	next_page r   b/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/huggingface_hub/utils/_pagination.pypaginate   s   r   responsec                 C   s   | j di dS )Nnexturl)linksr   )r   r   r   r   r   2   s   r   )__doc__collections.abcr   Zhttpx r   r   r   r   Z
get_logger__name__r   strdictr   Responser   r   r   r   r   <module>   s   
