Update pydocs.
* python/mailutils/__init__.py: Update pydocs. * python/mailutils/mailbox.py: Likewise. * python/mailutils/mailcap.py: Likewise. * python/mailutils/registrar.py: Likewise. * python/mailutils/sieve.py: Likewise.
Showing
5 changed files
with
75 additions
and
7 deletions
... | @@ -16,6 +16,28 @@ | ... | @@ -16,6 +16,28 @@ |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | # MA 02110-1301 USA | 17 | # MA 02110-1301 USA |
18 | 18 | ||
19 | """ | ||
20 | A Python interface to Mailutils framework. | ||
21 | |||
22 | GNU Mailutils is a rich and powerful protocol-independent mail | ||
23 | framework. It contains a series of useful mail libraries, clients, | ||
24 | and servers. These are the primary mail utilities for the GNU system. | ||
25 | The central library is capable of handling electronic mail in various | ||
26 | mailbox formats and protocols, both local and remote. Specifically, | ||
27 | this project contains a POP3 server, an IMAP4 server, and a Sieve mail | ||
28 | filter. It also provides a POSIX `mailx' client, and a collection of | ||
29 | other handy tools. | ||
30 | |||
31 | This software is part of the GNU Project and belongs to the Free | ||
32 | Software Foundation. All libraries are licensed using the GNU LGPL. | ||
33 | The documentation is licensed under the GNU FDL, and everything else | ||
34 | is licensed using the GNU GPL. | ||
35 | |||
36 | See http://www.gnu.org/software/mailutils/ for more information about | ||
37 | GNU Mailutils. | ||
38 | |||
39 | """ | ||
40 | |||
19 | __all__ = [ | 41 | __all__ = [ |
20 | "error", | 42 | "error", |
21 | "address", | 43 | "address", | ... | ... |
... | @@ -28,7 +28,19 @@ from mailutils.error import MailboxError | ... | @@ -28,7 +28,19 @@ from mailutils.error import MailboxError |
28 | 28 | ||
29 | class MailboxBase: | 29 | class MailboxBase: |
30 | def open (self, mode = 0): | 30 | def open (self, mode = 0): |
31 | """Open the connection.""" | 31 | """Open the connection. |
32 | |||
33 | 'mode' may be a string, consisting of the characters described | ||
34 | below, giving the access mode for the mailbox. | ||
35 | |||
36 | mode Meaning | ||
37 | -------------------------------------------------------- | ||
38 | r Open for reading. | ||
39 | w Open for writing. | ||
40 | a Open for appending to the end of the mailbox. | ||
41 | c Create the mailbox if it does not exist. | ||
42 | |||
43 | """ | ||
32 | if isinstance (mode, types.StringType): | 44 | if isinstance (mode, types.StringType): |
33 | from mailutils import stream | 45 | from mailutils import stream |
34 | flags = 0 | 46 | flags = 0 |
... | @@ -84,14 +96,14 @@ class MailboxBase: | ... | @@ -84,14 +96,14 @@ class MailboxBase: |
84 | return unseen | 96 | return unseen |
85 | 97 | ||
86 | def get_message (self, msgno): | 98 | def get_message (self, msgno): |
87 | """Retrieve message number MSGNO.""" | 99 | """Retrieve message number 'msgno'.""" |
88 | status, c_msg = mailbox.get_message (self.mbox, msgno) | 100 | status, c_msg = mailbox.get_message (self.mbox, msgno) |
89 | if status: | 101 | if status: |
90 | raise MailboxError (status) | 102 | raise MailboxError (status) |
91 | return message.Message (c_msg) | 103 | return message.Message (c_msg) |
92 | 104 | ||
93 | def append_message (self, msg): | 105 | def append_message (self, msg): |
94 | """Append MSG to the mailbox.""" | 106 | """Append 'msg' to the mailbox.""" |
95 | status = mailbox.append_message (self.mbox, msg.msg) | 107 | status = mailbox.append_message (self.mbox, msg.msg) |
96 | if status: | 108 | if status: |
97 | raise MailboxError (status) | 109 | raise MailboxError (status) |
... | @@ -135,19 +147,21 @@ class MailboxBase: | ... | @@ -135,19 +147,21 @@ class MailboxBase: |
135 | return size | 147 | return size |
136 | 148 | ||
137 | def get_folder (self): | 149 | def get_folder (self): |
138 | """Get the FOLDER.""" | 150 | """Get the Folder object.""" |
139 | status, fld = mailbox.get_folder (self.mbox) | 151 | status, fld = mailbox.get_folder (self.mbox) |
140 | if status: | 152 | if status: |
141 | raise MailboxError (status) | 153 | raise MailboxError (status) |
142 | return folder.Folder (fld) | 154 | return folder.Folder (fld) |
143 | 155 | ||
144 | def get_debug (self): | 156 | def get_debug (self): |
157 | """Get the Debug object.""" | ||
145 | status, dbg = mailbox.get_debug (self.mbox) | 158 | status, dbg = mailbox.get_debug (self.mbox) |
146 | if status: | 159 | if status: |
147 | raise MailboxError (status) | 160 | raise MailboxError (status) |
148 | return debug.Debug (dbg) | 161 | return debug.Debug (dbg) |
149 | 162 | ||
150 | def get_url (self): | 163 | def get_url (self): |
164 | """Get the Url object.""" | ||
151 | status, u = mailbox.get_url (self.mbox) | 165 | status, u = mailbox.get_url (self.mbox) |
152 | if status: | 166 | if status: |
153 | raise MailboxError (status) | 167 | raise MailboxError (status) |
... | @@ -206,6 +220,17 @@ class Mailbox (MailboxBase): | ... | @@ -206,6 +220,17 @@ class Mailbox (MailboxBase): |
206 | 220 | ||
207 | class MailboxDefault (MailboxBase): | 221 | class MailboxDefault (MailboxBase): |
208 | def __init__ (self, name = None): | 222 | def __init__ (self, name = None): |
223 | """MailboxDefault creates a Mailbox object for the supplied | ||
224 | mailbox 'name'. Before creating, the name is expanded using | ||
225 | the rules below: | ||
226 | |||
227 | % --> system mailbox for the real uid | ||
228 | %user --> system mailbox for the given user | ||
229 | ~/file --> /home/user/file | ||
230 | ~user/file --> /home/user/file | ||
231 | +file --> /home/user/Mail/file | ||
232 | =file --> /home/user/Mail/file | ||
233 | """ | ||
209 | self.mbox = mailbox.MailboxType () | 234 | self.mbox = mailbox.MailboxType () |
210 | status = mailbox.create_default (self.mbox, name) | 235 | status = mailbox.create_default (self.mbox, name) |
211 | if status: | 236 | if status: | ... | ... |
... | @@ -59,7 +59,7 @@ class Mailcap: | ... | @@ -59,7 +59,7 @@ class Mailcap: |
59 | return count | 59 | return count |
60 | 60 | ||
61 | def get_entry (self, item): | 61 | def get_entry (self, item): |
62 | """Return in MailcapEntry the mailcap entry of ITEM.""" | 62 | """Return in MailcapEntry the mailcap entry of 'item'.""" |
63 | status, entry = mailcap.get_entry (self.mc, item) | 63 | status, entry = mailcap.get_entry (self.mc, item) |
64 | if status: | 64 | if status: |
65 | raise MailcapError (status) | 65 | raise MailcapError (status) | ... | ... |
... | @@ -22,6 +22,27 @@ import types | ... | @@ -22,6 +22,27 @@ import types |
22 | from mailutils.c_api import registrar | 22 | from mailutils.c_api import registrar |
23 | 23 | ||
24 | def register_format (name = None): | 24 | def register_format (name = None): |
25 | """Register desired mailutils 'name' format. | ||
26 | |||
27 | A list or tuple of strings can be given. | ||
28 | Each element must be one of the following strings: | ||
29 | |||
30 | Argument Meaning | ||
31 | -------------------------------------------------------------- | ||
32 | 'mbox' Regular UNIX mbox format | ||
33 | 'mh' MH mailbox format | ||
34 | 'maildir' Maildir mailbox format | ||
35 | 'pop' POP mailbox format | ||
36 | 'pops' POPS mailbox format | ||
37 | 'imap' IMAP mailbox format | ||
38 | 'imaps' IMAPS mailbox format | ||
39 | 'sendmail' sendmail mailer format | ||
40 | 'smtp' SMTP mailer format | ||
41 | |||
42 | If called without arguments, the function registers all available | ||
43 | formats. | ||
44 | |||
45 | """ | ||
25 | if name == None: | 46 | if name == None: |
26 | registrar.register_format () | 47 | registrar.register_format () |
27 | elif isinstance (name, types.TupleType) \ | 48 | elif isinstance (name, types.TupleType) \ | ... | ... |
... | @@ -53,7 +53,7 @@ class Machine: | ... | @@ -53,7 +53,7 @@ class Machine: |
53 | raise SieveMachineError (status) | 53 | raise SieveMachineError (status) |
54 | 54 | ||
55 | def compile (self, name): | 55 | def compile (self, name): |
56 | """Compile the sieve script from the file NAME.""" | 56 | """Compile the sieve script from the file 'name'.""" |
57 | status = sieve.compile (self.mach, name) | 57 | status = sieve.compile (self.mach, name) |
58 | if status: | 58 | if status: |
59 | raise SieveMachineError (status) | 59 | raise SieveMachineError (status) |
... | @@ -73,7 +73,7 @@ class Machine: | ... | @@ -73,7 +73,7 @@ class Machine: |
73 | 73 | ||
74 | def message (self, msg): | 74 | def message (self, msg): |
75 | """Execute the code from the given instance of sieve machine | 75 | """Execute the code from the given instance of sieve machine |
76 | over the MSG.""" | 76 | over the 'msg'.""" |
77 | status = sieve.message (self.mach, msg.msg) | 77 | status = sieve.message (self.mach, msg.msg) |
78 | if status: | 78 | if status: |
79 | raise SieveMachineError (status) | 79 | raise SieveMachineError (status) | ... | ... |
-
Please register or sign in to post a comment