
    Rho                     |    d Z ddlZddlZddlZddlZg dZd Z ej                  dd      d        Zd	 Z	d
 Z
d Zy)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)filterfnmatchfnmatchcase	translatec                     t         j                  j                  |       } t         j                  j                  |      }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).
    )ospathnormcaser   )namepats     /usr/lib/python3.12/fnmatch.pyr   r      s9     77D!D
''

3
CtS!!    i   T)maxsizetypedc                     t        | t              r$t        | d      }t        |      }t        |d      }nt        |       }t	        j
                  |      j                  S )Nz
ISO-8859-1)
isinstancebytesstrr   recompilematch)r   pat_strres_strress       r   _compile_patternr   &   sK    #uc<(G$G\*n::c?   r   c                 L   g }t         j                  j                  |      }t        |      }t         j                  t        u r#| D ]  } ||      s|j                  |        |S | D ]9  } |t         j                  j                  |            s)|j                  |       ; |S )zJConstruct a list from those elements of the iterable NAMES that match PAT.)r   r	   r
   r   	posixpathappend)namesr   resultr   r   s        r   r   r   0   s    F
''

3
CS!E	ww) 	$DT{d#	$ M  	$DRWW%%d+,d#	$ Mr   c                 ,    t        |      } ||       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   )r   r   r   s      r   r   r   @   s     S!E;d""r   c                 f   t               }g }|j                  }dt        |       }}||k  r| |   }|dz   }|dk(  r|r|d   |ur ||       n|dk(  r
 |d       n|dk(  r|}||k  r| |   dk(  r|dz   }||k  r| |   d	k(  r|dz   }||k  r| |   d	k7  r|dz   }||k  r	| |   d	k7  r||k\  r
 |d
       nq| || }d|vr|j                  dd      }ng }	| |   dk(  r|dz   n|dz   }
	 | j	                  d|
|      }
|
dk  rn|	j                  | ||
        |
dz   }|
dz   }
8| || }|r|	j                  |       n|	dxx   dz  cc<   t        t        |	      dz
  dd      D ]4  }
|	|
dz
     d   |	|
   d   kD  s|	|
dz
     dd |	|
   dd z   |	|
dz
  <   |	|
= 6 dj                  d |	D              }t        j                  dd|      }|dz   }|s	 |d       nS|dk(  r	 |d       nE|d   dk(  r	d|dd z   }n|d   dv rd|z   } |d| d	       n |t        j                  |             ||k  r||k(  sJ |}g }|j                  }dt        |      }}||k  r$||   |ur |||          |dz  }||k  r||   |ur||k  r||   |u sJ |dz  }||k(  r	 |d       nv||   |usJ g }||k  r-||   |ur&|j                  ||          |dz  }||k  r||   |ur&dj                  |      }||k(  r |d        ||       n |d| d       ||k  r||k(  sJ dj                  |      }d| dS )zfTranslate a shell PATTERN to a regular expression.

    There is no way to quote meta-characters.
    r      *?.[!]z\[-\\\      Nc              3   `   K   | ]&  }|j                  d d      j                  dd       ( yw)r,   r-   r+   z\-N)replace).0ss     r   	<genexpr>ztranslate.<locals>.<genexpr>   s0      %6)* &'YYtU%;%C%CC%O %6s   ,.z([&~|])z\\\1z(?!)^)r5   r(   z.* z(?>.*?)z(?s:z)\Z)
objectr   lenr1   findrangejoinr   subescape)r   STARr   addincjstuffchunkskchunkinpfixeds                 r   r   r   J   s
    8D
C
**Cc#hqA
a%FaC8CG4/D	#XH#XA1uQ3aC1uQ3aCa%CFcMaC a%CFcMAvE
Aae#!MM$6EF"1v}!!A#AHHS!Q/q5!c!Ah/aCaC   !HEe,r
c)
"3v;q=!R8 *!!A#;r?VAYq\9*01+cr*:VAYqr]*JF1Q3K &q	*  HH %6.4%6 6E z7E:aCKc\HQx3 #eABiqZ/ $u!E7!%		! a%@ 6M6 C
C
**Cc#hqA
a%CF$&CF	Q a%CF$& a%1v~~	Q6I1vT!!!!eAd*LLQ FA !eAd* 6IJ&q!"! a%" 6M6
''#,C3%sr   )__doc__r   r   r   	functools__all__r   	lru_cacher   r   r   r    r   r   <module>rP      sU   
 
  	 
;"& U$/! 0! #or   