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)
| 1441 | return token, value |
| 1442 | |
| 1443 | def 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 | |
| 1481 | def get_local_part(value): |
| 1482 | """ local-part = dot-atom / quoted-string / obs-local-part |
no test coverage detected
searching dependent graphs…