summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libmhlib.tex
blob: 27b71b063315fcc8f6151bd582f47556ae938ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
% LaTeX'ized from the comments in the module by Skip Montanaro
% <skip@mojam.com>.

\section{\module{mhlib} ---
         Access to MH mailboxes}

\declaremodule{standard}{mhlib}
\modulesynopsis{Manipulate MH mailboxes from Python.}


The \module{mhlib} module provides a Python interface to MH folders and
their contents.

The module contains three basic classes, \class{MH}, which represents a
particular collection of folders, \class{Folder}, which represents a single
folder, and \class{Message}, which represents a single message.


\begin{classdesc}{MH}{\optional{path\optional{, profile}}}
\class{MH} represents a collection of MH folders.
\end{classdesc}

\begin{classdesc}{Folder}{mh, name}
The \class{Folder} class represents a single folder and its messages.
\end{classdesc}

\begin{classdesc}{Message}{folder, number\optional{, name}}
\class{Message} objects represent individual messages in a folder.  The
Message class is derived from \class{mimetools.Message}.
\end{classdesc}


\subsection{MH Objects \label{mh-objects}}

\class{MH} instances have the following methods:


\begin{methoddesc}[MH]{error}{format\optional{, ...}}
Print an error message -- can be overridden.
\end{methoddesc}

\begin{methoddesc}[MH]{getprofile}{key}
Return a profile entry (\code{None} if not set).
\end{methoddesc}

\begin{methoddesc}[MH]{getpath}{}
Return the mailbox pathname.
\end{methoddesc}

\begin{methoddesc}[MH]{getcontext}{}
Return the current folder name.
\end{methoddesc}

\begin{methoddesc}[MH]{setcontext}{name}
Set the current folder name.
\end{methoddesc}

\begin{methoddesc}[MH]{listfolders}{}
Return a list of top-level folders.
\end{methoddesc}

\begin{methoddesc}[MH]{listallfolders}{}
Return a list of all folders.
\end{methoddesc}

\begin{methoddesc}[MH]{listsubfolders}{name}
Return a list of direct subfolders of the given folder.
\end{methoddesc}

\begin{methoddesc}[MH]{listallsubfolders}{name}
Return a list of all subfolders of the given folder.
\end{methoddesc}

\begin{methoddesc}[MH]{makefolder}{name}
Create a new folder.
\end{methoddesc}

\begin{methoddesc}[MH]{deletefolder}{name}
Delete a folder -- must have no subfolders.
\end{methoddesc}

\begin{methoddesc}[MH]{openfolder}{name}
Return a new open folder object.
\end{methoddesc}



\subsection{Folder Objects \label{mh-folder-objects}}

\class{Folder} instances represent open folders and have the following
methods:


\begin{methoddesc}[Folder]{error}{format\optional{, ...}}
Print an error message -- can be overridden.
\end{methoddesc}

\begin{methoddesc}[Folder]{getfullname}{}
Return the folder's full pathname.
\end{methoddesc}

\begin{methoddesc}[Folder]{getsequencesfilename}{}
Return the full pathname of the folder's sequences file.
\end{methoddesc}

\begin{methoddesc}[Folder]{getmessagefilename}{n}
Return the full pathname of message \var{n} of the folder.
\end{methoddesc}

\begin{methoddesc}[Folder]{listmessages}{}
Return a list of messages in the folder (as numbers).
\end{methoddesc}

\begin{methoddesc}[Folder]{getcurrent}{}
Return the current message number.
\end{methoddesc}

\begin{methoddesc}[Folder]{setcurrent}{n}
Set the current message number to \var{n}.
\end{methoddesc}

\begin{methoddesc}[Folder]{parsesequence}{seq}
Parse msgs syntax into list of messages.
\end{methoddesc}

\begin{methoddesc}[Folder]{getlast}{}
Get last message, or \code{0} if no messages are in the folder.
\end{methoddesc}

\begin{methoddesc}[Folder]{setlast}{n}
Set last message (internal use only).
\end{methoddesc}

\begin{methoddesc}[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.
\end{methoddesc}

\begin{methoddesc}[Folder]{putsequences}{dict}
Return dictionary of sequences in folder {name: list}.
\end{methoddesc}

\begin{methoddesc}[Folder]{removemessages}{list}
Remove messages in list from folder.
\end{methoddesc}

\begin{methoddesc}[Folder]{refilemessages}{list, tofolder}
Move messages in list to other folder.
\end{methoddesc}

\begin{methoddesc}[Folder]{movemessage}{n, tofolder, ton}
Move one message to a given destination in another folder.
\end{methoddesc}

\begin{methoddesc}[Folder]{copymessage}{n, tofolder, ton}
Copy one message to a given destination in another folder.
\end{methoddesc}


\subsection{Message Objects \label{mh-message-objects}}

The \class{Message} class adds one method to those of
\class{mimetools.Message}:

\begin{methoddesc}[Message]{openmessage}{n}
Return a new open message object (costs a file descriptor).
\end{methoddesc}