'*' digits The formal BNF is more complicated because leading 0s are not allowed. We check for that and add a defect. We also assume no CFWS is allowed between the '*' and the digits, though the RFC is not crystal clear on that. The caller should already have dealt with leading C
(value)
| 2433 | return attribute, value |
| 2434 | |
| 2435 | def get_section(value): |
| 2436 | """ '*' digits |
| 2437 | |
| 2438 | The formal BNF is more complicated because leading 0s are not allowed. We |
| 2439 | check for that and add a defect. We also assume no CFWS is allowed between |
| 2440 | the '*' and the digits, though the RFC is not crystal clear on that. |
| 2441 | The caller should already have dealt with leading CFWS. |
| 2442 | |
| 2443 | """ |
| 2444 | section = Section() |
| 2445 | if not value or value[0] != '*': |
| 2446 | raise errors.HeaderParseError("Expected section but found {}".format( |
| 2447 | value)) |
| 2448 | section.append(ValueTerminal('*', 'section-marker')) |
| 2449 | value = value[1:] |
| 2450 | if not value or not value[0].isdigit(): |
| 2451 | raise errors.HeaderParseError("Expected section number but " |
| 2452 | "found {}".format(value)) |
| 2453 | digits = '' |
| 2454 | while value and value[0].isdigit(): |
| 2455 | digits += value[0] |
| 2456 | value = value[1:] |
| 2457 | if digits[0] == '0' and digits != '0': |
| 2458 | section.defects.append(errors.InvalidHeaderDefect( |
| 2459 | "section number has an invalid leading 0")) |
| 2460 | section.number = int(digits) |
| 2461 | section.append(ValueTerminal(digits, 'digits')) |
| 2462 | return section, value |
| 2463 | |
| 2464 | |
| 2465 | def get_value(value): |
no test coverage detected
searching dependent graphs…