MCPcopy
hub / github.com/docopt/docopt / OneOrMore

Class OneOrMore

docopt.py:253–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251
252
253class OneOrMore(ParentPattern):
254
255 def match(self, left, collected=None):
256 assert len(self.children) == 1
257 collected = [] if collected is None else collected
258 l = left
259 c = collected
260 l_ = None
261 matched = True
262 times = 0
263 while matched:
264 # could it be that something didn't match but changed l or c?
265 matched, l, c = self.children[0].match(l, c)
266 times += 1 if matched else 0
267 if l_ == l:
268 break
269 l_ = l
270 if times >= 1:
271 return True, l, c
272 return False, left, collected
273
274
275class Either(ParentPattern):

Callers 7

test_pattern_flatFunction · 0.90
test_parse_patternFunction · 0.90
test_one_or_more_matchFunction · 0.90
test_list_argument_matchFunction · 0.90
test_pattern_eitherFunction · 0.90
parse_seqFunction · 0.85

Calls

no outgoing calls

Tested by 6

test_pattern_flatFunction · 0.72
test_parse_patternFunction · 0.72
test_one_or_more_matchFunction · 0.72
test_list_argument_matchFunction · 0.72
test_pattern_eitherFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…