Fix encoding for test page generation.
This commit is contained in:
parent
e6d35c6494
commit
cb3589bbd0
1 changed files with 12 additions and 9 deletions
|
@ -5,6 +5,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import cgi
|
import cgi
|
||||||
|
import codecs
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
||||||
from dosagelib.scraper import get_scrapers
|
from dosagelib.scraper import get_scrapers
|
||||||
from dosagelib.configuration import Version as DosageVersion
|
from dosagelib.configuration import Version as DosageVersion
|
||||||
|
@ -17,7 +18,7 @@ class Status:
|
||||||
error = "error"
|
error = "error"
|
||||||
orphan = "orphan"
|
orphan = "orphan"
|
||||||
|
|
||||||
indextemplate = """
|
indextemplate = u"""
|
||||||
---
|
---
|
||||||
extends: base.j2
|
extends: base.j2
|
||||||
title: Dosage comic list
|
title: Dosage comic list
|
||||||
|
@ -52,7 +53,7 @@ window.onload = function() {
|
||||||
{%% endblock content %%}
|
{%% endblock content %%}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
comic_template = """
|
comic_template = u"""
|
||||||
---
|
---
|
||||||
extends: base.j2
|
extends: base.j2
|
||||||
title: Dosage comic %(name)s
|
title: Dosage comic %(name)s
|
||||||
|
@ -90,12 +91,12 @@ title: Dosage comic %(name)s
|
||||||
{%% endblock content %%}
|
{%% endblock content %%}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
entrytemplate_url = """
|
entrytemplate_url = u"""
|
||||||
<a href="%(url)s" title="%(title)s" class="%(css)s">%(name)s</a>
|
<a href="%(url)s" title="%(title)s" class="%(css)s">%(name)s</a>
|
||||||
<div class="g-plusone" data-size="medium" data-annotation="bubble" data-href="%(url)s"></div>
|
<div class="g-plusone" data-size="medium" data-annotation="bubble" data-href="%(url)s"></div>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
entrytemplate_nourl = """
|
entrytemplate_nourl = u"""
|
||||||
<span title="%(title)s" class="%(css)s">%(name)s</span>
|
<span title="%(title)s" class="%(css)s">%(name)s</span>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -127,9 +128,11 @@ def get_testinfo(filename, modified):
|
||||||
orphaned.
|
orphaned.
|
||||||
@return: {name -> {
|
@return: {name -> {
|
||||||
"status": Status.*,
|
"status": Status.*,
|
||||||
"url": string or None,
|
"url": string,
|
||||||
"description": string or None,
|
"description": string,
|
||||||
"error": string or None,
|
"error": string or None,
|
||||||
|
"since": string,
|
||||||
|
"adult": bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
@ -168,7 +171,7 @@ def get_testentry(line):
|
||||||
entry = {
|
entry = {
|
||||||
"status": Status.ok if line.startswith(". ") else Status.error,
|
"status": Status.ok if line.startswith(". ") else Status.error,
|
||||||
"name": name,
|
"name": name,
|
||||||
"url": None,
|
"url": "",
|
||||||
"description": scraper.description,
|
"description": scraper.description,
|
||||||
"error": None,
|
"error": None,
|
||||||
"adult": scraper.adult,
|
"adult": scraper.adult,
|
||||||
|
@ -231,7 +234,7 @@ def write_html(testinfo, outputdir, modified):
|
||||||
date = strdate(modified)
|
date = strdate(modified)
|
||||||
args = {"date": quote(date), "content": content}
|
args = {"date": quote(date), "content": content}
|
||||||
fname = os.path.join(outputdir, "comic_index.html")
|
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)
|
fp.write(indextemplate % args)
|
||||||
comicdir = os.path.join(outputdir, "comics")
|
comicdir = os.path.join(outputdir, "comics")
|
||||||
if not os.path.isdir(comicdir):
|
if not os.path.isdir(comicdir):
|
||||||
|
@ -252,7 +255,7 @@ def write_html_comic(key, entry, outputdir, date):
|
||||||
"date": quote(date),
|
"date": quote(date),
|
||||||
}
|
}
|
||||||
fname = os.path.join(outputdir, key+".html")
|
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)
|
fp.write(comic_template % args)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue