mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix regression with loading custom recipes that use __future__ imports
This commit is contained in:
parent
77f2f9d76f
commit
5dd27c22e6
@ -86,11 +86,15 @@ def compile_recipe(src):
|
|||||||
match = re.search(r'coding[:=]\s*([-\w.]+)', src[:200])
|
match = re.search(r'coding[:=]\s*([-\w.]+)', src[:200])
|
||||||
enc = match.group(1) if match else 'utf-8'
|
enc = match.group(1) if match else 'utf-8'
|
||||||
src = src.decode(enc)
|
src = src.decode(enc)
|
||||||
|
src = re.sub(r'from __future__.*', '', src)
|
||||||
f = open(temp, 'wb')
|
f = open(temp, 'wb')
|
||||||
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
|
||||||
src = '# coding: utf-8\n' + src
|
src = '# coding: utf-8\n' + src
|
||||||
f.write(src.replace('from libprs500', 'from calibre').encode('utf-8'))
|
src = 'from __future__ import with_statement\n' + src
|
||||||
|
|
||||||
|
src = src.replace('from libprs500', 'from calibre').encode('utf-8')
|
||||||
|
f.write(src)
|
||||||
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