Allow importing calibre_plugins in the interactive debug shell

This commit is contained in:
Kovid Goyal 2018-08-29 09:21:24 +05:30
parent 8ccd911822
commit 23e2dbae65
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -230,12 +230,15 @@ def run_debug_gui(logpath):
calibre(['__CALIBRE_GUI_DEBUG__', logpath]) calibre(['__CALIBRE_GUI_DEBUG__', logpath])
def run_script(path, args): def load_user_plugins():
# Load all user defined plugins so the script can import from the # Load all user defined plugins so the script can import from the
# calibre_plugins namespace # calibre_plugins namespace
import calibre.customize.ui as dummy import calibre.customize.ui as dummy
dummy return dummy
def run_script(path, args):
load_user_plugins()
sys.argv = [path] + args sys.argv = [path] + args
ef = os.path.abspath(path) ef = os.path.abspath(path)
if '/src/calibre/' not in ef.replace(os.pathsep, '/'): if '/src/calibre/' not in ef.replace(os.pathsep, '/'):
@ -347,6 +350,7 @@ def main(args=sys.argv):
sys.path.insert(0, args[1]) sys.path.insert(0, args[1])
run_script(os.path.join(args[1], '__main__.py'), args[2:]) run_script(os.path.join(args[1], '__main__.py'), args[2:])
else: else:
load_user_plugins()
from calibre import ipython from calibre import ipython
ipython() ipython()