neulab/docprompting-conala huggingface dataset:
class email.headerregistry.BaseHeader(name, value)  
name and value are passed to BaseHeader from the header_factory call. The string value of any header object is the value fully decoded to unicode. This base class defines the following read-only properties:  
name  
The name of the header (the portion of the field before the ‘:’). This is exactly the value passed in the header_factory call for name; that is, case is preserved. 
  
defects  
A tuple of HeaderDefect instances reporting any RFC compliance problems found during parsing. The email package tries to be complete about detecting compliance issues. See the errors module for a discussion of the types of defects that may be reported. 
  
max_count  
The maximum number of headers of this type that can have the same name. A value of None means unlimited. The BaseHeader value for this attribute is None; it is expected that specialized header classes will override this value as needed. 
 BaseHeader also provides the following method, which is called by the email library code and should not in general be called by application programs:  
fold(*, policy)  
Return a string containing linesep characters as required to correctly fold the header according to policy. A cte_type of 8bit will be treated as if it were 7bit, since headers may not contain arbitrary binary data. If utf8 is False, non-ASCII data will be RFC 2047 encoded. 
 BaseHeader by itself cannot be used to create a header object. It defines a protocol that each specialized header cooperates with in order to produce the header object. Specifically, BaseHeader requires that the specialized class provide a classmethod() named parse. This method is called as follows: parse(string, kwds)
 kwds is a dictionary containing one pre-initialized key, defects. defects is an empty list. The parse method should append any detected defects to this list. On return, the kwds dictionary must contain values for at least the keys decoded and defects. decoded should be the string value for the header (that is, the header value fully decoded to unicode). The parse method should assume that string may contain content-transfer-encoded parts, but should correctly handle all valid unicode characters as well so that it can parse un-encoded header values. BaseHeader’s __new__ then creates the header instance, and calls its init method. The specialized class only needs to provide an init method if it wishes to set additional attributes beyond those provided by BaseHeader itself. Such an init method should look like this: def init(self, /, *args, **kw):
    self._myattr = kw.pop('myattr')
    super().init(*args, **kw)
 That is, anything extra that the specialized class puts in to the kwds dictionary should be removed and handled, and the remaining contents of kw (and args) passed to the BaseHeader init method.
defects  
A tuple of HeaderDefect instances reporting any RFC compliance problems found during parsing. The email package tries to be complete about detecting compliance issues. See the errors module for a discussion of the types of defects that may be reported.
fold(*, policy)  
Return a string containing linesep characters as required to correctly fold the header according to policy. A cte_type of 8bit will be treated as if it were 7bit, since headers may not contain arbitrary binary data. If utf8 is False, non-ASCII data will be RFC 2047 encoded.
max_count  
The maximum number of headers of this type that can have the same name. A value of None means unlimited. The BaseHeader value for this attribute is None; it is expected that specialized header classes will override this value as needed.
name  
The name of the header (the portion of the field before the ‘:’). This is exactly the value passed in the header_factory call for name; that is, case is preserved.
class email.headerregistry.ContentDispositionHeader  
A ParameterizedMIMEHeader class that handles the Content-Disposition header.  
content_disposition  
inline and attachment are the only valid values in common use.
class email.headerregistry.ContentTransferEncoding  
Handles the Content-Transfer-Encoding header.  
cte  
Valid values are 7bit, 8bit, base64, and quoted-printable. See RFC 2045 for more information.
cte  
Valid values are 7bit, 8bit, base64, and quoted-printable. See RFC 2045 for more information.
class email.headerregistry.ContentTypeHeader  
A ParameterizedMIMEHeader class that handles the Content-Type header.  
content_type  
The content type string, in the form maintype/subtype. 
  
maintype 
  
subtype
class email.headerregistry.DateHeader  
RFC 5322 specifies a very specific format for dates within email headers. The DateHeader parser recognizes that date format, as well as recognizing a number of variant forms that are sometimes found “in the wild”. This header type provides the following additional attributes:  
datetime  
If the header value can be recognized as a valid date of one form or another, this attribute will contain a datetime instance representing that date. If the timezone of the input date is specified as -0000 (indicating it is in UTC but contains no information about the source timezone), then datetime will be a naive datetime. If a specific timezone offset is found (including +0000), then datetime will contain an aware datetime that uses datetime.timezone to record the timezone offset. 
 The decoded value of the header is determined by formatting the datetime according to the RFC 5322 rules; that is, it is set to: email.utils.format_datetime(self.datetime)
 When creating a DateHeader, value may be datetime instance. This means, for example, that the following code is valid and does what one would expect: msg['Date'] = datetime(2011, 7, 15, 21)
 Because this is a naive datetime it will be interpreted as a UTC timestamp, and the resulting value will have a timezone of -0000. Much more useful is to use the localtime() function from the utils module: msg['Date'] = utils.localtime()
 This example sets the date header to the current time and date using the current timezone offset.
datetime  
If the header value can be recognized as a valid date of one form or another, this attribute will contain a datetime instance representing that date. If the timezone of the input date is specified as -0000 (indicating it is in UTC but contains no information about the source timezone), then datetime will be a naive datetime. If a specific timezone offset is found (including +0000), then datetime will contain an aware datetime that uses datetime.timezone to record the timezone offset.
class email.headerregistry.Group(display_name=None, addresses=None)  
The class used to represent an address group. The general form of an address group is: display_name: [address-list];
 As a convenience for processing lists of addresses that consist of a mixture of groups and single addresses, a Group may also be used to represent single addresses that are not part of a group by setting display_name to None and providing a list of the single address as addresses.  
display_name  
The display_name of the group. If it is None and there is exactly one Address in addresses, then the Group represents a single address that is not in a group. 
  
addresses  
A possibly empty tuple of Address objects representing the addresses in the group. 
  
__str__()  
The str value of a Group is formatted according to RFC 5322, but with no Content Transfer Encoding of any non-ASCII characters. If display_name is none and there is a single Address in the addresses list, the str value will be the same as the str of that single Address.
display_name  
The display_name of the group. If it is None and there is exactly one Address in addresses, then the Group represents a single address that is not in a group.
__str__()  
The str value of a Group is formatted according to RFC 5322, but with no Content Transfer Encoding of any non-ASCII characters. If display_name is none and there is a single Address in the addresses list, the str value will be the same as the str of that single Address.
class email.headerregistry.HeaderRegistry(base_class=BaseHeader, default_class=UnstructuredHeader, use_default_map=True)  
This is the factory used by EmailPolicy by default. HeaderRegistry builds the class used to create a header instance dynamically, using base_class and a specialized class retrieved from a registry that it holds. When a given header name does not appear in the registry, the class specified by default_class is used as the specialized class. When use_default_map is True (the default), the standard mapping of header names to classes is copied in to the registry during initialization. base_class is always the last class in the generated class’s __bases__ list. The default mappings are:  subject 
UniqueUnstructuredHeader  date 
UniqueDateHeader  resent-date 
DateHeader  orig-date 
UniqueDateHeader  sender 
UniqueSingleAddressHeader  resent-sender 
SingleAddressHeader  to 
UniqueAddressHeader  resent-to 
AddressHeader  cc 
UniqueAddressHeader  resent-cc 
AddressHeader  bcc 
UniqueAddressHeader  resent-bcc 
AddressHeader  from 
UniqueAddressHeader  resent-from 
AddressHeader  reply-to 
UniqueAddressHeader  mime-version 
MIMEVersionHeader  content-type 
ContentTypeHeader  content-disposition 
ContentDispositionHeader  content-transfer-encoding 
ContentTransferEncodingHeader  message-id 
MessageIDHeader   HeaderRegistry has the following methods:  
map_to_type(self, name, cls)  
name is the name of the header to be mapped. It will be converted to lower case in the registry. cls is the specialized class to be used, along with base_class, to create the class used to instantiate headers that match name. 
  
__getitem__(name)  
Construct and return a class to handle creating a name header. 
  
__call__(name, value)  
Retrieves the specialized header associated with name from the registry (using default_class if name does not appear in the registry) and composes it with base_class to produce a class, calls the constructed class’s constructor, passing it the same argument list, and finally returns the class instance created thereby.
map_to_type(self, name, cls)  
name is the name of the header to be mapped. It will be converted to lower case in the registry. cls is the specialized class to be used, along with base_class, to create the class used to instantiate headers that match name.
__call__(name, value)  
Retrieves the specialized header associated with name from the registry (using default_class if name does not appear in the registry) and composes it with base_class to produce a class, calls the constructed class’s constructor, passing it the same argument list, and finally returns the class instance created thereby.
__getitem__(name)  
Construct and return a class to handle creating a name header.
class email.headerregistry.MIMEVersionHeader  
There is really only one valid value for the MIME-Version header, and that is 1.0. For future proofing, this header class supports other valid version numbers. If a version number has a valid value per RFC 2045, then the header object will have non-None values for the following attributes:  
version  
The version number as a string, with any whitespace and/or comments removed. 
  
major  
The major version number as an integer 
  
minor  
The minor version number as an integer
class email.headerregistry.ParameterizedMIMEHeader  
MIME headers all start with the prefix ‘Content-‘. Each specific header has a certain value, described under the class for that header. Some can also take a list of supplemental parameters, which have a common format. This class serves as a base for all the MIME headers that take parameters.  
params  
A dictionary mapping parameter names to parameter values.
class email.headerregistry.SingleAddressHeader  
A subclass of AddressHeader that adds one additional attribute:  
address  
The single address encoded by the header value. If the header value actually contains more than one address (which would be a violation of the RFC under the default policy), accessing this attribute will result in a ValueError.
address  
The single address encoded by the header value. If the header value actually contains more than one address (which would be a violation of the RFC under the default policy), accessing this attribute will result in a ValueError.
class email.headerregistry.UnstructuredHeader  
An “unstructured” header is the default type of header in RFC 5322. Any header that does not have a specified syntax is treated as unstructured. The classic example of an unstructured header is the Subject header. In RFC 5322, an unstructured header is a run of arbitrary text in the ASCII character set. RFC 2047, however, has an RFC 5322 compatible mechanism for encoding non-ASCII text as ASCII characters within a header value. When a value containing encoded words is passed to the constructor, the UnstructuredHeader parser converts such encoded words into unicode, following the RFC 2047 rules for unstructured text. The parser uses heuristics to attempt to decode certain non-compliant encoded words. Defects are registered in such cases, as well as defects for issues such as invalid characters within the encoded words or the non-encoded text. This header type provides no additional attributes.
email.iterators.body_line_iterator(msg, decode=False)  
This iterates over all the payloads in all the subparts of msg, returning the string payloads line-by-line. It skips over all the subpart headers, and it skips over any subpart with a payload that isn’t a Python string. This is somewhat equivalent to reading the flat text representation of the message from a file using readline(), skipping over all the intervening headers. Optional decode is passed through to Message.get_payload.
email.iterators.typed_subpart_iterator(msg, maintype='text', subtype=None)  
This iterates over all the subparts of msg, returning only those subparts that match the MIME type specified by maintype and subtype. Note that subtype is optional; if omitted, then subpart MIME type matching is done only with the main type. maintype is optional too; it defaults to text. Thus, by default typed_subpart_iterator() returns each subpart that has a MIME type of text/*.
email.iterators._structure(msg, fp=None, level=0, include_default=False)  
Prints an indented representation of the content types of the message object structure. For example: >>> msg = email.message_from_file(somefile)
>>> _structure(msg)
multipart/mixed
    text/plain
    text/plain
    multipart/digest
        message/rfc822
            text/plain
        message/rfc822
            text/plain
        message/rfc822
            text/plain
        message/rfc822
            text/plain
        message/rfc822
            text/plain
    text/plain
 Optional fp is a file-like object to print the output to. It must be suitable for Python’s print() function. level is used internally. include_default, if true, prints the default type as well.
add_alternative(*args, content_manager=None, **kw)  
If the message is a multipart/alternative, create a new message object, pass all of the arguments to its set_content() method, and attach() it to the multipart. If the message is a non-multipart or multipart/related, call make_alternative() and then proceed as above. If the message is any other type of multipart, raise a TypeError. If content_manager is not specified, use the content_manager specified by the current policy.
add_attachment(*args, content_manager=None, **kw)  
If the message is a multipart/mixed, create a new message object, pass all of the arguments to its set_content() method, and attach() it to the multipart. If the message is a non-multipart, multipart/related, or multipart/alternative, call make_mixed() and then proceed as above. If content_manager is not specified, use the content_manager specified by the current policy. If the added part has no Content-Disposition header, add one with the value attachment. This method can be used both for explicit attachments (Content-Disposition: attachment) and inline attachments (Content-Disposition: inline), by passing appropriate options to the content_manager.
add_header(_name, _value, **_params)  
Extended header setting. This method is similar to __setitem__() except that additional header parameters can be provided as keyword arguments. _name is the header field to add and _value is the primary value for the header. For each item in the keyword argument dictionary _params, the key is taken as the parameter name, with underscores converted to dashes (since dashes are illegal in Python identifiers). Normally, the parameter will be added as key="value" unless the value is None, in which case only the key will be added. If the value contains non-ASCII characters, the charset and language may be explicitly controlled by specifying the value as a three tuple in the format (CHARSET, LANGUAGE, VALUE), where CHARSET is a string naming the charset to be used to encode the value, LANGUAGE can usually be set to None or the empty string (see RFC 2231 for other possibilities), and VALUE is the string value containing non-ASCII code points. If a three tuple is not passed and the value contains non-ASCII characters, it is automatically encoded in RFC 2231 format using a CHARSET of utf-8 and a LANGUAGE of None. Here is an example: msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')
 This will add a header that looks like Content-Disposition: attachment; filename="bud.gif"
 An example of the extended interface with non-ASCII characters: msg.add_header('Content-Disposition', 'attachment',
               filename=('iso-8859-1', '', 'Fußballer.ppt'))
add_related(*args, content_manager=None, **kw)  
If the message is a multipart/related, create a new message object, pass all of the arguments to its set_content() method, and attach() it to the multipart. If the message is a non-multipart, call make_related() and then proceed as above. If the message is any other type of multipart, raise a TypeError. If content_manager is not specified, use the content_manager specified by the current policy. If the added part has no Content-Disposition header, add one with the value inline.
as_bytes(unixfrom=False, policy=None)  
Return the entire message flattened as a bytes object. When optional unixfrom is true, the envelope header is included in the returned string. unixfrom defaults to False. The policy argument may be used to override the default policy obtained from the message instance. This can be used to control some of the formatting produced by the method, since the specified policy will be passed to the BytesGenerator. Flattening the message may trigger changes to the EmailMessage if defaults need to be filled in to complete the transformation to a string (for example, MIME boundaries may be generated or modified). Note that this method is provided as a convenience and may not be the most useful way to serialize messages in your application, especially if you are dealing with multiple messages. See email.generator.BytesGenerator for a more flexible API for serializing messages.
as_string(unixfrom=False, maxheaderlen=None, policy=None)  
Return the entire message flattened as a string. When optional unixfrom is true, the envelope header is included in the returned string. unixfrom defaults to False. For backward compatibility with the base Message class maxheaderlen is accepted, but defaults to None, which means that by default the line length is controlled by the max_line_length of the policy. The policy argument may be used to override the default policy obtained from the message instance. This can be used to control some of the formatting produced by the method, since the specified policy will be passed to the Generator. Flattening the message may trigger changes to the EmailMessage if defaults need to be filled in to complete the transformation to a string (for example, MIME boundaries may be generated or modified). Note that this method is provided as a convenience and may not be the most useful way to serialize messages in your application, especially if you are dealing with multiple messages. See email.generator.Generator for a more flexible API for serializing messages. Note also that this method is restricted to producing messages serialized as “7 bit clean” when utf8 is False, which is the default.  Changed in version 3.6: the default behavior when maxheaderlen is not specified was changed from defaulting to 0 to defaulting to the value of max_line_length from the policy.
clear_content()  
Remove the payload and all of the Content- headers, leaving all other headers intact and in their original order.
defects  
The defects attribute contains a list of all the problems found when parsing this message. See email.errors for a detailed description of the possible parsing defects.
del_param(param, header='content-type', requote=True)  
Remove the given parameter completely from the Content-Type header. The header will be re-written in place without the parameter or its value. Optional header specifies an alternative to Content-Type. Use of the requote parameter with EmailMessage objects is deprecated.
epilogue  
The epilogue attribute acts the same way as the preamble attribute, except that it contains text that appears between the last boundary and the end of the message. As with the preamble, if there is no epilog text this attribute will be None.
get(name, failobj=None)  
Return the value of the named header field. This is identical to __getitem__() except that optional failobj is returned if the named header is missing (failobj defaults to None).
get_all(name, failobj=None)  
Return a list of all the values for the field named name. If there are no such named headers in the message, failobj is returned (defaults to None).
get_body(preferencelist=('related', 'html', 'plain'))  
Return the MIME part that is the best candidate to be the “body” of the message. preferencelist must be a sequence of strings from the set related, html, and plain, and indicates the order of preference for the content type of the part returned. Start looking for candidate matches with the object on which the get_body method is called. If related is not included in preferencelist, consider the root part (or subpart of the root part) of any related encountered as a candidate if the (sub-)part matches a preference. When encountering a multipart/related, check the start parameter and if a part with a matching Content-ID is found, consider only it when looking for candidate matches. Otherwise consider only the first (default root) part of the multipart/related. If a part has a Content-Disposition header, only consider the part a candidate match if the value of the header is inline. If none of the candidates matches any of the preferences in preferencelist, return None. Notes: (1) For most applications the only preferencelist combinations that really make sense are ('plain',), ('html', 'plain'), and the default ('related', 'html', 'plain'). (2) Because matching starts with the object on which get_body is called, calling get_body on a multipart/related will return the object itself unless preferencelist has a non-default value. (3) Messages (or message parts) that do not specify a Content-Type or whose Content-Type header is invalid will be treated as if they are of type text/plain, which may occasionally cause get_body to return unexpected results.
get_boundary(failobj=None)  
Return the value of the boundary parameter of the Content-Type header of the message, or failobj if either the header is missing, or has no boundary parameter. The returned string will always be unquoted as per email.utils.unquote().
get_charsets(failobj=None)  
Return a list containing the character set names in the message. If the message is a multipart, then the list will contain one element for each subpart in the payload, otherwise, it will be a list of length 1. Each item in the list will be a string which is the value of the charset parameter in the Content-Type header for the represented subpart. If the subpart has no Content-Type header, no charset parameter, or is not of the text main MIME type, then that item in the returned list will be failobj.