3

T'íc9ã@sØUdZddlZddlmZmZmZmZmZmZm	Z	ddl
mZeedœdd„Z
eeeeegeeefdœd	d
„ZGdd„dƒZed
gƒZiZeee	feeeeedœdd„Zeeeeedœdd„ZdS)z.Pattern-matching utility functions for Sphinx.éN)ÚCallableÚDictÚIterableÚListÚMatchÚOptionalÚPattern)Ú
canon_path)ÚpatÚreturncCsndt|ƒ}}d}xP||krd||}|d7}|dkrh||kr^||dkr^|d7}|d}n|d}q|dkrz|d}q|d	krT|}||kr¤||d
kr¤|d7}||krÀ||dkrÀ|d7}x ||krà||dkrà|d7}qÂW||krô|d}n^|||…jd
dƒ}|d}|dd
kr0d|dd…}n|ddkrFd
|}d||f}q|tj|ƒ7}qW|dS)z£Translate 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ú^z%s[%s]ú$)ÚlenÚreplaceÚreÚescape)r
ÚiÚnÚresÚcÚjÚstuff©r ú6/tmp/pip-build-gk9425m9/sphinx/sphinx/util/matching.pyÚ_translate_pattern	s>




r")ÚpatternsrcCsdd„|DƒS)NcSsg|]}tjt|ƒƒj‘qSr )rÚcompiler"Úmatch)Ú.0r
r r r!ú
<listcomp>8sz$compile_matchers.<locals>.<listcomp>r )r#r r r!Úcompile_matchers7sr(c@sDeZdZdZeeddœdd„Zeedœdd„Zeedœd	d
„Z	dS)ÚMatcherz¾A 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"
    N)r#rcCs dd„|Dƒ}t||ƒ|_dS)NcSs"g|]}|jdƒr|dd…‘qS)z**/éN)Ú
startswith)r&r
r r r!r'Csz$Matcher.__init__.<locals>.<listcomp>)r(r#)Úselfr#Úexpandedr r r!Ú__init__BszMatcher.__init__)ÚstringrcCs
|j|ƒS)N)r%)r,r/r r r!Ú__call__FszMatcher.__call__cs tˆƒ‰t‡fdd„|jDƒƒS)Nc3s|]}|ˆƒVqdS)Nr )r&r
)r/r r!ú	<genexpr>Ksz Matcher.match.<locals>.<genexpr>)r	Úanyr#)r,r/r )r/r!r%Isz
Matcher.match)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__rÚstrr.Úboolr0r%r r r r!r);sr)z**/.*)Únamer
rcCs(|tkrtjt|ƒƒt|<t|j|ƒS)zbReturn if name matches the regular expression (pattern)
    ``pat```. Adapted from fnmatch module.)Ú
_pat_cacherr$r"r%)r9r
r r r!ÚpatmatchTsr;)Únamesr
rcCs2|tkrtjt|ƒƒt|<t|j}tt||ƒƒS)z‡Return the subset of the list ``names`` that match
    the regular expression (pattern) ``pat``.

    Adapted from fnmatch module.
    )r:rr$r"r%ÚlistÚfilter)r<r
r%r r r!Ú	patfilter\s
r?)r6rÚtypingrrrrrrrZsphinx.util.osutilr	r7r"r(r)ZDOTFILESr:r;r?r r r r!Ú<module>s$.*