Helper function used by read_tuple_value and read_set_value.
(
self, s, position, reentrances, match, close_paren, seq_class, plus_class
)
| 2528 | ) |
| 2529 | |
| 2530 | def _read_seq_value( |
| 2531 | self, s, position, reentrances, match, close_paren, seq_class, plus_class |
| 2532 | ): |
| 2533 | """ |
| 2534 | Helper function used by read_tuple_value and read_set_value. |
| 2535 | """ |
| 2536 | cp = re.escape(close_paren) |
| 2537 | position = match.end() |
| 2538 | # Special syntax of empty tuples: |
| 2539 | m = re.compile(r"\s*/?\s*%s" % cp).match(s, position) |
| 2540 | if m: |
| 2541 | return seq_class(), m.end() |
| 2542 | # Read values: |
| 2543 | values = [] |
| 2544 | seen_plus = False |
| 2545 | while True: |
| 2546 | # Close paren: return value. |
| 2547 | m = re.compile(r"\s*%s" % cp).match(s, position) |
| 2548 | if m: |
| 2549 | if seen_plus: |
| 2550 | return plus_class(values), m.end() |
| 2551 | else: |
| 2552 | return seq_class(values), m.end() |
| 2553 | |
| 2554 | # Read the next value. |
| 2555 | val, position = self.read_value(s, position, reentrances) |
| 2556 | values.append(val) |
| 2557 | |
| 2558 | # Comma or looking at close paren |
| 2559 | m = re.compile(r"\s*(,|\+|(?=%s))\s*" % cp).match(s, position) |
| 2560 | if not m: |
| 2561 | raise ValueError("',' or '+' or '%s'" % cp, position) |
| 2562 | if m.group(1) == "+": |
| 2563 | seen_plus = True |
| 2564 | position = m.end() |
| 2565 | |
| 2566 | |
| 2567 | ###################################################################### |
no test coverage detected