(self, parser, option, accum, rest, section, map,
depth)
| 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 | |
| 483 | class ExtendedInterpolation(Interpolation): |
no test coverage detected