From 8524d20072ee5284984d968be6b88100a79d75ad Mon Sep 17 00:00:00 2001 From: Keith Gaughan Date: Sat, 16 Sep 2017 16:17:11 +0100 Subject: [PATCH 1/2] Encode output file as UTF-8. --- planet/shell/_genshi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planet/shell/_genshi.py b/planet/shell/_genshi.py index 7880a3ad..f7944d0c 100644 --- a/planet/shell/_genshi.py +++ b/planet/shell/_genshi.py @@ -141,7 +141,7 @@ def run(script, doc, output_file=None, options={}): if output_file: out_file = open(output_file,'w') - out_file.write(output) + out_file.write(output.encode('utf-8')) out_file.close() else: return output From a7954c331a9d6f48d8da18a0317320ea2e9f13dd Mon Sep 17 00:00:00 2001 From: Keith Gaughan Date: Sat, 16 Sep 2017 16:23:30 +0100 Subject: [PATCH 2/2] Choose an appropriate rendering method. --- planet/shell/_genshi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/planet/shell/_genshi.py b/planet/shell/_genshi.py index f7944d0c..c991e628 100644 --- a/planet/shell/_genshi.py +++ b/planet/shell/_genshi.py @@ -137,7 +137,11 @@ def run(script, doc, output_file=None, options={}): context.push(vars) # apply template - output=tmpl.generate(context).render('xml') + if output_file.endswith('.xml'): + method = 'xml' + else: + method = 'xhtml' + output = tmpl.generate(context).render(method) if output_file: out_file = open(output_file,'w')