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

Function get_phrase

Lib/email/_header_value_parser.py:1426–1462  ·  view source on GitHub ↗

phrase = 1*word / obs-phrase obs-phrase = word *(word / "." / CFWS) This means a phrase can be a sequence of words, periods, and CFWS in any order as long as it starts with at least one word. If anything other than words is detected, an ObsoleteHeaderDefect is added to the tok

(value)

Source from the content-addressed store, hash-verified

1424 return token, value
1425
1426def get_phrase(value):
1427 """ phrase = 1*word / obs-phrase
1428 obs-phrase = word *(word / "." / CFWS)
1429
1430 This means a phrase can be a sequence of words, periods, and CFWS in any
1431 order as long as it starts with at least one word. If anything other than
1432 words is detected, an ObsoleteHeaderDefect is added to the token's defect
1433 list. We also accept a phrase that starts with CFWS followed by a dot;
1434 this is registered as an InvalidHeaderDefect, since it is not supported by
1435 even the obsolete grammar.
1436
1437 """
1438 phrase = Phrase()
1439 try:
1440 token, value = get_word(value)
1441 phrase.append(token)
1442 except errors.HeaderParseError:
1443 phrase.defects.append(errors.InvalidHeaderDefect(
1444 "phrase does not start with word"))
1445 while value and value[0] not in PHRASE_ENDS:
1446 if value[0]=='.':
1447 phrase.append(DOT)
1448 phrase.defects.append(errors.ObsoleteHeaderDefect(
1449 "period in 'phrase'"))
1450 value = value[1:]
1451 else:
1452 try:
1453 token, value = get_word(value)
1454 except errors.HeaderParseError:
1455 if value[0] in CFWS_LEADER:
1456 token, value = get_cfws(value)
1457 phrase.defects.append(errors.ObsoleteHeaderDefect(
1458 "comment found without atom"))
1459 else:
1460 raise
1461 phrase.append(token)
1462 return phrase, value
1463
1464def get_local_part(value):
1465 """ local-part = dot-atom / quoted-string / obs-local-part

Callers 5

get_display_nameFunction · 0.85
get_invalid_mailboxFunction · 0.85
get_invalid_parameterFunction · 0.85
_find_mime_parametersFunction · 0.85

Calls 4

PhraseClass · 0.85
get_wordFunction · 0.85
get_cfwsFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected