Mercurial > repos > jankanis > blast2html
changeset 50:bfc82a8aa3c9
unicodify python sources
author | Jan Kanis <jan.code@jankanis.nl> |
---|---|
date | Wed, 21 May 2014 18:17:03 +0200 |
parents | 85f757f4fcd5 |
children | b15a20c2372a |
files | blast2html.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/blast2html.py Tue May 20 16:19:05 2014 +0200 +++ b/blast2html.py Wed May 21 18:17:03 2014 +0200 @@ -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()