MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_section

Function get_section

Lib/email/_header_value_parser.py:2392–2419  ·  view source on GitHub ↗

'*' 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)

Source from the content-addressed store, hash-verified

2390 return attribute, value
2391
2392def get_section(value):
2393 """ '*' digits
2394
2395 The formal BNF is more complicated because leading 0s are not allowed. We
2396 check for that and add a defect. We also assume no CFWS is allowed between
2397 the '*' and the digits, though the RFC is not crystal clear on that.
2398 The caller should already have dealt with leading CFWS.
2399
2400 """
2401 section = Section()
2402 if not value or value[0] != '*':
2403 raise errors.HeaderParseError("Expected section but found {}".format(
2404 value))
2405 section.append(ValueTerminal('*', 'section-marker'))
2406 value = value[1:]
2407 if not value or not value[0].isdigit():
2408 raise errors.HeaderParseError("Expected section number but "
2409 "found {}".format(value))
2410 digits = ''
2411 while value and value[0].isdigit():
2412 digits += value[0]
2413 value = value[1:]
2414 if digits[0] == '0' and digits != '0':
2415 section.defects.append(errors.InvalidHeaderDefect(
2416 "section number has an invalid leading 0"))
2417 section.number = int(digits)
2418 section.append(ValueTerminal(digits, 'digits'))
2419 return section, value
2420
2421
2422def get_value(value):

Callers 1

get_parameterFunction · 0.85

Calls 5

SectionClass · 0.85
ValueTerminalClass · 0.85
formatMethod · 0.45
appendMethod · 0.45
isdigitMethod · 0.45

Tested by

no test coverage detected