
    ;3hr                         d Z ddlmZmZmZ ddlZddlmZmZm	Z	m
Z
  e
j                  e      Zdededed	efd
Zdej                   d	ee   fdZy)z;Contains utilities to handle pagination on Huggingface Hub.    )DictIterableOptionalN   )get_sessionhf_raise_for_statushttp_backoffloggingpathparamsheadersreturnc              #   d  K   t               }|j                  | ||      }t        |       |j                         E d{    t	        |      }|Zt
        j                  d|        t        d|dd|      }t        |       |j                         E d{    t	        |      }|Yyy7 l7 w)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   i  )max_retriesretry_on_status_codesr   )r   getr   json_get_next_pageloggerdebugr	   )r   r   r   sessionr	next_pages         a/var/www/html/audio-gradio/venv/lib/python3.12/site-packages/huggingface_hub/utils/_pagination.pypaginater      s      mGD9Avvx q!I

B9+NO	rQT^efA668"1%	 
  	s)   =B0B, AB0B.B0*B0.B0responsec                 X    | j                   j                  di       j                  d      S )Nnexturl)linksr   )r   s    r   r   r   3   s$    >>fb)--e44    )__doc__typingr   r   r   requests r   r   r	   r
   
get_logger__name__r   strr   Responser    r#   r   <module>r-      sl    B + +  E E 
		H	%&3 & &t & &05X.. 58C= 5r#   