Repository 'blast2html'
hg clone https://toolshed.g2.bx.psu.edu/repos/jankanis/blast2html

Changeset 50:bfc82a8aa3c9 (2014-05-21)
Previous changeset 49:85f757f4fcd5 (2014-05-20) Next changeset 51:b15a20c2372a (2014-05-21)
Commit message:
unicodify python sources
modified:
blast2html.py
b
diff -r 85f757f4fcd5 -r bfc82a8aa3c9 blast2html.py
--- a/blast2html.py Tue May 20 16:19:05 2014 +0200
+++ b/blast2html.py Wed May 21 18:17:03 2014 +0200
b
@@ -1,9 +1,13 @@
 #!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
 # Actually runs under either python 2 or 3
 
 # Copyright The Hyve B.V. 2014
 # License: GPL version 3 or higher
 
+from __future__ import unicode_literals
+
 import sys
 import math
 import warnings
@@ -169,7 +173,7 @@
         self.templatename = templatename
 
         self.blast = objectify.parse(self.input).getroot()
-        self.loader = jinja2.FileSystemLoader(searchpath=templatedir)
+        self.loader = jinja2.FileSystemLoader(searchpath=templatedir, encoding='utf-8')
         self.environment = jinja2.Environment(loader=self.loader,
                                               lstrip_blocks=True, trim_blocks=True, autoescape=True)
 
@@ -283,16 +287,16 @@
     input_group = parser.add_mutually_exclusive_group(required=True)
     input_group.add_argument('positional_arg', metavar='INPUT', nargs='?', type=argparse.FileType(mode='r'),
                              help='The input Blast XML file, same as -i/--input')
-    input_group.add_argument('-i', '--input', type=argparse.FileType(mode='r'), 
+    input_group.add_argument('-i', '--input', type=argparse.FileType(mode='r', encoding='utf-8'), 
                              help='The input Blast XML file')
-    parser.add_argument('-o', '--output', type=argparse.FileType(mode='w'), default=sys.stdout,
+    parser.add_argument('-o', '--output', type=argparse.FileType(mode='w', encoding='utf-8'), default=sys.stdout,
                         help='The output html file')
     # We just want the file name here, so jinja can open the file
     # itself. But it is easier to just use a FileType so argparse can
     # handle the errors. This introduces a small race condition when
     # jinja later tries to re-open the template file, but we don't
     # care too much.
-    parser.add_argument('--template', type=argparse.FileType(mode='r'), default=default_template,
+    parser.add_argument('--template', type=argparse.FileType(mode='r', encoding='utf-8'), default=default_template,
                         help='The template file to use. Defaults to blast_html.html.jinja')
 
     args = parser.parse_args()