diff --git a/calibre-plugin/common_utils.py b/calibre-plugin/common_utils.py index 2a52f6da..d4570530 100644 --- a/calibre-plugin/common_utils.py +++ b/calibre-plugin/common_utils.py @@ -28,6 +28,7 @@ from calibre.gui2.actions import menu_action_unique_name from calibre.gui2.keyboard import ShortcutConfig from calibre.utils.config import config_dir from calibre.utils.date import now, format_date, qt_to_dt, UNDEFINED_DATE +from .fanficfare.six import text_type as unicode # Global definition of our plugin name. Used for common functions that require this. plugin_name = None @@ -615,4 +616,3 @@ class PrefsViewerDialog(SizePersistedDialog): self.close() if d.do_restart: self.gui.quit(restart=True) - diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index aac53fff..73fc8868 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -44,6 +44,7 @@ else: from calibre.gui2 import dynamic, info_dialog, question_dialog from calibre.gui2.ui import get_gui from calibre.gui2.complete2 import EditWithComplete +from .fanficfare.six import text_type as unicode try: from calibre.ebooks.covers import generate_cover as cal_generate_cover @@ -1667,5 +1668,3 @@ class ImapTab(QWidget): self.l.addWidget(label,row,0,1,-1,Qt.AlignTop) self.l.setRowStretch(row,1) row+=1 - - diff --git a/calibre-plugin/dialogs.py b/calibre-plugin/dialogs.py index 076a1866..08fae875 100644 --- a/calibre-plugin/dialogs.py +++ b/calibre-plugin/dialogs.py @@ -55,6 +55,7 @@ from calibre.gui2 import gprefs show_download_options = 'fff:add new/update dialogs:show_download_options' from calibre.gui2.dialogs.confirm_delete import confirm from calibre.gui2.complete2 import EditWithComplete +from .fanficfare.six import text_type as unicode # pulls in translation files for _() strings try: @@ -707,7 +708,7 @@ class _LoopProgressDialog(QProgressDialog): book['good']=False book['status']=_("Error") book['comment']=unicode(e) - logger.error("Exception: %s:%s"%(book,unicode(e)),exc_info=True) + logger.error("Exception: %s:%s"%(book,book['comment']),exc_info=True) self.updateStatus() self.i += 1 diff --git a/calibre-plugin/fff_plugin.py b/calibre-plugin/fff_plugin.py index 33b487dd..4a9e42b2 100644 --- a/calibre-plugin/fff_plugin.py +++ b/calibre-plugin/fff_plugin.py @@ -7,6 +7,7 @@ __license__ = 'GPL v3' __copyright__ = '2019, Jim Miller' __docformat__ = 'restructuredtext en' +from .fanficfare.six import text_type as unicode # import cProfile diff --git a/calibre-plugin/jobs.py b/calibre-plugin/jobs.py index e181dff8..5dab4413 100644 --- a/calibre-plugin/jobs.py +++ b/calibre-plugin/jobs.py @@ -19,6 +19,7 @@ from calibre.utils.ipc.server import Server from calibre.utils.ipc.job import ParallelJob from calibre.constants import numeric_version as calibre_version from calibre.utils.date import local_tz +from .fanficfare.six import text_type as unicode from calibre_plugins.fanficfare_plugin.wordcount import get_word_count from calibre_plugins.fanficfare_plugin.prefs import (SAVE_YES, SAVE_YES_UNLESS_SITE) @@ -341,7 +342,7 @@ def do_download_for_worker(book,options,merge,notification=lambda x,y:x): book['comment']=unicode(e) book['icon']='dialog_error.png' book['status'] = _('Error') - logger.info("Exception: %s:%s"%(book,unicode(e)),exc_info=True) + logger.info("Exception: %s:%s"%(book,book['comment']),exc_info=True) #time.sleep(10) return book diff --git a/calibre-plugin/wordcount.py b/calibre-plugin/wordcount.py index 5ec46b08..acd64f6a 100644 --- a/calibre-plugin/wordcount.py +++ b/calibre-plugin/wordcount.py @@ -18,6 +18,7 @@ logger = logging.getLogger(__name__) import re from calibre.ebooks.oeb.iterator import EbookIterator +from .fanficfare.six import text_type as unicode RE_HTML_BODY = re.compile(u']*>(.*)', re.UNICODE | re.DOTALL | re.IGNORECASE) RE_STRIP_MARKUP = re.compile(u'<[^>]+>', re.UNICODE) @@ -28,7 +29,7 @@ def get_word_count(book_path): Estimate a word count ''' from calibre.utils.localization import get_lang - + iterator = _open_epub_file(book_path) lang = iterator.opf.language @@ -52,7 +53,7 @@ def _get_epub_standard_word_count(iterator, lang='en'): ''' book_text = _read_epub_contents(iterator, strip_html=True) - + try: from calibre.spell.break_iterator import count_words wordcount = count_words(book_text, lang) @@ -67,7 +68,7 @@ def _get_epub_standard_word_count(iterator, lang='en'): wordcount = get_wordcount_obj(book_text) wordcount = wordcount.words logger.debug('\tWord count - old method:%s'%wordcount) - + return wordcount def _read_epub_contents(iterator, strip_html=False): @@ -92,4 +93,3 @@ def _extract_body_text(data): if body: return RE_STRIP_MARKUP.sub('', body[0]).replace('.','. ') return '' -