]>
crepu.dev Git - config.git/blob - djavu-asus/emacs/elpy/rpc-venv/lib/python3.11/site-packages/zipp/glob.py
4 def translate(pattern
):
6 Given a glob pattern, produce a regex that matches it.
10 >>> translate('a?txt')
15 return ''.join(map(replace
, separate(pattern
)))
18 def separate(pattern
):
20 Separate out character sets to avoid translating their contents.
22 >>> [m.group(0) for m in separate('*.txt')]
24 >>> [m.group(0) for m in separate('a[?]txt')]
27 return re
.finditer(r
'([^\[]+)|(?P<set>[\[].*?[\]])|([\[][^\]]*$)', pattern
)
32 Perform the replacements for a match from :func:`separate`.
35 return match
.group('set') or (
36 re
.escape(match
.group(0))
37 .replace('\\*\\*', r
'.*')
38 .replace('\\*', r
'[^/]*')
39 .replace('\\?', r
'[^/]')