o
    2.a                     @   s@   d Z ddlZg dZi ZdZdd Zdd Zd	d
 Zdd ZdS )a  Filename matching with shell patterns.

fnmatch(FILENAME, PATTERN) matches according to the local convention.
fnmatchcase(FILENAME, PATTERN) always takes case in account.

The functions operate by translating the pattern into a regular
expression.  They cache the compiled regular expressions for speed.

The function translate(PATTERN) returns a regular expression
corresponding to PATTERN.  (It does not compile it.)
    N)fnmatchfnmatchcase	translated   c                   C   s   t   dS )zClear the pattern cacheN)_cacheclear r   r   6/usr/lib/python3/dist-packages/docker/utils/fnmatch.py_purge   s   r
   c                 C   s   |   } |  }t| |S )a  Test whether FILENAME matches PATTERN.

    Patterns are Unix shell style:

    *       matches everything
    ?       matches any single character
    [seq]   matches any character in seq
    [!seq]  matches any char not in seq

    An initial period in FILENAME is not special.
    Both FILENAME and PATTERN are first case-normalized
    if the operating system requires it.
    If you don't want this, use fnmatchcase(FILENAME, PATTERN).
    )lowerr   )namepatr   r   r	   r      s   
r   c                 C   s\   zt | }W n  ty&   t|}tt tkrt   t| t |< }Y nw || duS )zTest whether FILENAME matches PATTERN, including case.
    This is a version of fnmatch() which doesn't case-normalize
    its arguments.
    N)	r   KeyErrorr   len	_MAXCACHEr   recompilematch)r   r   Zre_patresr   r   r	   r   /   s   r   c                 C   s  dt | }}d}||k r| | }|d }|dkrH||k rC| | dkrC|d }||k r5| | dkr5|d }||kr>|d }n|d }n|d }n|d	krQ|d
 }nz|dkr|}||k re| | dkre|d }||k rs| | dkrs|d }||k r| | dkr|d }||k r| | dks}||kr|d }n7| || dd}|d }|d dkrd|dd  }n
|d dkrd| }| d| d}n|t| }||k s|d S )zfTranslate a shell PATTERN to a regular expression.

    There is no way to quote meta-characters.
    r   ^   */z.*z(.*/)?z[^/]*?z[^/][!]z\[\z\\N$)r   replacer   escape)r   inr   cjstuffr   r   r	   r   ?   sJ   




-r   )	__doc__r   __all__r   r   r
   r   r   r   r   r   r   r	   <module>   s    