MCPcopy Index your code
hub / github.com/python/cpython / get_phrase

Function get_phrase

Lib/email/_header_value_parser.py:1443–1479  ·  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

1441 return token, value
1442
1443def get_phrase(value):
1444 """ phrase = 1*word / obs-phrase
1445 obs-phrase = word *(word / "." / CFWS)
1446
1447 This means a phrase can be a sequence of words, periods, and CFWS in any
1448 order as long as it starts with at least one word. If anything other than
1449 words is detected, an ObsoleteHeaderDefect is added to the token's defect
1450 list. We also accept a phrase that starts with CFWS followed by a dot;
1451 this is registered as an InvalidHeaderDefect, since it is not supported by
1452 even the obsolete grammar.
1453
1454 """
1455 phrase = Phrase()
1456 try:
1457 token, value = get_word(value)
1458 phrase.append(token)
1459 except errors.HeaderParseError:
1460 phrase.defects.append(errors.InvalidHeaderDefect(
1461 "phrase does not start with word"))
1462 while value and value[0] not in PHRASE_ENDS:
1463 if value[0]=='.':
1464 phrase.append(DOT)
1465 phrase.defects.append(errors.ObsoleteHeaderDefect(
1466 "period in 'phrase'"))
1467 value = value[1:]
1468 else:
1469 try:
1470 token, value = get_word(value)
1471 except errors.HeaderParseError:
1472 if value[0] in CFWS_LEADER:
1473 token, value = get_cfws(value)
1474 phrase.defects.append(errors.ObsoleteHeaderDefect(
1475 "comment found without atom"))
1476 else:
1477 raise
1478 phrase.append(token)
1479 return phrase, value
1480
1481def get_local_part(value):
1482 """ 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

Used in the wild real call sites across dependent graphs

searching dependent graphs…