U
    ™K7\å  ã                   @   sB   d Z ddlZdddg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Ú	translateéd   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    c                 C   s^   zt | }W nB tk
rN   t|ƒ}tt ƒtkr8t  ¡  t |¡ t |< }Y nX | | ¡dk	S )zŽTest 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    c                 C   s˜  dt | ƒ }}d}||k r| | }|d }|dkr’||k rˆ| | dkrˆ|d }||k rl| | dkrl|d }||kr~|d }q|d }n|d }q|d	kr¤|d
 }q|dkr€|}||k rÎ| | dkrÎ|d }||k rê| | dkrê|d }||k r| | dkr|d }qê||kr |d }n^| ||…  dd¡}|d }|d dkr\d|dd…  }n|d dkrrd| }d||f }q|t |¡ }q|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\\Nz%s[%s]ú$)r   Úreplacer   Úescape)r   ÚiÚnr   ÚcÚjZstuffr   r   r	   r   ?   sF    








)	Ú__doc__r   Ú__all__r   r   r
   r   r   r   r   r   r   r	   Ú<module>   s   
