3
T'íc9 ã @ sØ U d Z ddlZddlmZmZmZmZmZmZm Z ddl
mZ eedddZ
ee eeegeee f dd d
ZG dd dZed
gZi Zeee f eeeee dddZee eee dddZdS )z.Pattern-matching utility functions for Sphinx.é N)ÚCallableÚDictÚIterableÚListÚMatchÚOptionalÚPattern)Ú
canon_path)ÚpatÚreturnc C sn dt | }}d}xP||k rd| | }|d7 }|dkrh||k r^| | dkr^|d7 }|d }n|d }q|dkrz|d }q|d krT|}||k r¤| | d
kr¤|d7 }||k rÀ| | dkrÀ|d7 }x ||k rà| | dkrà|d7 }qÂW ||krô|d }n^| ||
jd
d}|d }|d d
kr0d|dd
}n|d dkrFd
| }d||f }q|tj|7 }qW |d S )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