o
    hX                     @  sr   d Z ddlmZ ddlmZmZ ddlmZ erddlm	Z	 dddZ
dddddddZdddddddZdS )u  :module: watchdog.utils.patterns
:synopsis: Common wildcard searching/filtering functionality for files.
:author: boris.staletic@gmail.com (Boris Staletic)
:author: yesudeep@gmail.com (Yesudeep Mangalapilly)
:author: contact@tiger-222.fr (Mickaël Schoentgen)
    )annotations)PurePosixPathPureWindowsPath)TYPE_CHECKING)Iteratorraw_pathstrincluded_patternsset[str]excluded_patternscase_sensitiveboolreturnc                  s   |rt |  ndd |D }dd |D }t|  ||@ }|r)d| d}t|t fdd|D o?t fdd|D  S )zJInternal function same as :func:`match_path` but does not check arguments.c                 S     h | ]}|  qS  lower.0patternr   r   K/var/www/vscode/kcb/lib/python3.10/site-packages/watchdog/utils/patterns.py	<setcomp>$       z_match_path.<locals>.<setcomp>c                 S  r   r   r   r   r   r   r   r   %   r   zconflicting patterns `z` included and excludedc                 3  s    | ]}  |V  qd S )N)match)r   ppathr   r   	<genexpr>-   s    z_match_path.<locals>.<genexpr>)r   r   
ValueErrorany)r   r	   r   r   common_patternserrorr   r   r   _match_path   s   	
.r"   NTr	   r   r   paths	list[str]list[str] | NoneIterator[str]c                c  sP    t |du r	dgn|}t |du rg n|}| D ]}t||||dr%|V  qdS )a7  Filters from a set of paths based on acceptable patterns and
    ignorable patterns.
    :param paths:
        A list of path names that will be filtered based on matching and
        ignored patterns.
    :param included_patterns:
        Allow filenames matching wildcard patterns specified in this list.
        If no pattern list is specified, ["*"] is used as the default pattern,
        which matches all files.
    :param excluded_patterns:
        Ignores filenames matching wildcard patterns specified in this list.
        If no pattern list is specified, no files are ignored.
    :param case_sensitive:
        ``True`` if matching should be case-sensitive; ``False`` otherwise.
    :returns:
        A list of pathnames that matched the allowable patterns and passed
        through the ignored patterns.
    N*)r   )setr"   )r$   r	   r   r   includedexcludedr   r   r   r   filter_paths0   s   r,   c                C  s   t t| |||dS )zMatches from a set of paths based on acceptable patterns and
    ignorable patterns.
    See ``filter_paths()`` for signature details.
    r#   )r   r,   )r$   r	   r   r   r   r   r   match_any_pathsQ   s   r-   )
r   r   r	   r
   r   r
   r   r   r   r   )
r$   r%   r	   r&   r   r&   r   r   r   r'   )
r$   r%   r	   r&   r   r&   r   r   r   r   )__doc__
__future__r   pathlibr   r   typingr   collections.abcr   r"   r,   r-   r   r   r   r   <module>   s    	
$