Author: brett.cannon
Date: Wed May 30 23:19:47 2007
New Revision: 55688
Removed:
python/branches/p3yk/Doc/lib/libmimewriter.tex
python/branches/p3yk/Lib/MimeWriter.py
python/branches/p3yk/Lib/test/test_MimeWriter.py
Modified:
python/branches/p3yk/Doc/Makefile.deps
python/branches/p3yk/Doc/lib/lib.tex
python/branches/p3yk/Lib/test/test___all__.py
python/branches/p3yk/Misc/NEWS
Log:
Ditch MimeWriter.
Modified: python/branches/p3yk/Doc/Makefile.deps
==============================================================================
--- python/branches/p3yk/Doc/Makefile.deps (original)
+++ python/branches/p3yk/Doc/Makefile.deps Wed May 30 23:19:47 2007
@@ -192,7 +192,6 @@
lib/libsgmllib.tex \
lib/librfc822.tex \
lib/libmimetools.tex \
- lib/libmimewriter.tex \
lib/libbinascii.tex \
lib/libmm.tex \
lib/libaudioop.tex \
Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex (original)
+++ python/branches/p3yk/Doc/lib/lib.tex Wed May 30 23:19:47 2007
@@ -146,7 +146,6 @@
\input{libmhlib}
\input{libmimetools}
\input{libmimetypes}
-\input{libmimewriter}
\input{libmimify}
\input{libmultifile}
\input{librfc822}
Deleted: /python/branches/p3yk/Doc/lib/libmimewriter.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libmimewriter.tex Wed May 30 23:19:47 2007
+++ (empty file)
@@ -1,80 +0,0 @@
-\section{\module{MimeWriter} ---
- Generic MIME file writer}
-
-\declaremodule{standard}{MimeWriter}
-
-\modulesynopsis{Generic MIME file writer.}
-\sectionauthor{Christopher G. [EMAIL PROTECTED]
-
-\deprecated{2.3}{The \refmodule{email} package should be used in
- preference to the \module{MimeWriter} module. This
- module is present only to maintain backward
- compatibility.}
-
-This module defines the class \class{MimeWriter}. The
-\class{MimeWriter} class implements a basic formatter for creating
-MIME multi-part files. It doesn't seek around the output file nor
-does it use large amounts of buffer space. You must write the parts
-out in the order that they should occur in the final
-file. \class{MimeWriter} does buffer the headers you add, allowing you
-to rearrange their order.
-
-\begin{classdesc}{MimeWriter}{fp}
-Return a new instance of the \class{MimeWriter} class. The only
-argument passed, \var{fp}, is a file object to be used for
-writing. Note that a \class{StringIO} object could also be used.
-\end{classdesc}
-
-
-\subsection{MimeWriter Objects \label{MimeWriter-objects}}
-
-
-\class{MimeWriter} instances have the following methods:
-
-\begin{methoddesc}[MimeWriter]{addheader}{key, value\optional{, prefix}}
-Add a header line to the MIME message. The \var{key} is the name of
-the header, where the \var{value} obviously provides the value of the
-header. The optional argument \var{prefix} determines where the header
-is inserted; \samp{0} means append at the end, \samp{1} is insert at
-the start. The default is to append.
-\end{methoddesc}
-
-\begin{methoddesc}[MimeWriter]{flushheaders}{}
-Causes all headers accumulated so far to be written out (and
-forgotten). This is useful if you don't need a body part at all,
-e.g.\ for a subpart of type \mimetype{message/rfc822} that's (mis)used
-to store some header-like information.
-\end{methoddesc}
-
-\begin{methoddesc}[MimeWriter]{startbody}{ctype\optional{, plist\optional{,
prefix}}}
-Returns a file-like object which can be used to write to the
-body of the message. The content-type is set to the provided
-\var{ctype}, and the optional parameter \var{plist} provides
-additional parameters for the content-type declaration. \var{prefix}
-functions as in \method{addheader()} except that the default is to
-insert at the start.
-\end{methoddesc}
-
-\begin{methoddesc}[MimeWriter]{startmultipartbody}{subtype\optional{,
- boundary\optional{, plist\optional{, prefix}}}}
-Returns a file-like object which can be used to write to the
-body of the message. Additionally, this method initializes the
-multi-part code, where \var{subtype} provides the multipart subtype,
-\var{boundary} may provide a user-defined boundary specification, and
-\var{plist} provides optional parameters for the subtype.
-\var{prefix} functions as in \method{startbody()}. Subparts should be
-created using \method{nextpart()}.
-\end{methoddesc}
-
-\begin{methoddesc}[MimeWriter]{nextpart}{}
-Returns a new instance of \class{MimeWriter} which represents an
-individual part in a multipart message. This may be used to write the
-part as well as used for creating recursively complex multipart
-messages. The message must first be initialized with
-\method{startmultipartbody()} before using \method{nextpart()}.
-\end{methoddesc}
-
-\begin{methoddesc}[MimeWriter]{lastpart}{}
-This is used to designate the last part of a multipart message, and
-should \emph{always} be used when writing multipart messages.
-\end{methoddesc}
Deleted: /python/branches/p3yk/Lib/MimeWriter.py
==============================================================================
--- /python/branches/p3yk/Lib/MimeWriter.py Wed May 30 23:19:47 2007
+++ (empty file)
@@ -1,181 +0,0 @@
-"""Generic MIME writer.
-
-This module defines the class MimeWriter. The MimeWriter class implements
-a basic formatter for creating MIME multi-part files. It doesn't seek around
-the output file nor does it use large amounts of buffer space. You must write
-the parts out in the order that they should occur in the final file.
-MimeWriter does buffer the headers you add, allowing you to rearrange their
-order.
-
-"""
-
-
-import mimetools
-
-__all__ = ["MimeWriter"]
-
-class MimeWriter:
-
- """Generic MIME writer.
-
- Methods:
-
- __init__()
- addheader()
- flushheaders()
- startbody()
- startmultipartbody()
- nextpart()
- lastpart()
-
- A MIME writer is much more primitive than a MIME parser. It
- doesn't seek around on the output file, and it doesn't use large
- amounts of buffer space, so you have to write the parts in the
- order they should occur on the output file. It does buffer the
- headers you add, allowing you to rearrange their order.
-
- General usage is:
-
- f = <open the output file>
- w = MimeWriter(f)
- ...call w.addheader(key, value) 0 or more times...
-
- followed by either:
-
- f = w.startbody(content_type)
- ...call f.write(data) for body data...
-
- or:
-
- w.startmultipartbody(subtype)
- for each part:
- subwriter = w.nextpart()
- ...use the subwriter's methods to create the subpart...
- w.lastpart()
-
- The subwriter is another MimeWriter instance, and should be
- treated in the same way as the toplevel MimeWriter. This way,
- writing recursive body parts is easy.
-
- Warning: don't forget to call lastpart()!
-
- XXX There should be more state so calls made in the wrong order
- are detected.
-
- Some special cases:
-
- - startbody() just returns the file passed to the constructor;
- but don't use this knowledge, as it may be changed.
-
- - startmultipartbody() actually returns a file as well;
- this can be used to write the initial 'if you can read this your
- mailer is not MIME-aware' message.
-
- - If you call flushheaders(), the headers accumulated so far are
- written out (and forgotten); this is useful if you don't need a
- body part at all, e.g. for a subpart of type message/rfc822
- that's (mis)used to store some header-like information.
-
- - Passing a keyword argument 'prefix=<flag>' to addheader(),
- start*body() affects where the header is inserted; 0 means
- append at the end, 1 means insert at the start; default is
- append for addheader(), but insert for start*body(), which use
- it to determine where the Content-Type header goes.
-
- """
-
- def __init__(self, fp):
- self._fp = fp
- self._headers = []
-
- def addheader(self, key, value, prefix=0):
- """Add a header line to the MIME message.
-
- The key is the name of the header, where the value obviously provides
- the value of the header. The optional argument prefix determines
- where the header is inserted; 0 means append at the end, 1 means
- insert at the start. The default is to append.
-
- """
- lines = value.split("\n")
- while lines and not lines[-1]: del lines[-1]
- while lines and not lines[0]: del lines[0]
- for i in range(1, len(lines)):
- lines[i] = " " + lines[i].strip()
- value = "\n".join(lines) + "\n"
- line = key + ": " + value
- if prefix:
- self._headers.insert(0, line)
- else:
- self._headers.append(line)
-
- def flushheaders(self):
- """Writes out and forgets all headers accumulated so far.
-
- This is useful if you don't need a body part at all; for example,
- for a subpart of type message/rfc822 that's (mis)used to store some
- header-like information.
-
- """
- self._fp.writelines(self._headers)
- self._headers = []
-
- def startbody(self, ctype, plist=[], prefix=1):
- """Returns a file-like object for writing the body of the message.
-
- The content-type is set to the provided ctype, and the optional
- parameter, plist, provides additional parameters for the
- content-type declaration. The optional argument prefix determines
- where the header is inserted; 0 means append at the end, 1 means
- insert at the start. The default is to insert at the start.
-
- """
- for name, value in plist:
- ctype = ctype + ';\n %s=\"%s\"' % (name, value)
- self.addheader("Content-Type", ctype, prefix=prefix)
- self.flushheaders()
- self._fp.write("\n")
- return self._fp
-
- def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1):
- """Returns a file-like object for writing the body of the message.
-
- Additionally, this method initializes the multi-part code, where the
- subtype parameter provides the multipart subtype, the boundary
- parameter may provide a user-defined boundary specification, and the
- plist parameter provides optional parameters for the subtype. The
- optional argument, prefix, determines where the header is inserted;
- 0 means append at the end, 1 means insert at the start. The default
- is to insert at the start. Subparts should be created using the
- nextpart() method.
-
- """
- self._boundary = boundary or mimetools.choose_boundary()
- return self.startbody("multipart/" + subtype,
- [("boundary", self._boundary)] + plist,
- prefix=prefix)
-
- def nextpart(self):
- """Returns a new instance of MimeWriter which represents an
- individual part in a multipart message.
-
- This may be used to write the part as well as used for creating
- recursively complex multipart messages. The message must first be
- initialized with the startmultipartbody() method before using the
- nextpart() method.
-
- """
- self._fp.write("\n--" + self._boundary + "\n")
- return self.__class__(self._fp)
-
- def lastpart(self):
- """This is used to designate the last part of a multipart message.
-
- It should always be used when writing multipart messages.
-
- """
- self._fp.write("\n--" + self._boundary + "--\n")
-
-
-if __name__ == '__main__':
- import test.test_MimeWriter
Deleted: /python/branches/p3yk/Lib/test/test_MimeWriter.py
==============================================================================
--- /python/branches/p3yk/Lib/test/test_MimeWriter.py Wed May 30 23:19:47 2007
+++ (empty file)
@@ -1,291 +0,0 @@
-"""Test program for MimeWriter module.
-
-The test program was too big to comfortably fit in the MimeWriter
-class, so it's here in its own file.
-
-This should generate Barry's example, modulo some quotes and newlines.
-
-"""
-
-import unittest, sys, StringIO
-from test.test_support import run_unittest
-
-from MimeWriter import MimeWriter
-
-SELLER = '''\
-INTERFACE Seller-1;
-
-TYPE Seller = OBJECT
- DOCUMENTATION "A simple Seller interface to test ILU"
- METHODS
- price():INTEGER,
- END;
-'''
-
-BUYER = '''\
-class Buyer:
- def __setup__(self, maxprice):
- self._maxprice = maxprice
-
- def __main__(self, kos):
- """Entry point upon arrival at a new KOS."""
- broker = kos.broker()
- # B4 == Barry's Big Bass Business :-)
- seller = broker.lookup('Seller_1.Seller', 'B4')
- if seller:
- price = seller.price()
- print 'Seller wants $', price, '... '
- if price > self._maxprice:
- print 'too much!'
- else:
- print "I'll take it!"
- else:
- print 'no seller found here'
-''' # Don't ask why this comment is here
-
-STATE = '''\
-# instantiate a buyer instance and put it in a magic place for the KOS
-# to find.
-__kp__ = Buyer()
-__kp__.__setup__(500)
-'''
-
-SIMPLE_METADATA = [
- ("Interpreter", "python"),
- ("Interpreter-Version", "1.3"),
- ("Owner-Name", "Barry Warsaw"),
- ("Owner-Rendezvous", "[EMAIL PROTECTED]"),
- ("Home-KSS", "kss.cnri.reston.va.us"),
- ("Identifier", "hdl://cnri.kss/my_first_knowbot"),
- ("Launch-Date", "Mon Feb 12 16:39:03 EST 1996"),
- ]
-
-COMPLEX_METADATA = [
- ("Metadata-Type", "complex"),
- ("Metadata-Key", "connection"),
- ("Access", "read-only"),
- ("Connection-Description", "Barry's Big Bass Business"),
- ("Connection-Id", "B4"),
- ("Connection-Direction", "client"),
- ]
-
-EXTERNAL_METADATA = [
- ("Metadata-Type", "complex"),
- ("Metadata-Key", "generic-interface"),
- ("Access", "read-only"),
- ("Connection-Description", "Generic Interface for All Knowbots"),
- ("Connection-Id", "generic-kp"),
- ("Connection-Direction", "client"),
- ]
-
-
-OUTPUT = '''\
-From: [EMAIL PROTECTED]
-Date: Mon Feb 12 17:21:48 EST 1996
-To: [EMAIL PROTECTED]
-MIME-Version: 1.0
-Content-Type: multipart/knowbot;
- boundary="801spam999";
- version="0.1"
-
-This is a multi-part message in MIME format.
-
---801spam999
-Content-Type: multipart/knowbot-metadata;
- boundary="802spam999"
-
-
---802spam999
-Content-Type: message/rfc822
-KP-Metadata-Type: simple
-KP-Access: read-only
-
-KPMD-Interpreter: python
-KPMD-Interpreter-Version: 1.3
-KPMD-Owner-Name: Barry Warsaw
-KPMD-Owner-Rendezvous: [EMAIL PROTECTED]
-KPMD-Home-KSS: kss.cnri.reston.va.us
-KPMD-Identifier: hdl://cnri.kss/my_first_knowbot
-KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996
-
---802spam999
-Content-Type: text/isl
-KP-Metadata-Type: complex
-KP-Metadata-Key: connection
-KP-Access: read-only
-KP-Connection-Description: Barry's Big Bass Business
-KP-Connection-Id: B4
-KP-Connection-Direction: client
-
-INTERFACE Seller-1;
-
-TYPE Seller = OBJECT
- DOCUMENTATION "A simple Seller interface to test ILU"
- METHODS
- price():INTEGER,
- END;
-
---802spam999
-Content-Type: message/external-body;
- access-type="URL";
- URL="hdl://cnri.kss/generic-knowbot"
-
-Content-Type: text/isl
-KP-Metadata-Type: complex
-KP-Metadata-Key: generic-interface
-KP-Access: read-only
-KP-Connection-Description: Generic Interface for All Knowbots
-KP-Connection-Id: generic-kp
-KP-Connection-Direction: client
-
-
---802spam999--
-
---801spam999
-Content-Type: multipart/knowbot-code;
- boundary="803spam999"
-
-
---803spam999
-Content-Type: text/plain
-KP-Module-Name: BuyerKP
-
-class Buyer:
- def __setup__(self, maxprice):
- self._maxprice = maxprice
-
- def __main__(self, kos):
- """Entry point upon arrival at a new KOS."""
- broker = kos.broker()
- # B4 == Barry's Big Bass Business :-)
- seller = broker.lookup('Seller_1.Seller', 'B4')
- if seller:
- price = seller.price()
- print 'Seller wants $', price, '... '
- if price > self._maxprice:
- print 'too much!'
- else:
- print "I'll take it!"
- else:
- print 'no seller found here'
-
---803spam999--
-
---801spam999
-Content-Type: multipart/knowbot-state;
- boundary="804spam999"
-KP-Main-Module: main
-
-
---804spam999
-Content-Type: text/plain
-KP-Module-Name: main
-
-# instantiate a buyer instance and put it in a magic place for the KOS
-# to find.
-__kp__ = Buyer()
-__kp__.__setup__(500)
-
---804spam999--
-
---801spam999--
-'''
-
-class MimewriterTest(unittest.TestCase):
-
- def test(self):
- buf = StringIO.StringIO()
-
- # Toplevel headers
-
- toplevel = MimeWriter(buf)
- toplevel.addheader("From", "[EMAIL PROTECTED]")
- toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996")
- toplevel.addheader("To", "[EMAIL PROTECTED]")
- toplevel.addheader("MIME-Version", "1.0")
-
- # Toplevel body parts
-
- f = toplevel.startmultipartbody("knowbot", "801spam999",
- [("version", "0.1")], prefix=0)
- f.write("This is a multi-part message in MIME format.\n")
-
- # First toplevel body part: metadata
-
- md = toplevel.nextpart()
- md.startmultipartbody("knowbot-metadata", "802spam999")
-
- # Metadata part 1
-
- md1 = md.nextpart()
- md1.addheader("KP-Metadata-Type", "simple")
- md1.addheader("KP-Access", "read-only")
- m = MimeWriter(md1.startbody("message/rfc822"))
- for key, value in SIMPLE_METADATA:
- m.addheader("KPMD-" + key, value)
- m.flushheaders()
- del md1
-
- # Metadata part 2
-
- md2 = md.nextpart()
- for key, value in COMPLEX_METADATA:
- md2.addheader("KP-" + key, value)
- f = md2.startbody("text/isl")
- f.write(SELLER)
- del md2
-
- # Metadata part 3
-
- md3 = md.nextpart()
- f = md3.startbody("message/external-body",
- [("access-type", "URL"),
- ("URL", "hdl://cnri.kss/generic-knowbot")])
- m = MimeWriter(f)
- for key, value in EXTERNAL_METADATA:
- md3.addheader("KP-" + key, value)
- md3.startbody("text/isl")
- # Phantom body doesn't need to be written
-
- md.lastpart()
-
- # Second toplevel body part: code
-
- code = toplevel.nextpart()
- code.startmultipartbody("knowbot-code", "803spam999")
-
- # Code: buyer program source
-
- buyer = code.nextpart()
- buyer.addheader("KP-Module-Name", "BuyerKP")
- f = buyer.startbody("text/plain")
- f.write(BUYER)
-
- code.lastpart()
-
- # Third toplevel body part: state
-
- state = toplevel.nextpart()
- state.addheader("KP-Main-Module", "main")
- state.startmultipartbody("knowbot-state", "804spam999")
-
- # State: a bunch of assignments
-
- st = state.nextpart()
- st.addheader("KP-Module-Name", "main")
- f = st.startbody("text/plain")
- f.write(STATE)
-
- state.lastpart()
-
- # End toplevel body parts
-
- toplevel.lastpart()
-
- self.assertEqual(buf.getvalue(), OUTPUT)
-
-def test_main():
- run_unittest(MimewriterTest)
-
-if __name__ == '__main__':
- test_main()
Modified: python/branches/p3yk/Lib/test/test___all__.py
==============================================================================
--- python/branches/p3yk/Lib/test/test___all__.py (original)
+++ python/branches/p3yk/Lib/test/test___all__.py Wed May 30 23:19:47 2007
@@ -1,7 +1,6 @@
import unittest
from test.test_support import verbose, run_unittest
import sys
-import warnings
class AllTest(unittest.TestCase):
@@ -34,7 +33,6 @@
self.check_all("CGIHTTPServer")
self.check_all("ConfigParser")
self.check_all("Cookie")
- self.check_all("MimeWriter")
self.check_all("Queue")
self.check_all("SimpleHTTPServer")
self.check_all("SocketServer")
Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS (original)
+++ python/branches/p3yk/Misc/NEWS Wed May 30 23:19:47 2007
@@ -175,8 +175,8 @@
AST -> bytecode mechanism.
- Removed these modules:
- * Bastion, bsddb185, exceptions, md5, popen2, rexec,
- sets, sha, stringold, strop, xmllib
+ * Bastion, bsddb185, exceptions, md5, MimeWriter, popen2, rexec,
+ sets, sha, stringold, strop, xmllib.
- Remove obsolete IRIX modules: al/AL, cd/CD, cddb, cdplayer, cl/CL, DEVICE,
ERRNO, FILE, fl/FL, flp, fm, GET, gl/GL, GLWS, IN, imgfile, IOCTL, jpeg,
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins