aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/comment.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-26 09:27:50 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-26 09:27:50 -0400
commit97aeb18b20f901950da0355471fdc17055f3f4a8 (patch)
tree83caecf530df36cc9f88bd94373b0fea0129b979 /becommands/comment.py
parent033a4446c1522c9ff288afa6bc47c3d15d290216 (diff)
downloadbugseverywhere-97aeb18b20f901950da0355471fdc17055f3f4a8.tar.gz
Added ability to handle non text/* MIME types.
The main problem was the encoding/decoding that was happening to _all_ input/output. Now many I/O activities have a `binary' option to disable any encoding/decoding. The `binary' flag is set whenever the comment content-type is not a text/* type. In order to print valid XML (and make life easy on xml/be-xml-to-mbox), non text/* types are printed out as base64-encoded MIME messages, so be list --xml | be-xml-to-mbox | catmutt works as you'd expect. With the standard (non-XML) output from `be show', we just print a message telling the user that we can't reasonably display the MIME type and that they should use the XML output if they want to see it.
Diffstat (limited to 'becommands/comment.py')
-rw-r--r--becommands/comment.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/becommands/comment.py b/becommands/comment.py
index f7459dd..b31a6e7 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -93,9 +93,13 @@ def execute(args, test=False):
raise cmdutil.UserError("No comment entered.")
body = body.decode('utf-8')
elif args[1] == '-': # read body from stdin
- body = sys.stdin.read()
- if not body.endswith('\n'):
- body+='\n'
+ binary = not options.content_type.startswith("text/")
+ if not binary:
+ body = sys.stdin.read()
+ if not body.endswith('\n'):
+ body+='\n'
+ else: # read-in without decoding
+ body = sys.__stdin__.read()
else: # body = arg[1]
body = args[1]
if not body.endswith('\n'):