text: Note
  The headerregistry module has been included in the standard library on a provisional basis. Backwards incompatible changes (up to and including removal of the module) may occur if deemed necessary by the core developers.
  New in version 3.3: as a provisional module. EmailPolicy, all headers are produced.
  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:
  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.
  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.
  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:
  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 strings may not contain binary data.
  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 transport 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. parser converts such encoded words back in to the original.
  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:
  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:
  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.
  Address headers are one of the most complex structured header types. The AddressHeader class provides a generic interface to any address header.
  This header type provides the following additional attributes:
  A tuple of Group objects encoding the addresses and groups found in the header value. Addresses that are not part of a group are represented in this list as single-address Groups whose display_name is None.
  A tuple of Address objects value of the header will have all encoded words decoded to unicode. idna encoded domain names are also decoded to unicode. The decoded value is set by joining the str value of the elements of the groups attribute with ', '.
  A list of Address and Group objects in any combination may be used to set the value of an address header. Group objects whose display_name is None will be interpreted as single addresses, which allows an address list to be copied with groups intact by using the list obtained groups attribute of the source header.
  A subclass of AddressHeader that adds one additional attribute: values for the following attributes:
  The version number as a string, with any whitespace and/or comments removed.
  The major version number as an integer
  The minor version number as an integer
  MOME.
  A dictionary mapping parameter names to parameter values.
  A ParameterizedMIMEHeader class that handles the Content-Type header.
  The content type string, in the form maintype/subtype.
  A ParameterizedMIMEHeader class that handles the Content-Disposition header.
  inline and attachment are the only valid values in common use.
  Handles the Content-Transfer-Encoding header.
  Valid values are 7bit, 8bit, base64, and quoted-printable. See RFC 2045 for more information.
  This is the factory used by EmailPolicy by default. HeaderRegistry builds:
  HeaderRegistry has the following methods:
  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.
  Construct and return a class to handle creating a name header. will raise an error. Unicode characters are allowed and will be property encoded when serialized. However, per the RFCs, unicode is not allowed in the username portion of the address.
  The display name portion of the address, if any, with all quoting removed. If the address does not have a display name, this attribute will be an empty string.
  The username portion of the address, with all quoting removed.
  The domain portion of the address.
  The username@domain portion of the address, correctly quoted for use as a bare address (the second form shown above). This attribute is not mutable.
  The str value of the object is the address quoted according to RFC 5322 rules, but with no Content Transfer Encoding of any non-ASCII characters.
  To support SMTP (RFC 5321), Address handles one special case: if username and domain are both the empty string (or None), then the string value of the Address is <>.
  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.
  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.
  A possibly empty tuple of Address objects representing the addresses in the group.
  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.