mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix bug that was preventing custom recipes from working correctly.
This commit is contained in:
parent
549c3991de
commit
cd3da5d10e
@ -70,8 +70,6 @@ class CustomNewMenuItem(QAction):
|
|||||||
QAction.__init__(self, QIcon(':/images/user_profile.svg'), title, parent)
|
QAction.__init__(self, QIcon(':/images/user_profile.svg'), title, parent)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.recipe = compile_recipe(script)
|
self.recipe = compile_recipe(script)
|
||||||
print self.recipe.title
|
|
||||||
print script
|
|
||||||
self.recipe.gui_recipe_script = script
|
self.recipe.gui_recipe_script = script
|
||||||
|
|
||||||
class CustomNewsMenu(QMenu):
|
class CustomNewsMenu(QMenu):
|
||||||
|
@ -44,6 +44,7 @@ def load_recipe(module, package='libprs500.web.feeds.recipes'):
|
|||||||
recipes = [load_recipe(i) for i in recipes]
|
recipes = [load_recipe(i) for i in recipes]
|
||||||
|
|
||||||
_tdir = None
|
_tdir = None
|
||||||
|
_crep = 0
|
||||||
def compile_recipe(src):
|
def compile_recipe(src):
|
||||||
'''
|
'''
|
||||||
Compile the code in src and return the first object that is a recipe or profile.
|
Compile the code in src and return the first object that is a recipe or profile.
|
||||||
@ -51,10 +52,11 @@ def compile_recipe(src):
|
|||||||
@type src: string
|
@type src: string
|
||||||
@return: Recipe/Profile class or None, if no such class was found in C{src}
|
@return: Recipe/Profile class or None, if no such class was found in C{src}
|
||||||
'''
|
'''
|
||||||
global _tdir
|
global _tdir, _crep
|
||||||
if _tdir is None:
|
if _tdir is None:
|
||||||
_tdir = path(PersistentTemporaryDirectory('_recipes'))
|
_tdir = path(PersistentTemporaryDirectory('_recipes'))
|
||||||
temp = _tdir/('recipe%d.py'%time.time())
|
temp = _tdir/('recipe%d.py'%_crep)
|
||||||
|
_crep += 1
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user