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

Function get_token

Lib/email/_header_value_parser.py:2330–2351  ·  view source on GitHub ↗

token = [CFWS] 1*ttext [CFWS] The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or tspecials. We also exclude tabs even though the RFC doesn't. The RFC implies the CFWS but is not explicit about it in the BNF.

(value)

Source from the content-addressed store, hash-verified

2328 return ttext, value
2329
2330def get_token(value):
2331 """token = [CFWS] 1*ttext [CFWS]
2332
2333 The RFC equivalent of ttext is any US-ASCII chars except space, ctls, or
2334 tspecials. We also exclude tabs even though the RFC doesn't.
2335
2336 The RFC implies the CFWS but is not explicit about it in the BNF.
2337
2338 """
2339 mtoken = Token()
2340 if value and value[0] in CFWS_LEADER:
2341 token, value = get_cfws(value)
2342 mtoken.append(token)
2343 if value and value[0] in TOKEN_ENDS:
2344 raise errors.HeaderParseError(
2345 "expected token but found '{}'".format(value))
2346 token, value = get_ttext(value)
2347 mtoken.append(token)
2348 if value and value[0] in CFWS_LEADER:
2349 token, value = get_cfws(value)
2350 mtoken.append(token)
2351 return mtoken, value
2352
2353def get_attrtext(value):
2354 """attrtext = 1*(any non-ATTRIBUTE_ENDS character)

Calls 5

get_cfwsFunction · 0.85
get_ttextFunction · 0.85
TokenClass · 0.70
appendMethod · 0.45
formatMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…