Translate and compile a glob pattern to a regular expression matcher.
(pat, ignore_case=True)
| 619 | |
| 620 | |
| 621 | def _compile_pattern(pat, ignore_case=True): |
| 622 | """Translate and compile a glob pattern to a regular expression matcher.""" |
| 623 | if isinstance(pat, bytes): |
| 624 | pat_str = pat.decode('ISO-8859-1') |
| 625 | res_str = _translate_glob(pat_str) |
| 626 | res = res_str.encode('ISO-8859-1') |
| 627 | else: |
| 628 | res = _translate_glob(pat) |
| 629 | flags = re.IGNORECASE if ignore_case else 0 |
| 630 | return re.compile(res, flags=flags).match |
| 631 | |
| 632 | |
| 633 | def _iexplode_path(path): |
no test coverage detected