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

Method _interpolate_some

Lib/configparser.py:441–480  ·  view source on GitHub ↗
(self, parser, option, accum, rest, section, map,
                          depth)

Source from the content-addressed store, hash-verified

439 return value
440
441 def _interpolate_some(self, parser, option, accum, rest, section, map,
442 depth):
443 rawval = parser.get(section, option, raw=True, fallback=rest)
444 if depth > MAX_INTERPOLATION_DEPTH:
445 raise InterpolationDepthError(option, section, rawval)
446 while rest:
447 p = rest.find("%")
448 if p < 0:
449 accum.append(rest)
450 return
451 if p > 0:
452 accum.append(rest[:p])
453 rest = rest[p:]
454 # p is no longer used
455 c = rest[1:2]
456 if c == "%":
457 accum.append("%")
458 rest = rest[2:]
459 elif c == "(":
460 m = self._KEYCRE.match(rest)
461 if m is None:
462 raise InterpolationSyntaxError(option, section,
463 "bad interpolation variable reference %r" % rest)
464 var = parser.optionxform(m.group(1))
465 rest = rest[m.end():]
466 try:
467 v = map[var]
468 except KeyError:
469 raise InterpolationMissingOptionError(
470 option, section, rawval, var) from None
471 if "%" in v:
472 self._interpolate_some(parser, option, accum, v,
473 section, map, depth + 1)
474 else:
475 accum.append(v)
476 else:
477 raise InterpolationSyntaxError(
478 option, section,
479 "'%%' must be followed by '%%' or '(', "
480 "found: %r" % (rest,))
481
482
483class ExtendedInterpolation(Interpolation):

Callers 1

before_getMethod · 0.95

Calls 10

optionxformMethod · 0.80
getMethod · 0.45
findMethod · 0.45
appendMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected