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

Class EmailPolicy

Lib/email/policy.py:33–230  ·  view source on GitHub ↗

+ PROVISIONAL The API extensions enabled by this policy are currently provisional. Refer to the documentation for details. This policy adds new header parsing and folding algorithms. Instead of simple strings, headers are custom objects with custom attributes depending on

Source from the content-addressed store, hash-verified

31
32@_extend_docstrings
33class EmailPolicy(Policy):
34
35 """+
36 PROVISIONAL
37
38 The API extensions enabled by this policy are currently provisional.
39 Refer to the documentation for details.
40
41 This policy adds new header parsing and folding algorithms. Instead of
42 simple strings, headers are custom objects with custom attributes
43 depending on the type of the field. The folding algorithm fully
44 implements RFCs 2047 and 5322.
45
46 In addition to the settable attributes listed above that apply to
47 all Policies, this policy adds the following additional attributes:
48
49 utf8 -- if False (the default) message headers will be
50 serialized as ASCII, using encoded words to encode
51 any non-ASCII characters in the source strings. If
52 True, the message headers will be serialized using
53 utf8 and will not contain encoded words (see RFC
54 6532 for more on this serialization format).
55
56 refold_source -- if the value for a header in the Message object
57 came from the parsing of some source, this attribute
58 indicates whether or not a generator should refold
59 that value when transforming the message back into
60 stream form. The possible values are:
61
62 none -- all source values use original folding
63 long -- source values that have any line that is
64 longer than max_line_length will be
65 refolded
66 all -- all values are refolded.
67
68 The default is 'long'.
69
70 header_factory -- a callable that takes two arguments, 'name' and
71 'value', where 'name' is a header field name and
72 'value' is an unfolded header field value, and
73 returns a string-like object that represents that
74 header. A default header_factory is provided that
75 understands some of the RFC5322 header field types.
76 (Currently address fields and date fields have
77 special treatment, while all other fields are
78 treated as unstructured. This list will be
79 completed before the extension is marked stable.)
80
81 content_manager -- an object with at least two methods: get_content
82 and set_content. When the get_content or
83 set_content method of a Message object is called,
84 it calls the corresponding method of this object,
85 passing it the message object as its first argument,
86 and any arguments or keywords that were passed to
87 it as additional arguments. The default
88 content_manager is
89 :data:`~email.contentmanager.raw_data_manager`.
90

Callers 1

policy.pyFile · 0.85

Calls 1

HeaderRegistryClass · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…