mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #682
This commit is contained in:
parent
dd3d69663b
commit
857455241a
@ -57,10 +57,15 @@ def compile_recipe(src):
|
|||||||
_tdir = path(PersistentTemporaryDirectory('_recipes'))
|
_tdir = path(PersistentTemporaryDirectory('_recipes'))
|
||||||
temp = _tdir/('recipe%d.py'%_crep)
|
temp = _tdir/('recipe%d.py'%_crep)
|
||||||
_crep += 1
|
_crep += 1
|
||||||
|
if not isinstance(src, unicode):
|
||||||
|
match = re.search(r'coding[:=]\s*([-\w.]+)', src[:200])
|
||||||
|
enc = match.group(1) if match else 'utf-8'
|
||||||
|
src = src.decode(enc)
|
||||||
f = open(temp, 'wb')
|
f = open(temp, 'wb')
|
||||||
|
src = '# coding=utf-8\n' + src
|
||||||
src = 'from %s.web.feeds.news import BasicNewsRecipe, AutomaticNewsRecipe\n'%__appname__ + src
|
src = 'from %s.web.feeds.news import BasicNewsRecipe, AutomaticNewsRecipe\n'%__appname__ + src
|
||||||
src = 'from %s.ebooks.lrf.web.profiles import DefaultProfile, FullContentProfile\n'%__appname__ + src
|
src = 'from %s.ebooks.lrf.web.profiles import DefaultProfile, FullContentProfile\n'%__appname__ + src
|
||||||
f.write(src.replace('from libprs500', 'from calibre'))
|
f.write(src.replace('from libprs500', 'from calibre').encode('utf-8'))
|
||||||
f.close()
|
f.close()
|
||||||
module = imp.find_module(temp.namebase, [temp.dirname()])
|
module = imp.find_module(temp.namebase, [temp.dirname()])
|
||||||
module = imp.load_module(temp.namebase, *module)
|
module = imp.load_module(temp.namebase, *module)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user