ó
    pyüi‘  ã                   óä   • S r SSKJrJrJr  SSKJr  SSKJr  SSKJ	r	  \	" S5      r
/ SQrSS	/rS
S
S
S.S\\
   S\\   \-  S
-  S\\   \-  S
-  S\\
/\4   S
-  S\\
S
S
4   4
S jjrS\S\4S jrg
)z6Contains utilities to handle paths in Huggingface Hub.é    )ÚCallableÚ	GeneratorÚIterable©Úfnmatch)ÚPath)ÚTypeVarÚ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             #   óÌ  ^#   • [        U[        5      (       a  U/n[        U[        5      (       a  U/nUb  U Vs/ s H  n[        U5      PM     nnUb  U Vs/ s H  n[        U5      PM     nnUc  S[        S[        4S jnUnU  HM  nU" U5      mUb  [	        U4S jU 5       5      (       d  M*  Ub  [	        U4S jU 5       5      (       a  MI  Uv •  MO     gs  snf s  snf 7f)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 Standard Wildcards (globbing patterns), NOT regular expressions.
The pattern matching is based on Python's `fnmatch`. Note that `fnmatch` matches
`*` across path boundaries, unlike traditional Unix shell globbing. For example,
`"data/*.json"` will match both `data/file.json` and `data/subdir/file.json`.
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                 óŽ   • [        U [        5      (       a  U $ [        U [        5      (       a  [        U 5      $ [        SU  S35      e)Nz9Please provide `key` argument in `filter_repo_objects`: `z` is not a string.)Ú
isinstanceÚstrr   Ú
ValueError)r   s    ÚY/home/mande/repo/quber/.venv/lib/python3.13/site-packages/huggingface_hub/utils/_paths.pyÚ	_identityÚ&filter_repo_objects.<locals>._identityv   sC   € Ü˜$¤×$Ñ$Ø�Ü˜$¤×%Ñ%Ü˜4“yÐ ÜÐXÐY]ÐX^Ð^pÐqÓrÐró    c              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7f©Nr   ©Ú.0ÚrÚpaths     €r   Ú	<genexpr>Ú&filter_repo_objects.<locals>.<genexpr>ƒ   s   øé € Ð1[ÊNÀq´'¸$À×2BÐ2BÊNùó   ƒc              3   ó<   >#   • U  H  n[        TU5      v •  M     g 7fr   r   r   s     €r   r!   r"   ‡   s   øé € Ð.YÊÀA¬w°t¸Q×/?Ð/?Êùr#   )r   r   Ú_add_wildcard_to_directoriesr
   Úany)r   r   r   r   Úpr   r   r    s          @r   Úfilter_repo_objectsr(   '   sì   øé € ôD �.¤#×&Ñ&Ø(Ð)ˆä�/¤3×'Ñ'Ø*Ð+ˆàÑ!ÙCQÓRÂ>¸aÔ6°qÖ9Á>ˆÐRØÑ"ÙDSÓTÂO¸qÔ7¸Ö:ÁOˆÐTà
�{ð	sœAð 	s¤#ô 	sð ˆãˆÙ�4‹yˆð Ñ%¬cÔ1[ÉNÓ1[×.[Ñ.[Ùð Ñ&¬3Ô.YÉÓ.Y×+YÑ+YÙàŒ
ò ùò SùâTùs   ƒ8C$»CÁ	C$ÁCÁ.A6C$Úpatternc                 ó"   • U S   S:X  a  U S-   $ U $ )NéÿÿÿÿÚ/Ú*© )r)   s    r   r%   r%   �   s   € Øˆr�{�cÓØ˜‰}ÐØ€Nr   )Ú__doc__Úcollections.abcr   r   r   r   Úpathlibr   Útypingr	   r
   ÚDEFAULT_IGNORE_PATTERNSÚFORBIDDEN_FOLDERSÚlistr   r(   r%   r.   r   r   Ú<module>r6      sÌ   ðñ =ç 9Ñ 9Ý Ý Ý ñ ˆCƒL€ò	Ð ð ˜XÐ&Ð ð .2Ø.2Ø%)òcØ�A‰;ðcð ˜‘I ‘O dÑ*ðcð ˜#‘Y ‘_ tÑ+ð	cð
 
�1�#�s�(Ñ	˜dÑ	"ðcð ˆq�$˜ˆ}ÑõcðL¨#ð °#õ r   