[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1
watch for a Python 3.X–compatible version of more robust and complete open
source alternatives, such as the html2text.py same-named third-party utility de-
scribed in this chapter’s earlier note. The open source BeautifulSoup system offers
another lenient and forgiving HTML parser, but is based on SGMLParser tools
available in 2.X only (removed in 3.X).

Text/HTML alternative mails
Also in the HTML department, there is presently no support for sending both text
and HTML versions of a mail as a MIME multipart/alternative message—a popular
scheme which supports both text- and HTML-based clients and allows users to
choose which to use. Such messages can be viewed (both parts are offered in the
GUI), but cannot be composed. Again, since there is no support for HTML editing
anyhow, this is a moot point; if such an editor is ever added, we’d need to support
this sort of mail structure in mailtools message object construction code and re-
factor parts of its current send logic so that it can be shared.


Internationalized headers throw list columns off
As is so often true in software, one feature added in this version broke another
already present: the fonts used for display of some non-ASCII Unicode header fields
is large enough to throw off the fixed-width columns in mail index list windows.
They rely on the assumption that N characters is always the same width among all
mails, and this is no longer true for some Chinese and other character set encodings.
This isn’t a showstopper—it only occurs when some i18n headers are displayed,
and simply means that “|” column separators are askew for such mails only, but
could still be addressed. The fix here is probably to move to a more sophisticated
list display, and might be resolved as a side effect of allowing for the column sorts
described earlier.


Address books
PyMailGUI has no notion of automatically filling in an email address from an ad-
dress book, as many modern email clients do. Adding this would be an interesting
extension; low-level keyboard event binding may allow matching as addresses are
typed, and Python’s pickle and shelve modules of Chapters 1 and 17 might come
in handy for data storage.


Spelling checker
There is currently no spelling checker of the sort most email programs have today.
This could be added in PyMailGUI, but it would probably be more appropriate to
add it in the PyEdit text edit component/program that it uses, so the spell-checking
would be inherited by all PyEdit clients. A quick web search reveals a variety of
options, including the interesting PyEnchant third-party package, none of which
we have space to explore here.


Mail searches
Similarly, there is no support for searching emails’ content (headers or bodies) for
a given string. It’s not clear how this should be provided given that the system
fetches and caches just message headers until a mail is requested, but searching


Ideas for Improvement| 1119
Free download pdf