Raise ValueError if ** appears in anything but a full path segment. >>> Translator().translate('**foo') Traceback (most recent call last): ... ValueError: ** must appear alone in a path segment
(self, pattern)
| 75 | ) |
| 76 | |
| 77 | def restrict_rglob(self, pattern): |
| 78 | """ |
| 79 | Raise ValueError if ** appears in anything but a full path segment. |
| 80 | |
| 81 | >>> Translator().translate('**foo') |
| 82 | Traceback (most recent call last): |
| 83 | ... |
| 84 | ValueError: ** must appear alone in a path segment |
| 85 | """ |
| 86 | seps_pattern = rf'[{re.escape(self.seps)}]+' |
| 87 | segments = re.split(seps_pattern, pattern) |
| 88 | if any('**' in segment and segment != '**' for segment in segments): |
| 89 | raise ValueError("** must appear alone in a path segment") |
| 90 | |
| 91 | def star_not_empty(self, pattern): |
| 92 | """ |
no test coverage detected