MCPcopy Index your code
hub / github.com/python/cpython / restrict_rglob

Method restrict_rglob

Lib/zipfile/_path/glob.py:77–89  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 1

translate_coreMethod · 0.95

Calls 3

escapeMethod · 0.80
anyFunction · 0.50
splitMethod · 0.45

Tested by

no test coverage detected