py3: fix unicode type

This commit is contained in:
Eli Schwartz 2019-05-13 13:41:35 -04:00 committed by Jim Miller
parent b4feb0153d
commit 93e93dee92
6 changed files with 11 additions and 9 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -7,6 +7,7 @@ __license__ = 'GPL v3'
__copyright__ = '2019, Jim Miller'
__docformat__ = 'restructuredtext en'
from .fanficfare.six import text_type as unicode
# import cProfile

View file

@ -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

View file

@ -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'<body[^>]*>(.*)</body>', 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 ''