Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e14dde2

Browse files
committed
Fixed description of similarity between m[name] and m.getheader(name),
reported by Samuel L. Bayer. Use methoddesc instead of funcdesc, etc.
1 parent d275de9 commit e14dde2

2 files changed

Lines changed: 52 additions & 48 deletions

File tree

Doc/lib/librfc822.tex

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,42 @@ \section{Standard Module \sectcode{rfc822}}
6262
\end{funcdesc}
6363

6464
\subsection{Message Objects}
65+
\label{message-objects}
6566

6667
A \class{Message} instance has the following methods:
6768

68-
\begin{funcdesc}{rewindbody}{}
69+
\begin{methoddesc}{rewindbody}{}
6970
Seek to the start of the message body. This only works if the file
7071
object is seekable.
71-
\end{funcdesc}
72+
\end{methoddesc}
7273

73-
\begin{funcdesc}{getallmatchingheaders}{name}
74+
\begin{methoddesc}{getallmatchingheaders}{name}
7475
Return a list of lines consisting of all headers matching
7576
\var{name}, if any. Each physical line, whether it is a continuation
7677
line or not, is a separate list item. Return the empty list if no
7778
header matches \var{name}.
78-
\end{funcdesc}
79+
\end{methoddesc}
7980

80-
\begin{funcdesc}{getfirstmatchingheader}{name}
81+
\begin{methoddesc}{getfirstmatchingheader}{name}
8182
Return a list of lines comprising the first header matching
8283
\var{name}, and its continuation line(s), if any. Return \code{None}
8384
if there is no header matching \var{name}.
84-
\end{funcdesc}
85+
\end{methoddesc}
8586

86-
\begin{funcdesc}{getrawheader}{name}
87+
\begin{methoddesc}{getrawheader}{name}
8788
Return a single string consisting of the text after the colon in the
8889
first header matching \var{name}. This includes leading whitespace,
8990
the trailing linefeed, and internal linefeeds and whitespace if there
9091
any continuation line(s) were present. Return \code{None} if there is
9192
no header matching \var{name}.
92-
\end{funcdesc}
93+
\end{methoddesc}
9394

94-
\begin{funcdesc}{getheader}{name}
95+
\begin{methoddesc}{getheader}{name}
9596
Like \code{getrawheader(\var{name})}, but strip leading and trailing
9697
whitespace. Internal whitespace is not stripped.
97-
\end{funcdesc}
98+
\end{methoddesc}
9899

99-
\begin{funcdesc}{getaddr}{name}
100+
\begin{methoddesc}{getaddr}{name}
100101
Return a pair \code{(\var{full name}, \var{email address})} parsed
101102
from the string returned by \code{getheader(\var{name})}. If no
102103
header matching \var{name} exists, return \code{(None, None)};
@@ -110,9 +111,9 @@ \subsection{Message Objects}
110111
If the header contained
111112
\code{'Jack Jansen <[email protected]>'} instead, it would yield the
112113
exact same result.
113-
\end{funcdesc}
114+
\end{methoddesc}
114115

115-
\begin{funcdesc}{getaddrlist}{name}
116+
\begin{methoddesc}{getaddrlist}{name}
116117
This is similar to \code{getaddr(\var{list})}, but parses a header
117118
containing a list of email addresses (e.g. a \code{To} header) and
118119
returns a list of \code{(\var{full name}, \var{email address})} pairs
@@ -121,9 +122,9 @@ \subsection{Message Objects}
121122

122123
XXX The current version of this function is not really correct. It
123124
yields bogus results if a full name contains a comma.
124-
\end{funcdesc}
125+
\end{methoddesc}
125126

126-
\begin{funcdesc}{getdate}{name}
127+
\begin{methoddesc}{getdate}{name}
127128
Retrieve a header using \method{getheader()} and parse it into a 9-tuple
128129
compatible with \function{time.mktime()}. If there is no header matching
129130
\var{name}, or it is unparsable, return \code{None}.
@@ -132,32 +133,33 @@ \subsection{Message Objects}
132133
the standard. While it has been tested and found correct on a large
133134
collection of email from many sources, it is still possible that this
134135
function may occasionally yield an incorrect result.
135-
\end{funcdesc}
136+
\end{methoddesc}
136137

137-
\begin{funcdesc}{getdate_tz}{name}
138+
\begin{methoddesc}{getdate_tz}{name}
138139
Retrieve a header using \method{getheader()} and parse it into a
139140
10-tuple; the first 9 elements will make a tuple compatible with
140141
\function{time.mktime()}, and the 10th is a number giving the offset
141142
of the date's timezone from UTC. Similarly to \method{getdate()}, if
142143
there is no header matching \var{name}, or it is unparsable, return
143144
\code{None}.
144-
\end{funcdesc}
145+
\end{methoddesc}
145146

146147
\class{Message} instances also support a read-only mapping interface.
147-
In particular: \code{\var{m}[name]} is the same as
148-
\code{\var{m}.getheader(name)}; and \code{len(\var{m})},
148+
In particular: \code{\var{m}[name]} is like
149+
\code{\var{m}.getheader(name)} but raises \exception{KeyError} if
150+
there is no matching header; and \code{len(\var{m})},
149151
\code{\var{m}.has_key(name)}, \code{\var{m}.keys()},
150152
\code{\var{m}.values()} and \code{\var{m}.items()} act as expected
151153
(and consistently).
152154

153155
Finally, \class{Message} instances have two public instance variables:
154156

155-
\begin{datadesc}{headers}
157+
\begin{memberdesc}{headers}
156158
A list containing the entire set of header lines, in the order in
157159
which they were read. Each line contains a trailing newline. The
158160
blank line terminating the headers is not contained in the list.
159-
\end{datadesc}
161+
\end{memberdesc}
160162

161-
\begin{datadesc}{fp}
163+
\begin{memberdesc}{fp}
162164
The file object passed at instantiation time.
163-
\end{datadesc}
165+
\end{memberdesc}

Doc/librfc822.tex

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,42 @@ \section{Standard Module \sectcode{rfc822}}
6262
\end{funcdesc}
6363

6464
\subsection{Message Objects}
65+
\label{message-objects}
6566

6667
A \class{Message} instance has the following methods:
6768

68-
\begin{funcdesc}{rewindbody}{}
69+
\begin{methoddesc}{rewindbody}{}
6970
Seek to the start of the message body. This only works if the file
7071
object is seekable.
71-
\end{funcdesc}
72+
\end{methoddesc}
7273

73-
\begin{funcdesc}{getallmatchingheaders}{name}
74+
\begin{methoddesc}{getallmatchingheaders}{name}
7475
Return a list of lines consisting of all headers matching
7576
\var{name}, if any. Each physical line, whether it is a continuation
7677
line or not, is a separate list item. Return the empty list if no
7778
header matches \var{name}.
78-
\end{funcdesc}
79+
\end{methoddesc}
7980

80-
\begin{funcdesc}{getfirstmatchingheader}{name}
81+
\begin{methoddesc}{getfirstmatchingheader}{name}
8182
Return a list of lines comprising the first header matching
8283
\var{name}, and its continuation line(s), if any. Return \code{None}
8384
if there is no header matching \var{name}.
84-
\end{funcdesc}
85+
\end{methoddesc}
8586

86-
\begin{funcdesc}{getrawheader}{name}
87+
\begin{methoddesc}{getrawheader}{name}
8788
Return a single string consisting of the text after the colon in the
8889
first header matching \var{name}. This includes leading whitespace,
8990
the trailing linefeed, and internal linefeeds and whitespace if there
9091
any continuation line(s) were present. Return \code{None} if there is
9192
no header matching \var{name}.
92-
\end{funcdesc}
93+
\end{methoddesc}
9394

94-
\begin{funcdesc}{getheader}{name}
95+
\begin{methoddesc}{getheader}{name}
9596
Like \code{getrawheader(\var{name})}, but strip leading and trailing
9697
whitespace. Internal whitespace is not stripped.
97-
\end{funcdesc}
98+
\end{methoddesc}
9899

99-
\begin{funcdesc}{getaddr}{name}
100+
\begin{methoddesc}{getaddr}{name}
100101
Return a pair \code{(\var{full name}, \var{email address})} parsed
101102
from the string returned by \code{getheader(\var{name})}. If no
102103
header matching \var{name} exists, return \code{(None, None)};
@@ -110,9 +111,9 @@ \subsection{Message Objects}
110111
If the header contained
111112
\code{'Jack Jansen <[email protected]>'} instead, it would yield the
112113
exact same result.
113-
\end{funcdesc}
114+
\end{methoddesc}
114115

115-
\begin{funcdesc}{getaddrlist}{name}
116+
\begin{methoddesc}{getaddrlist}{name}
116117
This is similar to \code{getaddr(\var{list})}, but parses a header
117118
containing a list of email addresses (e.g. a \code{To} header) and
118119
returns a list of \code{(\var{full name}, \var{email address})} pairs
@@ -121,9 +122,9 @@ \subsection{Message Objects}
121122

122123
XXX The current version of this function is not really correct. It
123124
yields bogus results if a full name contains a comma.
124-
\end{funcdesc}
125+
\end{methoddesc}
125126

126-
\begin{funcdesc}{getdate}{name}
127+
\begin{methoddesc}{getdate}{name}
127128
Retrieve a header using \method{getheader()} and parse it into a 9-tuple
128129
compatible with \function{time.mktime()}. If there is no header matching
129130
\var{name}, or it is unparsable, return \code{None}.
@@ -132,32 +133,33 @@ \subsection{Message Objects}
132133
the standard. While it has been tested and found correct on a large
133134
collection of email from many sources, it is still possible that this
134135
function may occasionally yield an incorrect result.
135-
\end{funcdesc}
136+
\end{methoddesc}
136137

137-
\begin{funcdesc}{getdate_tz}{name}
138+
\begin{methoddesc}{getdate_tz}{name}
138139
Retrieve a header using \method{getheader()} and parse it into a
139140
10-tuple; the first 9 elements will make a tuple compatible with
140141
\function{time.mktime()}, and the 10th is a number giving the offset
141142
of the date's timezone from UTC. Similarly to \method{getdate()}, if
142143
there is no header matching \var{name}, or it is unparsable, return
143144
\code{None}.
144-
\end{funcdesc}
145+
\end{methoddesc}
145146

146147
\class{Message} instances also support a read-only mapping interface.
147-
In particular: \code{\var{m}[name]} is the same as
148-
\code{\var{m}.getheader(name)}; and \code{len(\var{m})},
148+
In particular: \code{\var{m}[name]} is like
149+
\code{\var{m}.getheader(name)} but raises \exception{KeyError} if
150+
there is no matching header; and \code{len(\var{m})},
149151
\code{\var{m}.has_key(name)}, \code{\var{m}.keys()},
150152
\code{\var{m}.values()} and \code{\var{m}.items()} act as expected
151153
(and consistently).
152154

153155
Finally, \class{Message} instances have two public instance variables:
154156

155-
\begin{datadesc}{headers}
157+
\begin{memberdesc}{headers}
156158
A list containing the entire set of header lines, in the order in
157159
which they were read. Each line contains a trailing newline. The
158160
blank line terminating the headers is not contained in the list.
159-
\end{datadesc}
161+
\end{memberdesc}
160162

161-
\begin{datadesc}{fp}
163+
\begin{memberdesc}{fp}
162164
The file object passed at instantiation time.
163-
\end{datadesc}
165+
\end{memberdesc}

0 commit comments

Comments
 (0)