r""" Given a glob pattern, produce a regex that matches it. >>> t = Translator() >>> t.translate_core('*.txt').replace('\\\\', '') '[^/]*\\.txt' >>> t.translate_core('a?txt') 'a[^/]txt' >>> t.translate_core('**/*').replace('\\\\', '')
(self, pattern)
| 49 | return rf'{pattern}[/]?' |
| 50 | |
| 51 | def translate_core(self, pattern): |
| 52 | r""" |
| 53 | Given a glob pattern, produce a regex that matches it. |
| 54 | |
| 55 | >>> t = Translator() |
| 56 | >>> t.translate_core('*.txt').replace('\\\\', '') |
| 57 | '[^/]*\\.txt' |
| 58 | >>> t.translate_core('a?txt') |
| 59 | 'a[^/]txt' |
| 60 | >>> t.translate_core('**/*').replace('\\\\', '') |
| 61 | '.*/[^/][^/]*' |
| 62 | """ |
| 63 | self.restrict_rglob(pattern) |
| 64 | return ''.join(map(self.replace, separate(self.star_not_empty(pattern)))) |
| 65 | |
| 66 | def replace(self, match): |
| 67 | """ |
no test coverage detected