From 49ba0a991bb2c486e4b7ba7ed9b47bb0c08b3d4f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 4 Apr 2014 01:04:53 +0530 Subject: [PATCH] DRY --- src/calibre/web/feeds/recipes/collection.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/calibre/web/feeds/recipes/collection.py b/src/calibre/web/feeds/recipes/collection.py index f7d9dd25f0..5cfbb7899c 100644 --- a/src/calibre/web/feeds/recipes/collection.py +++ b/src/calibre/web/feeds/recipes/collection.py @@ -140,23 +140,7 @@ def update_custom_recipe(id_, title, script): def add_custom_recipe(title, script): - from calibre.web.feeds.recipes import custom_recipes, \ - 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) + add_custom_recipes({title:script}) def add_custom_recipes(script_map): from calibre.web.feeds.recipes import custom_recipes, \