mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Entry point to easily run the default programs code using calibre-debug
This commit is contained in:
parent
f63fd2d005
commit
0e2de4306c
@ -79,6 +79,8 @@ Everything after the -- is passed to the script.
|
|||||||
parser.add_option('--diff', action='store_true', default=False, help=_(
|
parser.add_option('--diff', action='store_true', default=False, help=_(
|
||||||
'Run the calibre diff tool. For example:\n'
|
'Run the calibre diff tool. For example:\n'
|
||||||
'calibre-debug --diff file1 file2'))
|
'calibre-debug --diff file1 file2'))
|
||||||
|
parser.add_option('--default-programs', default=None, choices=['register', 'unregister'],
|
||||||
|
help=_('(Un)register calibre from Windows Default Programs.') + ' --default-programs=(register|unregister)')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -267,6 +269,15 @@ def main(args=sys.argv):
|
|||||||
elif opts.diff:
|
elif opts.diff:
|
||||||
from calibre.gui2.tweak_book.diff.main import main
|
from calibre.gui2.tweak_book.diff.main import main
|
||||||
main(['calibre-diff'] + args[1:])
|
main(['calibre-diff'] + args[1:])
|
||||||
|
elif opts.default_programs:
|
||||||
|
if not iswindows:
|
||||||
|
raise SystemExit('Can only be run on Microsoft Windows')
|
||||||
|
if opts.default_programs == 'register':
|
||||||
|
from calibre.utils.winreg.default_programs import register as func
|
||||||
|
else:
|
||||||
|
from calibre.utils.winreg.default_programs import unregister as func
|
||||||
|
print 'Running', func.__name__, '...'
|
||||||
|
func()
|
||||||
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}:
|
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'py', 'recipe'}:
|
||||||
run_script(args[1], args[2:])
|
run_script(args[1], args[2:])
|
||||||
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}:
|
elif len(args) >= 2 and args[1].rpartition('.')[-1] in {'mobi', 'azw', 'azw3', 'docx', 'odt'}:
|
||||||
@ -290,4 +301,3 @@ def main(args=sys.argv):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
||||||
|
@ -159,10 +159,3 @@ class Register(Thread):
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
prints('Registering with default programs...')
|
prints('Registering with default programs...')
|
||||||
register()
|
register()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
del sys.path[0]
|
|
||||||
func = (register if sys.argv[-1] == 'register' else unregister)
|
|
||||||
print ('Running', func.__name__, '...')
|
|
||||||
func()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user