Ë
    Q^(h²  ã                   óê   — d Z ddlmZ ddlmZ ddlmZmZmZmZm	Z	m
Z
mZ  e
d«      Zg d¢ZddgZd	d	d	d
œdee   de	eee   ef      de	eee   ef      de	eegef      deed	d	f   f
d„Zdedefd„Zy	)z6Contains utilities to handle paths in Huggingface Hub.é    ©Úfnmatch)ÚPath)ÚCallableÚ	GeneratorÚIterableÚListÚOptionalÚTypeVarÚUnionÚT)ú.gitz.git/*z*/.gitz
**/.git/**z.cache/huggingfacez.cache/huggingface/*z*/.cache/huggingfacez**/.cache/huggingface/**r   z.cacheN)Úallow_patternsÚignore_patternsÚkeyÚitemsr   r   r   Úreturnc             #   ó€  ‡K  — t        |t        «      r|g}t        |t        «      r|g}|�|D �cg c]  }t        |«      ‘Œ }}|�|D �cg c]  }t        |«      ‘Œ }}|€dt        dt        fd„}|}| D ]<  } ||«      Š|�t	        ˆfd„|D «       «      sŒ"|�t	        ˆfd„|D «       «      rŒ9|–— Œ> yc c}w c c}w ­w)aÀ  Filter repo objects based on an allowlist and a denylist.

    Input must be a list of paths (`str` or `Path`) or a list of arbitrary objects.
    In the later case, `key` must be provided and specifies a function of one argument
    that is used to extract a path from each element in iterable.

    Patterns are Unix shell-style wildcards which are NOT regular expressions. See
    https://docs.python.org/3/library/fnmatch.html for more details.

    Args:
        items (`Iterable`):
            List of items to filter.
        allow_patterns (`str` or `List[str]`, *optional*):
            Patterns constituting the allowlist. If provided, item paths must match at
            least one pattern from the allowlist.
        ignore_patterns (`str` or `List[str]`, *optional*):
            Patterns constituting the denylist. If provided, item paths must not match
            any patterns from the denylist.
        key (`Callable[[T], str]`, *optional*):
            Single-argument function to extract a path from each item. If not provided,
            the `items` must already be `str` or `Path`.

    Returns:
        Filtered list of objects, as a generator.

    Raises:
        :class:`ValueError`:
            If `key` is not provided and items are not `str` or `Path`.

    Example usage with paths:
    ```python
    >>> # Filter only PDFs that are not hidden.
    >>> list(filter_repo_objects(
    ...     ["aaa.PDF", "bbb.jpg", ".ccc.pdf", ".ddd.png"],
    ...     allow_patterns=["*.pdf"],
    ...     ignore_patterns=[".*"],
    ... ))
    ["aaa.pdf"]
    ```

    Example usage with objects:
    ```python
    >>> list(filter_repo_objects(
    ... [
    ...     CommitOperationAdd(path_or_fileobj="/tmp/aaa.pdf", path_in_repo="aaa.pdf")
    ...     CommitOperationAdd(path_or_fileobj="/tmp/bbb.jpg", path_in_repo="bbb.jpg")
    ...     CommitOperationAdd(path_or_fileobj="/tmp/.ccc.pdf", path_in_repo=".ccc.pdf")
    ...     CommitOperationAdd(path_or_fileobj="/tmp/.ddd.png", path_in_repo=".ddd.png")
    ... ],
    ... allow_patterns=["*.pdf"],
    ... ignore_patterns=[".*"],
    ... key=lambda x: x.repo_in_path
    ... ))
    [CommitOperationAdd(path_or_fileobj="/tmp/aaa.pdf", path_in_repo="aaa.pdf")]
    ```
    NÚitemr   c                 óz   — t        | t        «      r| S t        | t        «      rt        | «      S t        d| › d�«      ‚)Nz9Please provide `key` argument in `filter_repo_objects`: `z` is not a string.)Ú
isinstanceÚstrr   Ú
ValueError)r   s    úZ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/huggingface_hub/utils/_paths.pyÚ	_identityz&filter_repo_objects.<locals>._identitys   s=   € Ü˜$¤Ô$Ø�Ü˜$¤Ô%Ü˜4“yÐ ÜÐXÐY]ÐX^Ð^pÐqÓrÐró    c              3   ó6   •K  — | ]  }t        ‰|«      –— Œ y ­w©Nr   ©Ú.0ÚrÚpaths     €r   ú	<genexpr>z&filter_repo_objects.<locals>.<genexpr>€   s   øè ø€ Ò1[Àq´'¸$À×2BÑ1[ùó   ƒc              3   ó6   •K  — | ]  }t        ‰|«      –— Œ y ­wr   r   r   s     €r   r#   z&filter_repo_objects.<locals>.<genexpr>„   s   øè ø€ Ò.YÀA¬w°t¸Q×/?Ñ.Yùr$   )r   r   Ú_add_wildcard_to_directoriesr   Úany)r   r   r   r   Úpr   r   r"   s          @r   Úfilter_repo_objectsr)   '   sä   øè ø€ ô~ �.¤#Ô&Ø(Ð)ˆä�/¤3Ô'Ø*Ð+ˆàÐ!ØCQÖR¸aÔ6°qÕ9ÐRˆÐRØÐ"ØDSÖT¸qÔ7¸Õ:ÐTˆÐTà
€{ð	sœAð 	s¤#ó 	sð ˆàò ˆÙ�4‹yˆð Ð%¬cÓ1[ÈNÔ1[Ô.[Øð Ð&¬3Ó.YÈÔ.YÔ+YØà‹
ñùò SùâTùs   ƒ-B>°B4ÁB>Á
B9ÁA"B>Úpatternc                 ó    — | d   dk(  r| dz   S | S )Néÿÿÿÿú/Ú*© )r*   s    r   r&   r&   Š   s   € Øˆr�{�cÒØ˜‰}ÐØ€Nr   )Ú__doc__r   Úpathlibr   Útypingr   r   r   r	   r
   r   r   r   ÚDEFAULT_IGNORE_PATTERNSÚFORBIDDEN_FOLDERSr   r)   r&   r/   r   r   ú<module>r5      sÖ   ðñ =å Ý ß P× PÑ Pñ ˆCƒL€ò	Ð ð ˜XÐ&Ð ð 7;Ø7;Ø(,ò`Ø�A‰;ð`ð ˜U 4¨¡9¨c >Ñ2Ñ3ð`ð ˜e D¨¡I¨s NÑ3Ñ4ð	`ð
 
�(˜A˜3 ˜8Ñ$Ñ	%ð`ð ˆq�$˜ˆ}Ñó`ðF¨#ð °#ô r   