(self, parser, option, accum, rest, section, map,
depth)
| 500 | return value |
| 501 | |
| 502 | def _interpolate_some(self, parser, option, accum, rest, section, map, |
| 503 | depth): |
| 504 | rawval = parser.get(section, option, raw=True, fallback=rest) |
| 505 | if depth > MAX_INTERPOLATION_DEPTH: |
| 506 | raise InterpolationDepthError(option, section, rawval) |
| 507 | while rest: |
| 508 | p = rest.find("$") |
| 509 | if p < 0: |
| 510 | accum.append(rest) |
| 511 | return |
| 512 | if p > 0: |
| 513 | accum.append(rest[:p]) |
| 514 | rest = rest[p:] |
| 515 | # p is no longer used |
| 516 | c = rest[1:2] |
| 517 | if c == "$": |
| 518 | accum.append("$") |
| 519 | rest = rest[2:] |
| 520 | elif c == "{": |
| 521 | m = self._KEYCRE.match(rest) |
| 522 | if m is None: |
| 523 | raise InterpolationSyntaxError(option, section, |
| 524 | "bad interpolation variable reference %r" % rest) |
| 525 | path = m.group(1).split(':') |
| 526 | rest = rest[m.end():] |
| 527 | sect = section |
| 528 | opt = option |
| 529 | try: |
| 530 | if len(path) == 1: |
| 531 | opt = parser.optionxform(path[0]) |
| 532 | v = map[opt] |
| 533 | elif len(path) == 2: |
| 534 | sect = path[0] |
| 535 | opt = parser.optionxform(path[1]) |
| 536 | v = parser.get(sect, opt, raw=True) |
| 537 | else: |
| 538 | raise InterpolationSyntaxError( |
| 539 | option, section, |
| 540 | "More than one ':' found: %r" % (rest,)) |
| 541 | except (KeyError, NoSectionError, NoOptionError): |
| 542 | raise InterpolationMissingOptionError( |
| 543 | option, section, rawval, ":".join(path)) from None |
| 544 | if v is None: |
| 545 | continue |
| 546 | if "$" in v: |
| 547 | self._interpolate_some(parser, opt, accum, v, sect, |
| 548 | dict(parser.items(sect, raw=True)), |
| 549 | depth + 1) |
| 550 | else: |
| 551 | accum.append(v) |
| 552 | else: |
| 553 | raise InterpolationSyntaxError( |
| 554 | option, section, |
| 555 | "'$' must be followed by '$' or '{', " |
| 556 | "found: %r" % (rest,)) |
| 557 | |
| 558 | |
| 559 | class _ReadState: |
no test coverage detected