aboutsummaryrefslogtreecommitdiffstats
path: root/misc/xml/be-xml-to-mbox
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2010-01-21 09:17:40 -0500
committerW. Trevor King <wking@drexel.edu>2010-01-21 09:17:40 -0500
commita7134ad51224e33df79d4589b677ad0718387f48 (patch)
tree234673618f378d3e379885fac5e897319cb4d1e2 /misc/xml/be-xml-to-mbox
parentbe2de86f947b7bf2bb44f415df0a6f685633a64b (diff)
downloadbugseverywhere-a7134ad51224e33df79d4589b677ad0718387f48.tar.gz
Converted `be list --xml` to <be-xml> format.
Fixed up be-xml-to-mbox following the recent libbe restructuring. Moved stdout manipulation in be-mail-to-xml into the if __name__ == '__main__' block, in case some other module wants to recycle some of its functions/methods.
Diffstat (limited to 'misc/xml/be-xml-to-mbox')
-rwxr-xr-xmisc/xml/be-xml-to-mbox12
1 files changed, 7 insertions, 5 deletions
diff --git a/misc/xml/be-xml-to-mbox b/misc/xml/be-xml-to-mbox
index 34d0aa3..015444e 100755
--- a/misc/xml/be-xml-to-mbox
+++ b/misc/xml/be-xml-to-mbox
@@ -25,10 +25,9 @@ followed by a blank line.
"""
#from mailbox import mbox, Message # the mailbox people really want an on-disk copy
-import codecs
import email.utils
-from libbe.encoding import get_encoding, set_IO_stream_encodings
-from libbe.utility import str_to_time as rfc2822_to_gmtime_integer
+from libbe.util.encoding import get_output_encoding
+from libbe.util.utility import str_to_time as rfc2822_to_gmtime_integer
from time import asctime, gmtime
import types
try: # import core module, Python >= 2.5
@@ -40,8 +39,7 @@ from xml.sax.saxutils import unescape
DEFAULT_DOMAIN = "invalid.com"
DEFAULT_EMAIL = "dummy@" + DEFAULT_DOMAIN
-DEFAULT_ENCODING = get_encoding()
-set_IO_stream_encodings(DEFAULT_ENCODING)
+DEFAULT_ENCODING = get_output_encoding()
def rfc2822_to_asctime(rfc2822_string):
"""Convert an RFC 2822-fomatted string into a asctime string.
@@ -197,7 +195,11 @@ def print_to_mbox(element):
print_to_mbox(elt)
if __name__ == "__main__":
+ import codecs
import sys
+
+ sys.stdin = codecs.getreader(DEFAULT_ENCODING)(sys.stdin)
+ sys.stdout = codecs.getwriter(DEFAULT_ENCODING)(sys.stdout)
if len(sys.argv) == 1: # no filename given, use stdin
xml_unicode = sys.stdin.read()