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

Function get_word

Lib/email/_header_value_parser.py:1392–1424  ·  view source on GitHub ↗

word = atom / quoted-string Either atom or quoted-string may start with CFWS. We have to peel off this CFWS first to determine which type of word to parse. Afterward we splice the leading CFWS, if any, into the parsed sub-token. If neither an atom or a quoted-string is found befo

(value)

Source from the content-addressed store, hash-verified

1390 return dot_atom, value
1391
1392def get_word(value):
1393 """word = atom / quoted-string
1394
1395 Either atom or quoted-string may start with CFWS. We have to peel off this
1396 CFWS first to determine which type of word to parse. Afterward we splice
1397 the leading CFWS, if any, into the parsed sub-token.
1398
1399 If neither an atom or a quoted-string is found before the next special, a
1400 HeaderParseError is raised.
1401
1402 The token returned is either an Atom or a QuotedString, as appropriate.
1403 This means the 'word' level of the formal grammar is not represented in the
1404 parse tree; this is because having that extra layer when manipulating the
1405 parse tree is more confusing than it is helpful.
1406
1407 """
1408 if value[0] in CFWS_LEADER:
1409 leader, value = get_cfws(value)
1410 else:
1411 leader = None
1412 if not value:
1413 raise errors.HeaderParseError(
1414 "Expected 'atom' or 'quoted-string' but found nothing.")
1415 if value[0]=='"':
1416 token, value = get_quoted_string(value)
1417 elif value[0] in SPECIALS:
1418 raise errors.HeaderParseError("Expected 'atom' or 'quoted-string' "
1419 "but found '{}'".format(value))
1420 else:
1421 token, value = get_atom(value)
1422 if leader is not None:
1423 token[:0] = [leader]
1424 return token, value
1425
1426def get_phrase(value):
1427 """ phrase = 1*word / obs-phrase

Callers 3

get_phraseFunction · 0.85
get_local_partFunction · 0.85
get_obs_local_partFunction · 0.85

Calls 4

get_cfwsFunction · 0.85
get_quoted_stringFunction · 0.85
get_atomFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected