18.5. mhlib
β Access to MH mailboxesΒΆ
Deprecated since version 2.6: The mhlib
module has been removed in Python 3. Use the
mailbox
instead.
The mhlib
module provides a Python interface to MH folders and their
contents.
The module contains three basic classes, MH
, which represents a
particular collection of folders, Folder
, which represents a single
folder, and Message
, which represents a single message.
-
class
mhlib.
Message
(folder, number[, name])ΒΆ Message
objects represent individual messages in a folder. The Message class is derived frommimetools.Message
.
18.5.1. MH ObjectsΒΆ
MH
instances have the following methods:
-
MH.
error
(format[, ...])ΒΆ Print an error message β can be overridden.
-
MH.
getprofile
(key)ΒΆ Return a profile entry (
None
if not set).
-
MH.
getpath
()ΒΆ Return the mailbox pathname.
-
MH.
getcontext
()ΒΆ Return the current folder name.
-
MH.
setcontext
(name)ΒΆ Set the current folder name.
-
MH.
listfolders
()ΒΆ Return a list of top-level folders.
-
MH.
listallfolders
()ΒΆ Return a list of all folders.
-
MH.
listsubfolders
(name)ΒΆ Return a list of direct subfolders of the given folder.
-
MH.
listallsubfolders
(name)ΒΆ Return a list of all subfolders of the given folder.
-
MH.
makefolder
(name)ΒΆ Create a new folder.
-
MH.
deletefolder
(name)ΒΆ Delete a folder β must have no subfolders.
-
MH.
openfolder
(name)ΒΆ Return a new open folder object.
18.5.2. Folder ObjectsΒΆ
Folder
instances represent open folders and have the following methods:
-
Folder.
error
(format[, ...])ΒΆ Print an error message β can be overridden.
-
Folder.
getfullname
()ΒΆ Return the folderβs full pathname.
-
Folder.
getsequencesfilename
()ΒΆ Return the full pathname of the folderβs sequences file.
-
Folder.
getmessagefilename
(n)ΒΆ Return the full pathname of message n of the folder.
-
Folder.
listmessages
()ΒΆ Return a list of messages in the folder (as numbers).
-
Folder.
getcurrent
()ΒΆ Return the current message number.
-
Folder.
setcurrent
(n)ΒΆ Set the current message number to n.
-
Folder.
parsesequence
(seq)ΒΆ Parse msgs syntax into list of messages.
-
Folder.
getlast
()ΒΆ Get last message, or
0
if no messages are in the folder.
-
Folder.
setlast
(n)ΒΆ Set last message (internal use only).
-
Folder.
getsequences
()ΒΆ Return dictionary of sequences in folder. The sequence names are used as keys, and the values are the lists of message numbers in the sequences.
-
Folder.
putsequences
(dict)ΒΆ Return dictionary of sequences in folder name: list.
-
Folder.
removemessages
(list)ΒΆ Remove messages in list from folder.
-
Folder.
refilemessages
(list, tofolder)ΒΆ Move messages in list to other folder.
-
Folder.
movemessage
(n, tofolder, ton)ΒΆ Move one message to a given destination in another folder.
-
Folder.
copymessage
(n, tofolder, ton)ΒΆ Copy one message to a given destination in another folder.
18.5.3. Message ObjectsΒΆ
The Message
class adds one method to those of
mimetools.Message
:
-
Message.
openmessage
(n)ΒΆ Return a new open message object (costs a file descriptor).