AddressHeader ¶Īddress headers are one of the most complex structured header types. This example sets the date header to the current time and date using The decoded value of the header is determined by formatting theĭatetime according to the RFC 5322 rules that is, it is set to: If a specific timezone offset isįound (including +0000), then datetime will contain an awareĭatetime that uses datetime.timezone to record the timezone Information about the source timezone), then datetime will be a Specified as -0000 (indicating it is in UTC but contains no If the header value can be recognized as a valid date of one form orĪnother, this attribute will contain a datetime This header type provides the following additional attributes: datetime ¶ Recognizing a number of variant forms that are sometimes found “in the The DateHeader parser recognizes that date format, as well as RFC 5322 specifies a very specific format for dates within email headers. This header type provides no additional attributes. Such as invalid characters within the encoded words or the non-encoded text. Defects are registered in such cases, as well as defects for issues Parser uses heuristics to attempt to decode certain non-compliant encoded Into unicode, following the RFC 2047 rules for unstructured text. When a value containing encoded words is passed to theĬonstructor, the UnstructuredHeader parser converts such encoded words Mechanism for encoding non-ASCII text as ASCII characters within a header RFC 2047, however, has an RFC 5322 compatible In RFC 5322, an unstructured header is a run of arbitrary text in theĪSCII character set. The classic example of an unstructured header is the UnstructuredHeader ¶Īn “unstructured” header is the default type of header in RFC 5322.Īny header that does not have a specified syntax is treated as Kw (and args) passed to the BaseHeader init method. That is, anything extra that the specialized class puts in to the kwdsĭictionary should be removed and handled, and the remaining contents of Thisĭef init ( self, /, * args, ** kw ): self. The specialized class provide a classmethod() named parse. Itĭefines a protocol that each specialized header cooperates with in order to Treated as if it were 7bit, since headers may not contain arbitraryīaseHeader by itself cannot be used to create a header object. The BaseHeader valueįor this attribute is None it is expected that specialized headerĬlasses will override this value as needed.īaseHeader also provides the following method, which is called by theĮmail library code and should not in general be called by applicationĬharacters as required to correctly fold the header according to The maximum number of headers of this type that can have the same Module for a discussion of the types of defects that may be reported. The email package tries toīe complete about detecting compliance issues. RFC compliance problems found during parsing. ThisĪ tuple of HeaderDefect instances reporting any The name of the header (the portion of the field before the ‘:’). This base class defines the following read-only properties: name ¶ Name and value are passed to BaseHeader from theĪny header object is the value fully decoded to unicode. The sections below first document the header base classes and their attributes,įollowed by the API for modifying the behavior of HeaderRegistry, andįinally the support classes used to represent the data parsed from structured Transparently for the typical application program, but interfaces are providedįor modifying the default behavior for use by more complex applications. The specialized secondĬlass for a header is determined by the name of the header, using a lookup UnstructuredHeader as their other base class. Each header class has an additional base class that is determined by HeaderRegistry and have BaseHeader as their last baseĬlass. When using any of the policy objects derived from Various header types, but also provides an extension mechanism for applications Header_factory implemented by the email package for handling RFC 5322Ĭompliant email messages, which not only provides customized header objects for Particular class used to represent a given header is determined by theĮffect when the headers are created. Headers are represented by customized subclasses of str.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |