From cb3589bbd03f3fd1d6c8bf5f955a85a88152eb56 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 28 Jan 2013 06:53:27 +0100 Subject: [PATCH] Fix encoding for test page generation. --- scripts/mktestpage.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/mktestpage.py b/scripts/mktestpage.py index b2533e645..94a25bb0a 100755 --- a/scripts/mktestpage.py +++ b/scripts/mktestpage.py @@ -5,6 +5,7 @@ import sys import os import time import cgi +import codecs sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from dosagelib.scraper import get_scrapers from dosagelib.configuration import Version as DosageVersion @@ -17,7 +18,7 @@ class Status: error = "error" orphan = "orphan" -indextemplate = """ +indextemplate = u""" --- extends: base.j2 title: Dosage comic list @@ -52,7 +53,7 @@ window.onload = function() { {%% endblock content %%} """ -comic_template = """ +comic_template = u""" --- extends: base.j2 title: Dosage comic %(name)s @@ -90,12 +91,12 @@ title: Dosage comic %(name)s {%% endblock content %%} """ -entrytemplate_url = """ +entrytemplate_url = u""" %(name)s
""" -entrytemplate_nourl = """ +entrytemplate_nourl = u""" %(name)s """ @@ -127,9 +128,11 @@ def get_testinfo(filename, modified): orphaned. @return: {name -> { "status": Status.*, - "url": string or None, - "description": string or None, + "url": string, + "description": string, "error": string or None, + "since": string, + "adult": bool, } } """ @@ -168,7 +171,7 @@ def get_testentry(line): entry = { "status": Status.ok if line.startswith(". ") else Status.error, "name": name, - "url": None, + "url": "", "description": scraper.description, "error": None, "adult": scraper.adult, @@ -231,7 +234,7 @@ def write_html(testinfo, outputdir, modified): date = strdate(modified) args = {"date": quote(date), "content": content} fname = os.path.join(outputdir, "comic_index.html") - with open(fname, 'w') as fp: + with codecs.open(fname, 'w', 'utf-8') as fp: fp.write(indextemplate % args) comicdir = os.path.join(outputdir, "comics") if not os.path.isdir(comicdir): @@ -252,7 +255,7 @@ def write_html_comic(key, entry, outputdir, date): "date": quote(date), } fname = os.path.join(outputdir, key+".html") - with open(fname, 'w') as fp: + with codecs.open(fname, 'w', 'utf-8') as fp: fp.write(comic_template % args)