mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
DRY
This commit is contained in:
parent
3a193a24aa
commit
49ba0a991b
@ -140,23 +140,7 @@ def update_custom_recipe(id_, title, script):
|
|||||||
|
|
||||||
|
|
||||||
def add_custom_recipe(title, script):
|
def add_custom_recipe(title, script):
|
||||||
from calibre.web.feeds.recipes import custom_recipes, \
|
add_custom_recipes({title:script})
|
||||||
custom_recipe_filename
|
|
||||||
id_ = 1000
|
|
||||||
keys = tuple(map(int, custom_recipes.iterkeys()))
|
|
||||||
if keys:
|
|
||||||
id_ = max(keys)+1
|
|
||||||
id_ = str(id_)
|
|
||||||
bdir = os.path.dirname(custom_recipes.file_path)
|
|
||||||
|
|
||||||
fname = custom_recipe_filename(id_, title)
|
|
||||||
if isinstance(script, unicode):
|
|
||||||
script = script.encode('utf-8')
|
|
||||||
|
|
||||||
custom_recipes[id_] = (title, fname)
|
|
||||||
|
|
||||||
with open(os.path.join(bdir, fname), 'wb') as f:
|
|
||||||
f.write(script)
|
|
||||||
|
|
||||||
def add_custom_recipes(script_map):
|
def add_custom_recipes(script_map):
|
||||||
from calibre.web.feeds.recipes import custom_recipes, \
|
from calibre.web.feeds.recipes import custom_recipes, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user