Catalog generation: Fix error creating epub/mobi catalogs on non UTF-8 windows systems when the metadata contained non ASCII characters

This commit is contained in:
Kovid Goyal 2011-08-13 10:58:52 -06:00
parent 9cd8f008e2
commit 36b52e8b2d

View File

@ -10,7 +10,7 @@ from xml.sax.saxutils import escape
from lxml import etree
from types import StringType, UnicodeType
from calibre import prints, prepare_string_for_xml, strftime
from calibre import (prints, prepare_string_for_xml, strftime, force_unicode)
from calibre.constants import preferred_encoding, DEBUG
from calibre.customize import CatalogPlugin
from calibre.customize.conversion import OptionRecommendation, DummyReporter
@ -1083,15 +1083,11 @@ class EPUB_MOBI(CatalogPlugin):
self.__totalSteps += incremental_jobs
# Load section list templates
templates = []
with open(P('catalog/section_list_templates.py'), 'r') as f:
for line in f:
t = re.match("(by_.+_template)",line)
if t:
templates.append(t.group(1))
execfile(P('catalog/section_list_templates.py'), locals())
for t in templates:
setattr(self,t,eval(t))
templates = {}
execfile(P('catalog/section_list_templates.py'), templates)
for name, template in templates.iteritems():
if name.startswith('by_') and name.endswith('_template'):
setattr(self, name, force_unicode(template, 'utf-8'))
# Accessors
if True: