
    -Ph                        U d Z ddlmZ ddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ e
r
ddlmZ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+d$ZdS ),z.Pattern-matching utility functions for Sphinx.    )annotationsN)Path)TYPE_CHECKING)
canon_path)Callable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          T/var/www/html/test/jupyter/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>B   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>M   s1    QQQ3>>%;P;PQCGQQQr$   )r0   listr%   )selfr3   expandeds      r"   __init__zMatcher.__init__L   s7    QQ'7QQQ(.>)?)?()JKKr$   stringr   boolc                ,    |                      |          S N)r,   r:   r=   s     r"   __call__zMatcher.__call__P   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>U   s+      88333v;;888888r$   )r   anyr%   rA   s    `r"   r,   zMatcher.matchS   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   E   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 )zgReturn 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   g   sO     **%7%<%<==
3sO!Eue$$%%%r$   z**r*   dirnamestr | os.PathLike[str]include_patternsr3   Iterator[str]c              #    K   t          |                                           } t          |          }t          |          }t          j        | d          D ]%\  }}}t          j                            ||           }|dk    rd}t          |          }	g }
t          |          D ]g}t          |	|z  	                                          }d}|D ]} ||          rd} n|D ]} ||          rd} n|r|

                    |           hg }t          |          D ]M}t          |	|z  	                                          }|D ]} ||          r n|
                    |           N||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)r   resolver0   oswalkpathrelpathsorted_unicode_nfcas_posixappend)rV   rX   r3   exclude_matchersinclude_matchersrootdirsfilesrelative_rootrelative_root_pathincluded_filesentrykeepmatcherfiltered_dirsdir_name
normaliseds                    r"   get_matching_filesrt   s   s      7mm##%%G'(899'(899WW$??? &" &"dEg66CM!-00 E]] 	- 	-E "4u"<!F!F!H!HIIED+  75>> DE ,  75>>  DE  -%%e,,, t 	/ 	/H%'9H'D&N&N&P&PQQJ+ / /7:&& E $$X...QQQ "!!!!!!!!M&" &"r$   sc               ,    t          j        d|           S )z!Normalise the string to NFC form.NFC)unicodedata	normalize)ru   s    r"   rc   rc      s     ***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   )ru   r   r   r   )rJ   
__future__r   os.pathr^   r   rx   pathlibr   typingr   sphinx.util.osutilr   collections.abcr   r   r	   r#   r0   r2   DOTFILESrK   __annotations__rO   rT   rt   rc   r*   r$   r"   <module>r      s}   4 4 4 " " " " " "  				                       ) ) ) ) ) ) =<<<<<<<<<<+ + + +\K K K K9 9 9 9 9 9 9 9& 7G9 *,
 + + + +' ' ' '	& 	& 	& 	& '.&(:" :" :" :" :"z+ + + + + +r$   