U
    ê¥¡c.  ã                   @   s0   d dl mZmZ dd„ Zd
dd„Zddd	„ZdS )é    )ÚPureWindowsPathÚPurePosixPathc                    sz   |rt ˆ ƒ‰ n$dd„ |D ƒ}dd„ |D ƒ}tˆ ƒ‰ ||@ }|rLtd |¡ƒ‚t‡ fdd„|D ƒƒoxt‡ fdd„|D ƒƒ S )zJInternal function same as :func:`match_path` but does not check arguments.c                 S   s   h | ]}|  ¡ ’qS © ©Úlower©Ú.0Úpatternr   r   ú;/tmp/pip-unpacked-wheel-thtqfo2i/watchdog/utils/patterns.pyÚ	<setcomp>   s     z_match_path.<locals>.<setcomp>c                 S   s   h | ]}|  ¡ ’qS r   r   r   r   r   r
   r      s     z/conflicting patterns `{}` included and excludedc                 3   s   | ]}ˆ   |¡V  qd S ©N©Úmatch©r   Úp©Úpathr   r
   Ú	<genexpr>   s     z_match_path.<locals>.<genexpr>c                 3   s   | ]}ˆ   |¡V  qd S r   r   r   r   r   r
   r      s     )r   r   Ú
ValueErrorÚformatÚany)r   Úincluded_patternsÚexcluded_patternsÚcase_sensitiveZcommon_patternsr   r   r
   Ú_match_path   s    
ÿr   NTc                 c   sL   |dkrdgn|}|dkrg n|}| D ] }t |t|ƒt|ƒ|ƒr&|V  q&dS )a@  
    Filters from a set of paths based on acceptable patterns and
    ignorable patterns.
    :param pathnames:
        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   Úset©Úpathsr   r   r   ZincludedZexcludedr   r   r   r
   Úfilter_paths"   s
    r    c                 C   sL   |dkrdgn|}|dkrg n|}| D ] }t |t|ƒt|ƒ|ƒr& dS q&dS )a  
    Matches from a set of paths based on acceptable patterns and
    ignorable patterns.
    :param pathnames:
        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:
        ``True`` if any of the paths matches; ``False`` otherwise.
    Nr   TFr   r   r   r   r
   Úmatch_any_paths>   s    r!   )NNT)NNT)Úpathlibr   r   r   r    r!   r   r   r   r
   Ú<module>   s   
