def do_book_action(self): if self.wasCanceled(): return self.do_close() if self.i >= self.total_count: return self.do_close() book = self.indices[self.i] self.i += 1 # Get the title and build the caption and label text from the string parameters provided if self.db_type == 'calibre': dtitle = book[0].title elif self.db_type == 'kobo': dtitle = book.title self.setWindowTitle('{0} {1} {2} ({3} {4} failures)...'.format(self.action_type[0], self.total_count, self.status_msg_type, len(self.failures), self.action_type[1])) self.setLabelText('{0}: {1}'.format(self.action_type[0], dtitle)) # If a calibre db, feed the calibre bookmap to action.py's add_new_books method if self.db_type == 'calibre': if self.callback_fn([book]): self.successes.append(book) else: self.failures.append(book) # If a kobo db, feed the index to the kobo book to action.py's get_decrypted_kobo_books method elif self.db_type == 'kobo': if self.callback_fn(book): debug_print("DecryptAddProgressDialog::do_book_action - decrypted book: '%s'" % dtitle) self.successes.append(book) else: debug_print("DecryptAddProgressDialog::do_book_action - book decryption failed: '%s'" % dtitle) self.failures.append(book) self.setValue(self.i) # Lather, rinse, repeat. QTimer.singleShot(0, self.do_book_action)
def get_books(self): # debug_print("BookListTableWidget:get_books - self.books:", self.books) books = [] if len(self.selectedItems()): for row in range(self.rowCount()): # debug_print("BookListTableWidget:get_books - row:", row) if self.item(row, 0).isSelected(): book_num = convert_qvariant(self.item(row, 4).data(Qt.DisplayRole)) debug_print("BookListTableWidget:get_books - book_num:", book_num) book = self.books[book_num] debug_print("BookListTableWidget:get_books - book:", book.title) books.append(book) return books
def get_books(self): # debug_print("BookListTableWidget:get_books - self.books:", self.books) books = [] if len(self.selectedItems()): for row in range(self.rowCount()): # debug_print("BookListTableWidget:get_books - row:", row) if self.item(row, 0).isSelected(): book_num = convert_qvariant( self.item(row, 4).data(Qt.DisplayRole)) debug_print("BookListTableWidget:get_books - book_num:", book_num) book = self.books[book_num] debug_print("BookListTableWidget:get_books - book:", book.title) books.append(book) return books
def do_book_action(self): if self.wasCanceled(): return self.do_close() if self.i >= self.total_count: return self.do_close() book = self.indices[self.i] self.i += 1 # Get the title and build the caption and label text from the string parameters provided if self.db_type == 'calibre': dtitle = book[0].title elif self.db_type == 'kobo': dtitle = book.title self.setWindowTitle('{0} {1} {2} ({3} {4} failures)...'.format( self.action_type[0], self.total_count, self.status_msg_type, len(self.failures), self.action_type[1])) self.setLabelText('{0}: {1}'.format(self.action_type[0], dtitle)) # If a calibre db, feed the calibre bookmap to action.py's add_new_books method if self.db_type == 'calibre': if self.callback_fn([book]): self.successes.append(book) else: self.failures.append(book) # If a kobo db, feed the index to the kobo book to action.py's get_decrypted_kobo_books method elif self.db_type == 'kobo': if self.callback_fn(book): debug_print( "DecryptAddProgressDialog::do_book_action - decrypted book: '%s'" % dtitle) self.successes.append(book) else: debug_print( "DecryptAddProgressDialog::do_book_action - book decryption failed: '%s'" % dtitle) self.failures.append(book) self.setValue(self.i) # Lather, rinse, repeat. QTimer.singleShot(0, self.do_book_action)
def launchObok(self): ''' Main processing/distribution method ''' self.count = 0 self.books_to_add = [] self.formats_to_add = [] self.add_books_cancelled = False self.decryption_errors = [] self.userkeys = [] self.duplicate_book_list = [] self.no_home_for_book = [] self.ids_of_new_books = [] self.successful_format_adds =[] self.add_formats_cancelled = False self.tdir = PersistentTemporaryDirectory('_obok', prefix='') self.db = self.gui.current_db.new_api self.current_idx = self.gui.library_view.currentIndex() print ('Running {}'.format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) # # search for connected device in case serials are saved tmpserials = cfg['kobo_serials'] device_path = None try: device = self.parent().device_manager.connected_device if (device): device_path = device._main_prefix debug_print("get_device_settings - device_path=", device_path) else: debug_print("didn't find device") except: debug_print("Exception getting device path. Probably not an E-Ink Kobo device") # Get the Kobo Library object (obok v3.01) self.library = KoboLibrary(tmpserials, device_path, cfg['kobo_directory']) debug_print ("got kobodir %s" % self.library.kobodir) if (self.library.kobodir == ''): # linux and no device connected, but could be extended # to the case where on Windows/Mac the prog is not installed msg = _('<p>Could not find Kobo Library\n<p>Windows/Mac: do you have Kobo Desktop installed?\n<p>Windows/Mac/Linux: In case you have an Kobo eInk device, connect the device.') showErrorDlg(msg, None) return # Get a list of Kobo titles books = self.build_book_list() if len(books) < 1: msg = _('<p>No books found in Kobo Library\nAre you sure it\'s installed\configured\synchronized?') showErrorDlg(msg, None) return # Check to see if a key can be retrieved using the legacy obok method. legacy_key = legacy_obok().get_legacy_cookie_id if legacy_key is not None: print (_('Legacy key found: '), legacy_key.encode('hex_codec')) self.userkeys.append(legacy_key) # Add userkeys found through the normal obok method to the list to try. try: candidate_keys = self.library.userkeys except: print (_('Trouble retrieving keys with newer obok method.')) traceback.print_exc() else: if len(candidate_keys): self.userkeys.extend(candidate_keys) print (_('Found {0} possible keys to try.').format(len(self.userkeys))) if not len(self.userkeys): msg = _('<p>No userkeys found to decrypt books with. No point in proceeding.') showErrorDlg(msg, None) return # Launch the Dialog so the user can select titles. dlg = SelectionDialog(self.gui, self, books) if dlg.exec_(): books_to_import = dlg.getBooks() self.count = len(books_to_import) debug_print("InterfacePluginAction::launchObok - number of books to decrypt: %d" % self.count) # Feed the titles, the callback function (self.get_decrypted_kobo_books) # and the Kobo library object to the ProgressDialog dispatcher. d = DecryptAddProgressDialog(self.gui, books_to_import, self.get_decrypted_kobo_books, self.library, 'kobo', status_msg_type='Kobo books', action_type=('Decrypting', 'Decryption')) # Canceled the decryption process; clean up and exit. if d.wasCanceled(): print (_('{} - Decryption canceled by user.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.library.close() remove_dir(self.tdir) return else: # Canceled the selection process; clean up and exit. self.library.close() remove_dir(self.tdir) return # Close Kobo Library object self.library.close() # If we have decrypted books to work with, feed the list of decrypted books details # and the callback function (self.add_new_books) to the ProgressDialog dispatcher. if len(self.books_to_add): d = DecryptAddProgressDialog(self.gui, self.books_to_add, self.add_new_books, self.db, 'calibre', status_msg_type='new calibre books', action_type=('Adding','Addition')) # Canceled the "add new books to calibre" process; # show the results of what got added before cancellation. if d.wasCanceled(): print (_('{} - "Add books" canceled by user.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.add_books_cancelled = True print (_('{} - wrapping up results.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.wrap_up_results() remove_dir(self.tdir) return # If books couldn't be added because of duplicate entries in calibre, ask # if we should try to add the decrypted epubs to existing calibre library entries. if len(self.duplicate_book_list): if cfg['finding_homes_for_formats'] == 'Always': self.process_epub_formats() elif cfg['finding_homes_for_formats'] == 'Never': self.no_home_for_book.extend([entry[0] for entry in self.duplicate_book_list]) else: if self.ask_about_inserting_epubs(): # Find homes for the epub decrypted formats in existing calibre library entries. self.process_epub_formats() else: print (_('{} - User opted not to try to insert EPUB formats').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.no_home_for_book.extend([entry[0] for entry in self.duplicate_book_list]) print (_('{} - wrapping up results.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.wrap_up_results() remove_dir(self.tdir) return
AddEpubFormatsProgressDialog, ResultsSummaryDialog) from calibre_plugins.obok_dedrm.config import plugin_prefs as cfg from calibre_plugins.obok_dedrm.__init__ import (PLUGIN_NAME, PLUGIN_SAFE_NAME, PLUGIN_VERSION, PLUGIN_DESCRIPTION, HELPFILE_NAME) from calibre_plugins.obok_dedrm.utilities import ( get_icon, set_plugin_icon_resources, showErrorDlg, format_plural, debug_print ) from calibre_plugins.obok_dedrm.obok.obok import KoboLibrary from calibre_plugins.obok_dedrm.obok.legacy_obok import legacy_obok PLUGIN_ICONS = ['images/obok.png'] try: debug_print("obok::action_err.py - loading translations") load_translations() except NameError: debug_print("obok::action_err.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class InterfacePluginAction(InterfaceAction): name = PLUGIN_NAME action_spec = (PLUGIN_NAME, None, _(PLUGIN_DESCRIPTION), None) popup_type = QToolButton.InstantPopup action_type = 'current' def genesis(self): icon_resources = self.load_resources(PLUGIN_ICONS) set_plugin_icon_resources(PLUGIN_NAME, icon_resources)
except ImportError: from PyQt4.QtGui import (QListWidget, QAbstractItemView) from calibre.gui2 import gprefs, warning_dialog, error_dialog from calibre.gui2.dialogs.message_box import MessageBox #from calibre.ptempfile import remove_dir from calibre_plugins.obok_dedrm.utilities import (SizePersistedDialog, ImageTitleLayout, showErrorDlg, get_icon, convert_qvariant, debug_print ) from calibre_plugins.obok_dedrm.__init__ import (PLUGIN_NAME, PLUGIN_SAFE_NAME, PLUGIN_VERSION, PLUGIN_DESCRIPTION) try: debug_print("obok::dialogs.py - loading translations") load_translations() except NameError: debug_print("obok::dialogs.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class SelectionDialog(SizePersistedDialog): ''' Dialog to select the kobo books to decrypt ''' def __init__(self, gui, interface_action, books): ''' :param gui: Parent gui :param interface_action: InterfaceActionObject (InterfacePluginAction class from action.py) :param books: list of Kobo book '''
def launchObok(self): ''' Main processing/distribution method ''' self.count = 0 self.books_to_add = [] self.formats_to_add = [] self.add_books_cancelled = False self.decryption_errors = [] self.userkeys = [] self.duplicate_book_list = [] self.no_home_for_book = [] self.ids_of_new_books = [] self.successful_format_adds =[] self.add_formats_cancelled = False self.tdir = PersistentTemporaryDirectory('_obok', prefix='') self.db = self.gui.current_db.new_api self.current_idx = self.gui.library_view.currentIndex() print ('Running {}'.format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) # # search for connected device in case serials are saved tmpserials = cfg['kobo_serials'] device = self.parent().device_manager.connected_device device_path = None if (device): device_path = device._main_prefix debug_print("get_device_settings - device_path=", device_path) # get serial from device_path/.adobe-digital-editions/device.xml if can_parse_xml: devicexml = os.path.join(device_path, '.adobe-digital-editions', 'device.xml') debug_print("trying to load %s" % devicexml) if (os.path.exists(devicexml)): debug_print("trying to parse %s" % devicexml) xmltree = ET.parse(devicexml) for node in xmltree.iter(): if "deviceSerial" in node.tag: serial = node.text debug_print ("found serial %s" % serial) tmpserials.append(serial) break else: debug_print("didn't find device") # Get the Kobo Library object (obok v3.01) self.library = KoboLibrary(tmpserials, device_path) debug_print ("got kobodir %s" % self.library.kobodir) if (self.library.kobodir == ''): # linux and no device connected, but could be extended # to the case where on Windows/Mac the prog is not installed msg = _('<p>Could not find Kobo Library\n<p>Windows/Mac: do you have Kobo Desktop installed?\n<p>Windows/Mac/Linux: In case you have an Kobo eInk device, connect the device.') showErrorDlg(msg, None) return # Get a list of Kobo titles books = self.build_book_list() if len(books) < 1: msg = _('<p>No books found in Kobo Library\nAre you sure it\'s installed\configured\synchronized?') showErrorDlg(msg, None) return # Check to see if a key can be retrieved using the legacy obok method. legacy_key = legacy_obok().get_legacy_cookie_id if legacy_key is not None: print (_('Legacy key found: '), legacy_key.encode('hex_codec')) self.userkeys.append(legacy_key) # Add userkeys found through the normal obok method to the list to try. try: candidate_keys = self.library.userkeys except: print (_('Trouble retrieving keys with newer obok method.')) traceback.print_exc() else: if len(candidate_keys): self.userkeys.extend(candidate_keys) print (_('Found {0} possible keys to try.').format(len(self.userkeys))) if not len(self.userkeys): msg = _('<p>No userkeys found to decrypt books with. No point in proceeding.') showErrorDlg(msg, None) return # Launch the Dialog so the user can select titles. dlg = SelectionDialog(self.gui, self, books) if dlg.exec_(): books_to_import = dlg.getBooks() self.count = len(books_to_import) debug_print("InterfacePluginAction::launchObok - number of books to decrypt: %d" % self.count) # Feed the titles, the callback function (self.get_decrypted_kobo_books) # and the Kobo library object to the ProgressDialog dispatcher. d = DecryptAddProgressDialog(self.gui, books_to_import, self.get_decrypted_kobo_books, self.library, 'kobo', status_msg_type='Kobo books', action_type=('Decrypting', 'Decryption')) # Canceled the decryption process; clean up and exit. if d.wasCanceled(): print (_('{} - Decryption canceled by user.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.library.close() remove_dir(self.tdir) return else: # Canceled the selection process; clean up and exit. self.library.close() remove_dir(self.tdir) return # Close Kobo Library object self.library.close() # If we have decrypted books to work with, feed the list of decrypted books details # and the callback function (self.add_new_books) to the ProgressDialog dispatcher. if len(self.books_to_add): d = DecryptAddProgressDialog(self.gui, self.books_to_add, self.add_new_books, self.db, 'calibre', status_msg_type='new calibre books', action_type=('Adding','Addition')) # Canceled the "add new books to calibre" process; # show the results of what got added before cancellation. if d.wasCanceled(): print (_('{} - "Add books" canceled by user.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.add_books_cancelled = True print (_('{} - wrapping up results.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.wrap_up_results() remove_dir(self.tdir) return # If books couldn't be added because of duplicate entries in calibre, ask # if we should try to add the decrypted epubs to existing calibre library entries. if len(self.duplicate_book_list): if cfg['finding_homes_for_formats'] == 'Always': self.process_epub_formats() elif cfg['finding_homes_for_formats'] == 'Never': self.no_home_for_book.extend([entry[0] for entry in self.duplicate_book_list]) else: if self.ask_about_inserting_epubs(): # Find homes for the epub decrypted formats in existing calibre library entries. self.process_epub_formats() else: print (_('{} - User opted not to try to insert EPUB formats').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.no_home_for_book.extend([entry[0] for entry in self.duplicate_book_list]) print (_('{} - wrapping up results.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.wrap_up_results() remove_dir(self.tdir) return
AddEpubFormatsProgressDialog, ResultsSummaryDialog) from calibre_plugins.obok_dedrm.config import plugin_prefs as cfg from calibre_plugins.obok_dedrm.__init__ import (PLUGIN_NAME, PLUGIN_SAFE_NAME, PLUGIN_VERSION, PLUGIN_DESCRIPTION, HELPFILE_NAME) from calibre_plugins.obok_dedrm.utilities import ( get_icon, set_plugin_icon_resources, showErrorDlg, format_plural, debug_print ) from calibre_plugins.obok_dedrm.obok.obok import KoboLibrary from calibre_plugins.obok_dedrm.obok.legacy_obok import legacy_obok can_parse_xml = True try: from xml.etree import ElementTree as ET debug_print("using xml.etree for xml parsing") except ImportError: can_parse_xml = False debug_print("Cannot find xml.etree, disabling extraction of serial numbers") PLUGIN_ICONS = ['images/obok.png'] try: debug_print("obok::action_err.py - loading translations") load_translations() except NameError: debug_print("obok::action_err.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class InterfacePluginAction(InterfaceAction):
def launchObok(self): ''' Main processing/distribution method ''' self.count = 0 self.books_to_add = [] self.formats_to_add = [] self.add_books_cancelled = False self.decryption_errors = [] self.userkeys = [] self.duplicate_book_list = [] self.no_home_for_book = [] self.ids_of_new_books = [] self.successful_format_adds =[] self.add_formats_cancelled = False self.tdir = PersistentTemporaryDirectory('_obok', prefix='') self.db = self.gui.current_db.new_api self.current_idx = self.gui.library_view.currentIndex() print ('Running {}'.format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) # Get the Kobo Library object (obok v3.01) self.library = KoboLibrary() # Get a list of Kobo titles books = self.build_book_list() if len(books) < 1: msg = _('<p>No books found in Kobo Library\nAre you sure it\'s installed\configured\synchronized?') showErrorDlg(msg, None) return # Check to see if a key can be retrieved using the legacy obok method. legacy_key = legacy_obok().get_legacy_cookie_id if legacy_key is not None: print (_('Legacy key found: '), legacy_key.encode('hex_codec')) self.userkeys.append(legacy_key) # Add userkeys found through the normal obok method to the list to try. try: candidate_keys = self.library.userkeys except: print (_('Trouble retrieving keys with newer obok method.')) traceback.print_exc() else: if len(candidate_keys): self.userkeys.extend(candidate_keys) print (_('Found {0} possible keys to try.').format(len(self.userkeys))) if not len(self.userkeys): msg = _('<p>No userkeys found to decrypt books with. No point in proceeding.') showErrorDlg(msg, None) return # Launch the Dialog so the user can select titles. dlg = SelectionDialog(self.gui, self, books) if dlg.exec_(): books_to_import = dlg.getBooks() self.count = len(books_to_import) debug_print("InterfacePluginAction::launchObok - number of books to decrypt: %d" % self.count) # Feed the titles, the callback function (self.get_decrypted_kobo_books) # and the Kobo library object to the ProgressDialog dispatcher. d = DecryptAddProgressDialog(self.gui, books_to_import, self.get_decrypted_kobo_books, self.library, 'kobo', status_msg_type='Kobo books', action_type=('Decrypting', 'Decryption')) # Canceled the decryption process; clean up and exit. if d.wasCanceled(): print (_('{} - Decryption canceled by user.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.library.close() remove_dir(self.tdir) return else: # Canceled the selection process; clean up and exit. self.library.close() remove_dir(self.tdir) return # Close Kobo Library object self.library.close() # If we have decrypted books to work with, feed the list of decrypted books details # and the callback function (self.add_new_books) to the ProgressDialog dispatcher. if len(self.books_to_add): d = DecryptAddProgressDialog(self.gui, self.books_to_add, self.add_new_books, self.db, 'calibre', status_msg_type='new calibre books', action_type=('Adding','Addition')) # Canceled the "add new books to calibre" process; # show the results of what got added before cancellation. if d.wasCanceled(): print (_('{} - "Add books" canceled by user.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.add_books_cancelled = True print (_('{} - wrapping up results.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.wrap_up_results() remove_dir(self.tdir) return # If books couldn't be added because of duplicate entries in calibre, ask # if we should try to add the decrypted epubs to existing calibre library entries. if len(self.duplicate_book_list): if cfg['finding_homes_for_formats'] == 'Always': self.process_epub_formats() elif cfg['finding_homes_for_formats'] == 'Never': self.no_home_for_book.extend([entry[0] for entry in self.duplicate_book_list]) else: if self.ask_about_inserting_epubs(): # Find homes for the epub decrypted formats in existing calibre library entries. self.process_epub_formats() else: print (_('{} - User opted not to try to insert EPUB formats').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.no_home_for_book.extend([entry[0] for entry in self.duplicate_book_list]) print (_('{} - wrapping up results.').format(PLUGIN_NAME + ' v' + PLUGIN_VERSION)) self.wrap_up_results() remove_dir(self.tdir) return
AddEpubFormatsProgressDialog, ResultsSummaryDialog) from calibre_plugins.obok_dedrm.config import plugin_prefs as cfg from calibre_plugins.obok_dedrm.__init__ import (PLUGIN_NAME, PLUGIN_SAFE_NAME, PLUGIN_VERSION, PLUGIN_DESCRIPTION, HELPFILE_NAME) from calibre_plugins.obok_dedrm.utilities import ( get_icon, set_plugin_icon_resources, showErrorDlg, format_plural, debug_print ) from calibre_plugins.obok_dedrm.obok.obok import KoboLibrary from calibre_plugins.obok_dedrm.obok.legacy_obok import legacy_obok PLUGIN_ICONS = ['images/obok.png'] try: debug_print("obok::action_err.py - loading translations") load_translations() except NameError: debug_print("obok::action_err.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class InterfacePluginAction(InterfaceAction): name = PLUGIN_NAME action_spec = (PLUGIN_NAME, None, _(PLUGIN_DESCRIPTION), None) popup_type = QToolButton.InstantPopup action_type = 'current' def genesis(self): icon_resources = self.load_resources(PLUGIN_ICONS) set_plugin_icon_resources(PLUGIN_NAME, icon_resources)
QIcon, QHBoxLayout, QComboBox, QListWidgetItem, QFileDialog) from PyQt5 import Qt as QtGui from calibre.gui2 import (error_dialog, question_dialog, info_dialog, open_url) from calibre.utils.config import JSONConfig, config_dir plugin_prefs = JSONConfig('plugins/obok_dedrm_prefs') plugin_prefs.defaults['finding_homes_for_formats'] = 'Ask' plugin_prefs.defaults['kobo_serials'] = [] plugin_prefs.defaults['kobo_directory'] = u'' from calibre_plugins.obok_dedrm.__init__ import PLUGIN_NAME, PLUGIN_VERSION from calibre_plugins.obok_dedrm.utilities import (debug_print) try: debug_print("obok::config.py - loading translations") load_translations() except NameError: debug_print("obok::config.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class ConfigWidget(QWidget): def __init__(self, plugin_action): QWidget.__init__(self) self.plugin_action = plugin_action layout = QVBoxLayout(self) self.setLayout(layout) # copy of preferences self.tmpserials = plugin_prefs['kobo_serials']
from __future__ import unicode_literals, division, absolute_import, print_function try: from PyQt5.Qt import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QComboBox except ImportError: from PyQt4.Qt import QWidget, QLabel, QVBoxLayout, QHBoxLayout, QComboBox from calibre.utils.config import JSONConfig, config_dir plugin_prefs = JSONConfig("plugins/obok_dedrm_prefs") plugin_prefs.defaults["finding_homes_for_formats"] = "Ask" from calibre_plugins.obok_dedrm.utilities import debug_print try: debug_print("obok::config.py - loading translations") load_translations() except NameError: debug_print("obok::config.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class ConfigWidget(QWidget): def __init__(self, plugin_action): QWidget.__init__(self) self.plugin_action = plugin_action layout = QVBoxLayout(self) self.setLayout(layout) combo_label = QLabel(_("When should Obok try to insert EPUBs into existing calibre entries?"), self) layout.addWidget(combo_label)
from calibre.gui2 import gprefs, warning_dialog, error_dialog from calibre.gui2.dialogs.message_box import MessageBox #from calibre.ptempfile import remove_dir from calibre_plugins.obok_dedrm.utilities import (SizePersistedDialog, ImageTitleLayout, showErrorDlg, get_icon, convert_qvariant, debug_print) from calibre_plugins.obok_dedrm.__init__ import (PLUGIN_NAME, PLUGIN_SAFE_NAME, PLUGIN_VERSION, PLUGIN_DESCRIPTION) try: debug_print("obok::dialogs.py - loading translations") load_translations() except NameError: debug_print("obok::dialogs.py - exception when loading translations") pass # load_translations() added in calibre 1.9 class SelectionDialog(SizePersistedDialog): ''' Dialog to select the kobo books to decrypt ''' def __init__(self, gui, interface_action, books): ''' :param gui: Parent gui :param interface_action: InterfaceActionObject (InterfacePluginAction class from action.py) :param books: list of Kobo book
from calibre_plugins.obok_dedrm.__init__ import (PLUGIN_NAME, PLUGIN_SAFE_NAME, PLUGIN_VERSION, PLUGIN_DESCRIPTION, HELPFILE_NAME) from calibre_plugins.obok_dedrm.utilities import (get_icon, set_plugin_icon_resources, showErrorDlg, format_plural, debug_print) from calibre_plugins.obok_dedrm.obok.obok import KoboLibrary from calibre_plugins.obok_dedrm.obok.legacy_obok import legacy_obok can_parse_xml = True try: from xml.etree import ElementTree as ET debug_print("using xml.etree for xml parsing") except ImportError: can_parse_xml = False debug_print( "Cannot find xml.etree, disabling extraction of serial numbers") PLUGIN_ICONS = ['images/obok.png'] try: debug_print("obok::action_err.py - loading translations") load_translations() except NameError: debug_print("obok::action_err.py - exception when loading translations") pass # load_translations() added in calibre 1.9