mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-06 08:52:55 +01:00
py3: fix unicode type
This commit is contained in:
parent
b4feb0153d
commit
93e93dee92
6 changed files with 11 additions and 9 deletions
|
|
@ -28,6 +28,7 @@ from calibre.gui2.actions import menu_action_unique_name
|
||||||
from calibre.gui2.keyboard import ShortcutConfig
|
from calibre.gui2.keyboard import ShortcutConfig
|
||||||
from calibre.utils.config import config_dir
|
from calibre.utils.config import config_dir
|
||||||
from calibre.utils.date import now, format_date, qt_to_dt, UNDEFINED_DATE
|
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.
|
# Global definition of our plugin name. Used for common functions that require this.
|
||||||
plugin_name = None
|
plugin_name = None
|
||||||
|
|
@ -615,4 +616,3 @@ class PrefsViewerDialog(SizePersistedDialog):
|
||||||
self.close()
|
self.close()
|
||||||
if d.do_restart:
|
if d.do_restart:
|
||||||
self.gui.quit(restart=True)
|
self.gui.quit(restart=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ else:
|
||||||
from calibre.gui2 import dynamic, info_dialog, question_dialog
|
from calibre.gui2 import dynamic, info_dialog, question_dialog
|
||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
from calibre.gui2.complete2 import EditWithComplete
|
from calibre.gui2.complete2 import EditWithComplete
|
||||||
|
from .fanficfare.six import text_type as unicode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from calibre.ebooks.covers import generate_cover as cal_generate_cover
|
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.addWidget(label,row,0,1,-1,Qt.AlignTop)
|
||||||
self.l.setRowStretch(row,1)
|
self.l.setRowStretch(row,1)
|
||||||
row+=1
|
row+=1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ from calibre.gui2 import gprefs
|
||||||
show_download_options = 'fff:add new/update dialogs:show_download_options'
|
show_download_options = 'fff:add new/update dialogs:show_download_options'
|
||||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||||
from calibre.gui2.complete2 import EditWithComplete
|
from calibre.gui2.complete2 import EditWithComplete
|
||||||
|
from .fanficfare.six import text_type as unicode
|
||||||
|
|
||||||
# pulls in translation files for _() strings
|
# pulls in translation files for _() strings
|
||||||
try:
|
try:
|
||||||
|
|
@ -707,7 +708,7 @@ class _LoopProgressDialog(QProgressDialog):
|
||||||
book['good']=False
|
book['good']=False
|
||||||
book['status']=_("Error")
|
book['status']=_("Error")
|
||||||
book['comment']=unicode(e)
|
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.updateStatus()
|
||||||
self.i += 1
|
self.i += 1
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ __license__ = 'GPL v3'
|
||||||
__copyright__ = '2019, Jim Miller'
|
__copyright__ = '2019, Jim Miller'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
from .fanficfare.six import text_type as unicode
|
||||||
|
|
||||||
# import cProfile
|
# import cProfile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ from calibre.utils.ipc.server import Server
|
||||||
from calibre.utils.ipc.job import ParallelJob
|
from calibre.utils.ipc.job import ParallelJob
|
||||||
from calibre.constants import numeric_version as calibre_version
|
from calibre.constants import numeric_version as calibre_version
|
||||||
from calibre.utils.date import local_tz
|
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.wordcount import get_word_count
|
||||||
from calibre_plugins.fanficfare_plugin.prefs import (SAVE_YES, SAVE_YES_UNLESS_SITE)
|
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['comment']=unicode(e)
|
||||||
book['icon']='dialog_error.png'
|
book['icon']='dialog_error.png'
|
||||||
book['status'] = _('Error')
|
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)
|
#time.sleep(10)
|
||||||
return book
|
return book
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ logger = logging.getLogger(__name__)
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from calibre.ebooks.oeb.iterator import EbookIterator
|
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_HTML_BODY = re.compile(u'<body[^>]*>(.*)</body>', re.UNICODE | re.DOTALL | re.IGNORECASE)
|
||||||
RE_STRIP_MARKUP = re.compile(u'<[^>]+>', re.UNICODE)
|
RE_STRIP_MARKUP = re.compile(u'<[^>]+>', re.UNICODE)
|
||||||
|
|
@ -28,7 +29,7 @@ def get_word_count(book_path):
|
||||||
Estimate a word count
|
Estimate a word count
|
||||||
'''
|
'''
|
||||||
from calibre.utils.localization import get_lang
|
from calibre.utils.localization import get_lang
|
||||||
|
|
||||||
iterator = _open_epub_file(book_path)
|
iterator = _open_epub_file(book_path)
|
||||||
|
|
||||||
lang = iterator.opf.language
|
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)
|
book_text = _read_epub_contents(iterator, strip_html=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from calibre.spell.break_iterator import count_words
|
from calibre.spell.break_iterator import count_words
|
||||||
wordcount = count_words(book_text, lang)
|
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 = get_wordcount_obj(book_text)
|
||||||
wordcount = wordcount.words
|
wordcount = wordcount.words
|
||||||
logger.debug('\tWord count - old method:%s'%wordcount)
|
logger.debug('\tWord count - old method:%s'%wordcount)
|
||||||
|
|
||||||
return wordcount
|
return wordcount
|
||||||
|
|
||||||
def _read_epub_contents(iterator, strip_html=False):
|
def _read_epub_contents(iterator, strip_html=False):
|
||||||
|
|
@ -92,4 +93,3 @@ def _extract_body_text(data):
|
||||||
if body:
|
if body:
|
||||||
return RE_STRIP_MARKUP.sub('', body[0]).replace('.','. ')
|
return RE_STRIP_MARKUP.sub('', body[0]).replace('.','. ')
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue