Edit book: Advertise support for importable filetypes in the OS file associations

This commit is contained in:
Kovid Goyal 2015-02-25 11:31:26 +05:30
parent 623dabed7f
commit ee6f9b86c3
2 changed files with 9 additions and 3 deletions

View File

@ -347,7 +347,9 @@ class ZshCompleter(object): # {{{
def do_ebook_edit(self, f):
from calibre.ebooks.oeb.polish.main import SUPPORTED
from calibre.ebooks.oeb.polish.import_book import IMPORTABLE
from calibre.gui2.tweak_book.main import option_parser
tweakable_fmts = SUPPORTED | IMPORTABLE
parser = option_parser()
opt_lines = []
for opt in parser.option_list:
@ -392,7 +394,7 @@ _ebook_edit() {
return 1
}
''' % (opt_lines, '|'.join(SUPPORTED)) + '\n\n').encode('utf-8'))
''' % (opt_lines, '|'.join(tweakable_fmts)) + '\n\n').encode('utf-8'))
def do_calibredb(self, f):
import calibre.library.cli as cli
@ -815,6 +817,7 @@ class PostInstall:
f.write('MimeType=%s;\n'%';'.join(mimetypes))
from calibre.ebooks.oeb.polish.main import SUPPORTED
from calibre.ebooks.oeb.polish.import_book import IMPORTABLE
f = open('calibre-lrfviewer.desktop', 'wb')
f.write(VIEWER)
f.close()
@ -823,7 +826,7 @@ class PostInstall:
write_mimetypes(f)
f = open('calibre-ebook-edit.desktop', 'wb')
f.write(ETWEAK)
mt = [guess_type('a.' + x.lower())[0] for x in SUPPORTED]
mt = {guess_type('a.' + x.lower())[0] for x in (SUPPORTED|IMPORTABLE)} - {None, 'application/octet-stream'}
f.write('MimeType=%s;\n'%';'.join(mt))
f.close()
f = open('calibre-gui.desktop', 'wb')

View File

@ -43,13 +43,16 @@ def default_programs():
def extensions(basename):
if basename == 'calibre.exe':
from calibre.ebooks import BOOK_EXTENSIONS
# We remove rar and zip as they interfere with 7-zip associations
# http://www.mobileread.com/forums/showthread.php?t=256459
return set(BOOK_EXTENSIONS) - {'rar', 'zip'}
if basename == 'ebook-viewer.exe':
from calibre.customize.ui import all_input_formats
return set(all_input_formats())
if basename == 'ebook-edit.exe':
from calibre.ebooks.oeb.polish.main import SUPPORTED
return set(SUPPORTED)
from calibre.ebooks.oeb.polish.import_book import IMPORTABLE
return SUPPORTED | IMPORTABLE
class NotAllowed(ValueError):
pass