[Blends-commit] [SCM] website branch, master, updated. ab2b34307f739ff45fd595996ce01e73b75b2e9d
Ole Streicher
ole at aip.de
Fri Mar 4 13:02:47 UTC 2016
The following commit has been merged in the master branch:
commit 8b9e50584425cd9466c50c7da3a5c69f0aa4508b
Author: Ole Streicher <ole at aip.de>
Date: Fri Mar 4 13:17:18 2016 +0100
Write html files in utf-8 encoding
diff --git a/webtools/blendsunicode.py b/webtools/blendsunicode.py
index f6e5a74..daeaf05 100644
--- a/webtools/blendsunicode.py
+++ b/webtools/blendsunicode.py
@@ -11,7 +11,7 @@ from sys import stderr
def to_unicode(value, encoding='utf-8'):
if isinstance(value, str):
try:
- return value.decode(encoding).encode('ascii', 'xmlcharrefreplace')
+ return value.decode(encoding)
except UnicodeDecodeError, err:
print >>stderr, "type(value) =", type(value), \
"; isinstance(value, str) =", isinstance(value, str), \
diff --git a/webtools/bugs.py b/webtools/bugs.py
index c0faa3b..1aa2d8f 100755
--- a/webtools/bugs.py
+++ b/webtools/bugs.py
@@ -11,6 +11,7 @@ SLOWQUERYREPORTLIMIT=30
debug=0
+import codecs
from sys import argv, stderr, exit
import os
import psycopg2
@@ -475,7 +476,7 @@ the right shows the tasks of %s.""" ) \
os.unlink(outputfile)
except: # simply continue if file does not exist
pass
- f = open(outputfile, 'w')
+ f = codecs.open(outputfile, 'w', 'utf-8')
print >> f, template.generate(**data).render('xhtml')
f.close()
SetFilePermissions(outputfile)
diff --git a/webtools/tasks.py b/webtools/tasks.py
index 7d0c34e..95ea358 100755
--- a/webtools/tasks.py
+++ b/webtools/tasks.py
@@ -192,7 +192,7 @@ for lang in languages:
os.unlink(outputfile)
except: # simply continue if file does not exist
pass
- f = open(outputfile, 'w')
+ f = codecs.open(outputfile, 'w', 'utf-8')
try:
print >> f, template.generate(**data).render('xhtml')
except UnicodeDecodeError, errtxt:
@@ -295,8 +295,8 @@ for lang in languages:
SetFilePermissions(outputfile+'_tmp')
# Really rude hack to get back '<' / '>' signs which actually shoul be
# in the output
- tmp = open(outputfile+'_tmp', "r")
- f = open(outputfile, "w")
+ tmp = codecs.open(outputfile+'_tmp', "r", 'utf-8')
+ f = codecs.open(outputfile, "w", 'utf-8')
for line in tmp.readlines():
# We had to mask ampersand ('&') from Genshi but even if the browser shows
# the correct character packages.debian.org gets confused - so turn it back here
@@ -317,7 +317,7 @@ for lang in languages:
os.unlink(outputfile)
except: # simply continue if file does not exist
pass
- f = open(outputfile, 'w')
+ f = codecs.open(outputfile, 'w', 'utf-8')
data['projectsintasks'] = []
for task in data['taskskeys']:
diff --git a/webtools/thermometer.py b/webtools/thermometer.py
index faa2f45..e243cb6 100755
--- a/webtools/thermometer.py
+++ b/webtools/thermometer.py
@@ -8,6 +8,7 @@ PORT=UDDPORT
DEFAULTPORT=5432
from sys import argv, stderr, exit
+import codecs
import os
import psycopg2
import json
@@ -413,7 +414,7 @@ the right shows the tasks of %s.""" ) \
except: # simply continue if file does not exist
pass
- f = open(outputfile, 'w')
+ f = codecs.open(outputfile, 'w', 'utf-8')
template = loader.load('thermometer.xhtml')
try:
print >> f, template.generate(**data).render('xhtml')
@@ -421,7 +422,7 @@ the right shows the tasks of %s.""" ) \
print >>stderr, "Problem creating thermometer.html.\tMessage: %s" % (str(err))
f.close()
SetFilePermissions(outputfile)
- f = open(uoutputfile, 'w')
+ f = codecs.open(uoutputfile, 'w', 'utf-8')
utemplate = loader.load('uthermometer.xhtml')
try:
print >> f, utemplate.generate(**data).render('xhtml')
--
Static and dynamic websites for Debian Pure Blends
More information about the Blends-commit
mailing list