
    C`o                         d Z ddlZddlZ	 ddlmZ n# e$ r	 ddlmZ Y nw xY wg dZd ZddZ	 ed	d
          d             Z
ddZddZ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)	lru_cache   )filterfnmatchfnmatchcase	translatec                     |#t          j        d|pt          j        |           } n!|rt          j                            |           } | S )Nz\/)resubosseppathnormcase)r   
norm_pathsr   s      -lib/python3.11/site-packages/glob2/fnmatch.py_norm_pathsr      sE    veS]BFD11	 &w%%K    Tc                 R    fd| |fD             \  } }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).

    :param slashes:
    :param norm_paths:
        A tri-state boolean:
        when true, invokes `os.path,.normcase()` on both paths,
        when `None`, just equalize slashes/backslashes to `os.sep`,
        when false, does not touch paths at all.

        Note that a side-effect of `normcase()` on *Windows* is that
        it converts to lower-case all matches of `?glob()` functions.
    :param case_sensitive:
        defines the case-sensitiviness of regex doing the matches
    :param sep:
        in case only slahes replaced, what sep-char to substitute with;
        if false, `os.sep` is used.

    Notice that by default, `normcase()` causes insensitive matching
    on *Windows*, regardless of `case_insensitive` param.
    Set ``norm_paths=None, case_sensitive=False`` to preserve
    verbatim mathces.
    c                 2    g | ]}t          |          S  r   .0pr   r   s     r   
<listcomp>zfnmatch.<locals>.<listcomp>A   s5     ' ' ' Q
C00 ' ' 'r   )case_sensitive)r   )namepatr   r   r   s     ` `r   r   r      sQ    F' ' ' ' '+' ' 'ID# tS@@@@r      )maxsizetypedc                    t          | t                    r:|                     d          }t          |          }|                    d          }nt          |           }|rdnt
          j        }t          j        ||          j        S )Nz
ISO-8859-1r   )	
isinstancebytesdecoder   encoder
   
IGNORECASEcompilematch)r   r   pat_strres_strresflagss         r   _compile_patternr.   G   su    #u **\**G$$nn\**nn2AAR]E:c5!!''r   c           	         g }t          |          }t          ||          }| D ]a} |t          |                    }|rC|                    |t          fd|                                D                       f           b|S )z3Return the subset of the list NAMES that match PAT.c              3   :   K   | ]}t          |          V  d S )Nr   r   s     r   	<genexpr>zfilter.<locals>.<genexpr>\   s/       U UQQ
C!@!@ U U U U U Ur   )r   r.   appendtuplegroups)	namesr   r   r   r   resultr)   r   ms	     ` `    r   r   r   S   s    F
c:s
+
+CS.11E X XE+dJ4455 	XMM4  U U U U U!((** U U UUUW X X X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   r)   s       r   r   r   `   s&     S.11E5;;d""r   c                 P   dt          |           }}d}||k     r| |         }|dz   }|dk    r|dz   }n|dk    r|dz   }n|dk    r|}||k     r| |         d	k    r|dz   }||k     r| |         d
k    r|dz   }||k     r#| |         d
k    r|dz   }||k     r| |         d
k    ||k    r|dz   }nn| ||                             dd          }|dz   }|d         d	k    rd|dd         z   }n|d         dk    rd|z   }|d|d}n|t          j        |          z   }||k     d|z   dz   S )zfTranslate a shell PATTERN to a regular expression.

    There is no way to quote meta-characters.
    r    r   *z(.*)?z(.)[!]z\[\z\\^Nz([z])z(?ms)z\Z)lenreplacer
   escape)r   inr,   cjstuffs          r   r   r   j   s    c#hhqA
C
a%%FaC88,CC#XX+CC#XXA1uuQ3aC1uuQ3aCa%%CFcMMaC a%%CFcMMAvvEkAaC((f55aC8s??%)OEE1X__ 5LE$'CC/	!$C5 a%%6 S=4r   )TTN)T)__doc__r   r
   	functoolsr   ImportErrorcompat__all__r   r   r.   r   r   r   r   r   r   <module>rO      s  
 
 
			 				"####### " " "!!!!!!!!" <
;
;  &A &A &A &AR 3d###( ( $#(
 
 
 
# # # ##  #  #  #  # s    !!