]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Updated documentation for the IMAP response type structures.
authorNaveen Nathan <naveen@lastninja.net>
Thu, 24 Oct 2013 14:40:50 +0000 (01:40 +1100)
committerNaveen Nathan <naveen@lastninja.net>
Thu, 24 Oct 2013 14:40:50 +0000 (01:40 +1100)
imapclient/response_types.py

index eae23fe38cd80706eaec29980f1f1e96a78ce086..b4a81f7e4664e19db1aeec4dd56233600531478d 100644 (file)
@@ -2,10 +2,63 @@
 # Released subject to the New BSD License
 # Please see http://en.wikipedia.org/wiki/BSD_licenses
 
+"""
+Structured representation for IMAP response.
+Inspired by Ruby Net::IMAP::Envelope and Net::IMAP::Address
+(see http://www.ruby-doc.org/stdlib-2.0.0/libdoc/net/imap/rdoc/Net/IMAP.html).
+"""
+
 from collections import namedtuple
 
-Address = namedtuple("Address", "Name Route Mailbox Host")
+# the following hacks to add docstrings to namedtuples is courtesy of:
+# http://stackoverflow.com/questions/1606436/adding-docstrings-to-namedtuples-in-python
+
+class Address(namedtuple("Address", "Name Route Mailbox Host")):
+    """
+    Represents electronic mail addresses.
+
+    Fields (in-order):
+
+        Name -- Returns the phrase from [RFC-822] mailbox.
+
+        Route -- Returns the route from [RFC-822] route-addr.
+
+        Mailbox -- None indicates end of [RFC-822] group. If not None and host is None,
+                   returns [RFC-822] group name. Otherwise, returns [RFC-822] local-part.
+
+        Host -- None indicates [RFC-822] group syntax. Otherwise, returns [RFC-822] domain name.
+
+
+    """
 
 # note lowercase "from" is a keyword
-Envelope = namedtuple("Envelope", "Date Subject From Sender Reply_To To " + \
-                                  "Cc Bcc In_Reply_To Message_Id")
+class Envelope(namedtuple("Envelope", "Date Subject From Sender Reply_To To " + \
+                          "Cc Bcc In_Reply_To Message_Id")):
+    """
+
+    Represents envelope structures of messages.
+
+    Fields (in-order):
+
+        Date -- Returns a string that represents the "Date:" header.
+
+        Subject -- Returns a string that represents the "Subject:" header.
+
+        From -- Returns a tuple sequence of Address structure that represents "From:" header.
+
+        Sender -- Returns a tuple sequence of Address structure that represents "Sender:" header.
+
+        Reply_To -- Returns a tuple sequence of Address structure that represents "Reply_To:" header.
+
+        To -- Returns a tuple sequence of Address structure that represents "To:" header.
+
+        Cc -- Returns a tuple sequence of Address structure that represents "Cc:" header.
+
+        Bcc -- Returns a tuple sequence of Address structure that represents "Bcc:" header.
+
+        In_Reply_To -- Returns a string that represents the "In-Reply-To:" header.
+
+        Message_Id -- Returns a string that represents the "Message-Id:" header.
+
+
+    """