aboutsummaryrefslogtreecommitdiffstats
path: root/misc
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
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')
-rwxr-xr-xmisc/xml/be-mail-to-xml6
-rwxr-xr-xmisc/xml/be-xml-to-mbox12
2 files changed, 10 insertions, 8 deletions
diff --git a/misc/xml/be-mail-to-xml b/misc/xml/be-mail-to-xml
index 0b33465..5a1a88f 100755
--- a/misc/xml/be-mail-to-xml
+++ b/misc/xml/be-mail-to-xml
@@ -23,20 +23,17 @@ followed by a blank line.
"""
import base64
-import codecs
import email.utils
from libbe.util.encoding import get_output_encoding
from libbe.util.utility import time_to_str
import mailbox # the mailbox people really want an on-disk copy
import optparse
-import sys
from time import asctime, gmtime, mktime
import types
from xml.sax.saxutils import escape
BREAK = u'--' # signature separator
DEFAULT_ENCODING = get_output_encoding()
-sys.stdout = codecs.getwriter(DEFAULT_ENCODING)(sys.stdout)
KNOWN_IDS = []
@@ -172,4 +169,7 @@ def main(argv):
if __name__ == "__main__":
import sys
+ import codecs
+
+ sys.stdout = codecs.getwriter(DEFAULT_ENCODING)(sys.stdout)
main(sys.argv)
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()