def compare_format(self, book_id, fmt): db = self.current_db.new_api ofmt = fmt if fmt.startswith('ORIGINAL_'): fmt = fmt.partition('_')[-1] else: ofmt = 'ORIGINAL_' + fmt path1, path2 = db.format_abspath(book_id, ofmt), db.format_abspath(book_id, fmt) from calibre.gui2.tweak_book.diff.main import compare_books compare_books(path1, path2, parent=self, revert_msg=_('Restore %s') % ofmt, revert_callback=partial( self.iactions['Remove Books'].restore_format, book_id, ofmt), names=(ofmt, fmt))