Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
47db2527
Kaydet (Commit)
47db2527
authored
Haz 20, 2003
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add some documentation which describes how to use the email package
instead of rfc822 as the Message factory.
üst
dc31dc02
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
libmailbox.tex
Doc/lib/libmailbox.tex
+35
-1
No files found.
Doc/lib/libmailbox.tex
Dosyayı görüntüle @
47db2527
...
...
@@ -16,7 +16,7 @@ mailbox file. The optional \var{factory} parameter is a callable that
should create new message objects.
\var
{
factory
}
is called with one
argument,
\var
{
fp
}
by the
\method
{
next()
}
method of the mailbox
object. The default is the
\class
{
rfc822.Message
}
class (see the
\refmodule
{
rfc822
}
module).
\refmodule
{
rfc822
}
module
-- and the note below
).
For maximum portability, messages in a
\UNIX
-style mailbox are
separated by any line that begins exactly with the string
\code
{
'From
...
...
@@ -83,6 +83,40 @@ messages start with the EOOH line and end with a line containing only
\class
{
UnixMailbox
}
class.
\end{classdesc}
Note that because the
\refmodule
{
rfc822
}
module is deprecated, it is
recommended that you use the
\refmodule
{
email
}
package to create
message objects from a mailbox. (The default can't be changed for
backwards compatibility reasons.) The safest way to do this is with
bit of code:
\begin{verbatim}
import email
import email.Errors
import mailbox
def msgfactory(fp):
try:
return email.message
_
from
_
file(fp)
except email.Errors.MessageParseError:
# Don't return None since that will
# stop the mailbox iterator
return ''
mbox = mailbox.UnixMailbox(fp, msgfactory)
\end{verbatim}
The above wrapper is defensive against ill-formed MIME messages in the
mailbox, but you have to be prepared to receive the empty string from
the mailbox's
\function
{
next()
}
method. On the other hand, if you
know your mailbox contains only well-formed MIME messages, you can
simplify this to:
\begin{verbatim}
import email
import mailbox
mbox = mailbox.UnixMailbox(fp, email.message
_
from
_
file)
\end{verbatim}
\begin{seealso}
\seetitle
[http://www.qmail.org/man/man5/mbox.html]
{
mbox -
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment