
    7 f                        U d Z ddlmZ ddlZddlZddlmZmZ ddl	m
Z
mZ erddlmZmZ d"d
Zd#dZ G d d          Z edg          Zi Zded<   d$dZd%dZ	 	 d&d'd!ZdS )(z.Pattern-matching utility functions for Sphinx.    )annotationsN)TYPE_CHECKINGCallable)
canon_pathpath_stabilize)IterableIteratorpatstrreturnc                   dt          |           }}d}||k     r"| |         }|dz  }|dk    r#||k     r| |         dk    r|dz  }|dz   }n|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   S )zTranslate a shell-style glob pattern to a regular expression.

    Adapted from the fnmatch module, but enhanced so that single stars don't
    match slashes.
    r       *z.*z[^/]*?z[^/][!]z\[\z\\z^/N^$)lenreplacereescape)r
   inrescjstuffs          J/var/www/equiseq/venv/lib/python3.11/site-packages/sphinx/util/matching.py_translate_patternr#      s    c#hhqA
C
a%%F	Q881uuQ3QDj Gm#XX,CC#XXA1uuQ3Q1uuQ3Qa%%CFcMMQ a%%CFcMMAvvEkAaC((v66E8s?? 59,EE1X__ 5LE''u'''29Q<<CE a%%F 9    patternsIterable[str]+list[Callable[[str], re.Match[str] | None]]c                    d | D             S )Nc                Z    g | ](}t          j        t          |                    j        )S  )r   compiler#   match.0r
   s     r"   
<listcomp>z$compile_matchers.<locals>.<listcomp>@   s.    JJJ#BJ)#..//5JJJr$   r*   )r%   s    r"   compile_matchersr0   =   s     KJJJJJr$   c                  *    e Zd ZdZddZdd
ZddZdS )MatcherzA pattern matcher for Multiple shell-style glob patterns.

    Note: this modifies the patterns to work with copy_asset().
          For example, "**/index.rst" matches with "index.rst"
    exclude_patternsr&   r   Nonec                f    d |D             }t          t          |          |z             | _        d S )Nc                L    g | ]!}|                     d           |dd         "S )z**/   N)
startswithr-   s     r"   r/   z$Matcher.__init__.<locals>.<listcomp>K   s1    QQQ3>>%;P;PQCGQQQr$   )r0   listr%   )selfr3   expandeds      r"   __init__zMatcher.__init__J   s7    QQ'7QQQ(.>)?)?()JKKr$   stringr   boolc                ,    |                      |          S N)r,   r:   r=   s     r"   __call__zMatcher.__call__N   s    zz&!!!r$   c                b    t                    t          fd| j        D                       S )Nc              3  .   K   | ]} |          V  d S r@   r*   )r.   r
   r=   s     r"   	<genexpr>z Matcher.match.<locals>.<genexpr>S   s+      88333v;;888888r$   )r   anyr%   rA   s    `r"   r,   zMatcher.matchQ   s5    F##8888$-888888r$   N)r3   r&   r   r4   )r=   r   r   r>   )__name__
__module____qualname____doc__r<   rB   r,   r*   r$   r"   r2   r2   C   s^         L L L L" " " "9 9 9 9 9 9r$   r2   z**/.*zdict[str, re.Pattern[str]]
_pat_cachenamere.Match[str] | Nonec                    |t           vr)t          j        t          |                    t           |<   t           |                             |           S )zbReturn if name matches the regular expression (pattern)
    ``pat```. Adapted from fnmatch module.)rK   r   r+   r#   r,   )rL   r
   s     r"   patmatchrO   \   sC     **%7%<%<==
3c?  &&&r$   names	list[str]c                    |t           vr)t          j        t          |                    t           |<   t           |         j        }t          t          ||                     S )zReturn the subset of the list ``names`` that match
    the regular expression (pattern) ``pat``.

    Adapted from fnmatch module.
    )rK   r   r+   r#   r,   r9   filter)rP   r
   r,   s      r"   	patfilterrT   d   sO     **%7%<%<==
3sO!Eue$$%%%r$   z**r*   dirnamestr | os.PathLike[str]include_patternsr3   Iterator[str]c              #  >  K   t           j                            t           j                            |                     } t	          |          }t	          |          }t          j        | d          D ](\  }}}t           j                            ||           }|dk    rd}g }	t          |          D ]p}
t          t           j        	                    ||
                    }
d}|D ]} ||
          rd} n|D ]} ||
          rd} n|r|	
                    |
           qg }t          |          D ]V}t          t           j        	                    ||                    }|D ]} ||          r n|
                    |           W||dd<   |	E d{V  *dS )ac  Get all file names in a directory, recursively.

    Filter file names by the glob-style include_patterns and exclude_patterns.
    The default values include all files ("**") and exclude nothing ("").

    Only files matching some pattern in *include_patterns* are included, and
    exclusions from *exclude_patterns* take priority over inclusions.

    T)followlinks.r   FN)ospathnormpathabspathr0   walkrelpathsortedr   joinappend)rV   rX   r3   exclude_matchersinclude_matchersrootdirsfilesrelative_rootincluded_filesentrykeepmatcherfiltered_dirsdir_name
normaliseds                   r"   get_matching_filesrs   p   s      grww7788G'(899'(899WW$??? %" %"dEg66CM E]] 	- 	-E"27<<u#E#EFFED+  75>> DE ,  75>>  DE  -%%e,,, t 	/ 	/H']H(M(MNNJ+ / /7:&& E $$X...QQQ "!!!!!!!!K%" %"r$   )r
   r   r   r   )r%   r&   r   r'   )rL   r   r
   r   r   rM   )rP   r&   r
   r   r   rQ   )rU   r*   )rV   rW   rX   r&   r3   r&   r   rY   )rJ   
__future__r   os.pathr]   r   typingr   r   sphinx.util.osutilr   r   collections.abcr   r	   r#   r0   r2   DOTFILESrK   __annotations__rO   rT   rs   r*   r$   r"   <module>r{      sP   4 4 4 " " " " " "  				 * * * * * * * * 9 9 9 9 9 9 9 9 322222222+ + + +\K K K K9 9 9 9 9 9 9 9& 7G9 *,
 + + + +' ' ' '	& 	& 	& 	& '.&(9" 9" 9" 9" 9" 9" 9"r$   