From bb70c07c337d2c93bdb74cbe70c0e65fa4d3af6b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 10 Jun 2011 10:13:22 -0600 Subject: [PATCH] Fix plugins not working in calibre portable --- src/calibre/customize/ui.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/calibre/customize/ui.py b/src/calibre/customize/ui.py index 0a21b0b42e..24b720ec3e 100644 --- a/src/calibre/customize/ui.py +++ b/src/calibre/customize/ui.py @@ -355,11 +355,17 @@ def remove_plugin(plugin_or_name): name = getattr(plugin_or_name, 'name', plugin_or_name) plugins = config['plugins'] removed = False - if name in plugins.keys(): + if name in plugins: removed = True - zfp = plugins[name] - if os.path.exists(zfp): - os.remove(zfp) + try: + zfp = os.path.join(plugin_dir, name+'.zip') + if os.path.exists(zfp): + os.remove(zfp) + zfp = plugins[name] + if os.path.exists(zfp): + os.remove(zfp) + except: + pass plugins.pop(name) config['plugins'] = plugins initialize_plugins() @@ -495,8 +501,15 @@ def initialize_plugins(): builtin_names] for p in conflicts: remove_plugin(p) - for zfp in list(config['plugins'].itervalues()) + builtin_plugins: + external_plugins = config['plugins'] + for zfp in list(external_plugins) + builtin_plugins: try: + if not isinstance(zfp, type): + # We have a plugin name + pname = zfp + zfp = os.path.join(plugin_dir, zfp+'.zip') + if not os.path.exists(zfp): + zfp = external_plugins[pname] try: plugin = load_plugin(zfp) if not isinstance(zfp, type) else zfp except PluginNotFound: