mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Merge branch 'py3' of https://github.com/eli-schwartz/calibre
This commit is contained in:
commit
7b936ee3ea
@ -1,56 +0,0 @@
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
|
||||||
|
|
||||||
class AdvancedUserRecipe1278347258(BasicNewsRecipe):
|
|
||||||
title = u'Salt Lake City Tribune'
|
|
||||||
__author__ = 'Charles Holbert'
|
|
||||||
oldest_article = 7
|
|
||||||
max_articles_per_feed = 100
|
|
||||||
|
|
||||||
description = '''Utah's independent news source since 1871'''
|
|
||||||
publisher = 'http://www.sltrib.com/'
|
|
||||||
category = 'news, Utah, SLC'
|
|
||||||
language = 'en'
|
|
||||||
encoding = 'utf-8'
|
|
||||||
#delay = 1
|
|
||||||
#simultaneous_downloads = 1
|
|
||||||
remove_javascript = True
|
|
||||||
use_embedded_content = False
|
|
||||||
no_stylesheets = True
|
|
||||||
|
|
||||||
#masthead_url = 'http://www.sltrib.com/csp/cms/sites/sltrib/assets/images/logo_main.png'
|
|
||||||
#cover_url = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg9/lg/UT_SLT.jpg'
|
|
||||||
|
|
||||||
keep_only_tags = [dict(name='div',attrs={'id':'imageBox'})
|
|
||||||
,dict(name='div',attrs={'class':'headline'})
|
|
||||||
,dict(name='div',attrs={'class':'byline'})
|
|
||||||
,dict(name='p',attrs={'class':'TEXT_w_Indent'})]
|
|
||||||
|
|
||||||
feeds = [(u'SL Tribune Today', u'http://www.sltrib.com/csp/cms/sites/sltrib/RSS/rss.csp?cat=All'),
|
|
||||||
(u'Utah News', u'http://www.sltrib.com/csp/cms/sites/sltrib/RSS/rss.csp?cat=UtahNews'),
|
|
||||||
(u'Business News', u'http://www.sltrib.com/csp/cms/sites/sltrib/RSS/rss.csp?cat=Money'),
|
|
||||||
(u'Technology', u'http://www.sltrib.com/csp/cms/sites/sltrib/RSS/rss.csp?cat=Technology'),
|
|
||||||
(u'Most Popular', u'http://www.sltrib.com/csp/cms/sites/sltrib/RSS/rsspopular.csp'),
|
|
||||||
(u'Sports', u'http://www.sltrib.com/csp/cms/sites/sltrib/RSS/rss.csp?cat=Sports')]
|
|
||||||
|
|
||||||
extra_css = '''
|
|
||||||
.headline{font-family:Arial,Helvetica,sans-serif; font-size:xx-large; font-weight: bold; color:#0E5398;}
|
|
||||||
.byline{font-family:Arial,Helvetica,sans-serif; color:#333333; font-size:xx-small;}
|
|
||||||
.storytext{font-family:Arial,Helvetica,sans-serif; font-size:medium;}
|
|
||||||
'''
|
|
||||||
|
|
||||||
def print_version(self, url):
|
|
||||||
seg = url.split('/')
|
|
||||||
x = seg[5].split('-')
|
|
||||||
baseURL = 'http://www.sltrib.com/csp/cms/sites/sltrib/pages/printerfriendly.csp?id='
|
|
||||||
s = baseURL + x[0]
|
|
||||||
return s
|
|
||||||
|
|
||||||
def get_cover_url(self):
|
|
||||||
cover_url = None
|
|
||||||
href = 'http://www.newseum.org/todaysfrontpages/hr.asp?fpVname=UT_SLT&ref_pge=lst'
|
|
||||||
soup = self.index_to_soup(href)
|
|
||||||
div = soup.find('div',attrs={'class':'tfpLrgView_container'})
|
|
||||||
if div:
|
|
||||||
cover_url = div.img['src']
|
|
||||||
return cover_url
|
|
||||||
|
|
@ -67,7 +67,7 @@ class HTMLRenderer(object):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
image.save(buf, 'JPEG')
|
image.save(buf, 'JPEG')
|
||||||
self.data = bytes(ba.data())
|
self.data = ba.data()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.exception = e
|
self.exception = e
|
||||||
self.traceback = traceback.format_exc()
|
self.traceback = traceback.format_exc()
|
||||||
|
@ -464,7 +464,7 @@ class PDFStream(object):
|
|||||||
ba = QByteArray()
|
ba = QByteArray()
|
||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
image.save(buf, 'jpeg', 94)
|
image.save(buf, 'jpeg', 94)
|
||||||
data = bytes(ba.data())
|
data = ba.data()
|
||||||
|
|
||||||
if has_alpha:
|
if has_alpha:
|
||||||
soft_mask = self.write_image(tmask, w, h, 8)
|
soft_mask = self.write_image(tmask, w, h, 8)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
""" The GUI """
|
""" The GUI """
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
@ -354,7 +358,7 @@ def is_widescreen():
|
|||||||
global _is_widescreen
|
global _is_widescreen
|
||||||
if _is_widescreen is None:
|
if _is_widescreen is None:
|
||||||
try:
|
try:
|
||||||
_is_widescreen = float(available_width())/available_height() > 1.4
|
_is_widescreen = available_width()/available_height() > 1.4
|
||||||
except:
|
except:
|
||||||
_is_widescreen = False
|
_is_widescreen = False
|
||||||
return _is_widescreen
|
return _is_widescreen
|
||||||
@ -687,7 +691,7 @@ def pixmap_to_data(pixmap, format='JPEG', quality=None):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
pixmap.save(buf, format, quality=quality)
|
pixmap.save(buf, format, quality=quality)
|
||||||
return bytes(ba.data())
|
return ba.data()
|
||||||
|
|
||||||
|
|
||||||
def decouple(prefix):
|
def decouple(prefix):
|
||||||
@ -736,7 +740,7 @@ class Translator(QTranslator):
|
|||||||
try:
|
try:
|
||||||
src = unicode_type(args[1])
|
src = unicode_type(args[1])
|
||||||
except:
|
except:
|
||||||
return u''
|
return ''
|
||||||
t = _
|
t = _
|
||||||
return t(src)
|
return t(src)
|
||||||
|
|
||||||
@ -766,8 +770,8 @@ def load_builtin_fonts():
|
|||||||
if fid > -1:
|
if fid > -1:
|
||||||
fam = QFontDatabase.applicationFontFamilies(fid)
|
fam = QFontDatabase.applicationFontFamilies(fid)
|
||||||
fam = set(map(unicode_type, fam))
|
fam = set(map(unicode_type, fam))
|
||||||
if u'calibre Symbols' in fam:
|
if 'calibre Symbols' in fam:
|
||||||
_rating_font = u'calibre Symbols'
|
_rating_font = 'calibre Symbols'
|
||||||
|
|
||||||
|
|
||||||
def setup_gui_option_parser(parser):
|
def setup_gui_option_parser(parser):
|
||||||
@ -881,7 +885,7 @@ class Application(QApplication):
|
|||||||
self.line_height = max(12, QFontMetrics(self.font()).lineSpacing())
|
self.line_height = max(12, QFontMetrics(self.font()).lineSpacing())
|
||||||
|
|
||||||
dl = QLocale(get_lang())
|
dl = QLocale(get_lang())
|
||||||
if unicode_type(dl.bcp47Name()) != u'C':
|
if unicode_type(dl.bcp47Name()) != 'C':
|
||||||
QLocale.setDefault(dl)
|
QLocale.setDefault(dl)
|
||||||
global gui_thread, qt_app
|
global gui_thread, qt_app
|
||||||
gui_thread = QThread.currentThread()
|
gui_thread = QThread.currentThread()
|
||||||
@ -903,7 +907,7 @@ class Application(QApplication):
|
|||||||
'calibre versions newer than 2.0 do not run on Windows XP. This is'
|
'calibre versions newer than 2.0 do not run on Windows XP. This is'
|
||||||
' because the graphics toolkit calibre uses (Qt 5) crashes a lot'
|
' because the graphics toolkit calibre uses (Qt 5) crashes a lot'
|
||||||
' on Windows XP. We suggest you stay with <a href="%s">calibre 1.48</a>'
|
' on Windows XP. We suggest you stay with <a href="%s">calibre 1.48</a>'
|
||||||
' which works well on Windows XP.') % 'http://download.calibre-ebook.com/1.48.0/', show=True)
|
' which works well on Windows XP.') % 'https://download.calibre-ebook.com/1.48.0/', show=True)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
if iswindows:
|
if iswindows:
|
||||||
@ -978,22 +982,22 @@ class Application(QApplication):
|
|||||||
icon_map = self.__icon_map_memory_ = {}
|
icon_map = self.__icon_map_memory_ = {}
|
||||||
pcache = {}
|
pcache = {}
|
||||||
for k, v in iteritems({
|
for k, v in iteritems({
|
||||||
'DialogYesButton': u'ok.png',
|
'DialogYesButton': 'ok.png',
|
||||||
'DialogNoButton': u'window-close.png',
|
'DialogNoButton': 'window-close.png',
|
||||||
'DialogCloseButton': u'window-close.png',
|
'DialogCloseButton': 'window-close.png',
|
||||||
'DialogOkButton': u'ok.png',
|
'DialogOkButton': 'ok.png',
|
||||||
'DialogCancelButton': u'window-close.png',
|
'DialogCancelButton': 'window-close.png',
|
||||||
'DialogHelpButton': u'help.png',
|
'DialogHelpButton': 'help.png',
|
||||||
'DialogOpenButton': u'document_open.png',
|
'DialogOpenButton': 'document_open.png',
|
||||||
'DialogSaveButton': u'save.png',
|
'DialogSaveButton': 'save.png',
|
||||||
'DialogApplyButton': u'ok.png',
|
'DialogApplyButton': 'ok.png',
|
||||||
'DialogDiscardButton': u'trash.png',
|
'DialogDiscardButton': 'trash.png',
|
||||||
'MessageBoxInformation': u'dialog_information.png',
|
'MessageBoxInformation': 'dialog_information.png',
|
||||||
'MessageBoxWarning': u'dialog_warning.png',
|
'MessageBoxWarning': 'dialog_warning.png',
|
||||||
'MessageBoxCritical': u'dialog_error.png',
|
'MessageBoxCritical': 'dialog_error.png',
|
||||||
'MessageBoxQuestion': u'dialog_question.png',
|
'MessageBoxQuestion': 'dialog_question.png',
|
||||||
'BrowserReload': u'view-refresh.png',
|
'BrowserReload': 'view-refresh.png',
|
||||||
'LineEditClearButton': u'clear_left.png',
|
'LineEditClearButton': 'clear_left.png',
|
||||||
}):
|
}):
|
||||||
if v not in pcache:
|
if v not in pcache:
|
||||||
p = I(v)
|
p = I(v)
|
||||||
@ -1242,7 +1246,7 @@ def elided_text(text, font=None, width=300, pos='middle'):
|
|||||||
from PyQt5.Qt import QFontMetrics, QApplication
|
from PyQt5.Qt import QFontMetrics, QApplication
|
||||||
fm = QApplication.fontMetrics() if font is None else (font if isinstance(font, QFontMetrics) else QFontMetrics(font))
|
fm = QApplication.fontMetrics() if font is None else (font if isinstance(font, QFontMetrics) else QFontMetrics(font))
|
||||||
delta = 4
|
delta = 4
|
||||||
ellipsis = u'\u2026'
|
ellipsis = '\u2026'
|
||||||
|
|
||||||
def remove_middle(x):
|
def remove_middle(x):
|
||||||
mid = len(x) // 2
|
mid = len(x) // 2
|
||||||
@ -1361,7 +1365,7 @@ def set_app_uid(val):
|
|||||||
try:
|
try:
|
||||||
AppUserModelID(unicode_type(val))
|
AppUserModelID(unicode_type(val))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
prints(u'Failed to set app uid with error:', as_unicode(err))
|
prints('Failed to set app uid with error:', as_unicode(err))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -19,7 +20,7 @@ from polyglot.builtins import unicode_type, string_or_bytes
|
|||||||
|
|
||||||
|
|
||||||
def menu_action_unique_name(plugin, unique_name):
|
def menu_action_unique_name(plugin, unique_name):
|
||||||
return u'%s : menu action : %s'%(plugin.unique_name, unique_name)
|
return '%s : menu action : %s'%(plugin.unique_name, unique_name)
|
||||||
|
|
||||||
|
|
||||||
class InterfaceAction(QObject):
|
class InterfaceAction(QObject):
|
||||||
@ -151,7 +152,7 @@ class InterfaceAction(QObject):
|
|||||||
bn = self.__class__.__name__
|
bn = self.__class__.__name__
|
||||||
if getattr(self.interface_action_base_plugin, 'name'):
|
if getattr(self.interface_action_base_plugin, 'name'):
|
||||||
bn = self.interface_action_base_plugin.name
|
bn = self.interface_action_base_plugin.name
|
||||||
return u'Interface Action: %s (%s)'%(bn, self.name)
|
return 'Interface Action: %s (%s)'%(bn, self.name)
|
||||||
|
|
||||||
def create_action(self, spec=None, attr='qaction', shortcut_name=None):
|
def create_action(self, spec=None, attr='qaction', shortcut_name=None):
|
||||||
if spec is None:
|
if spec is None:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -331,7 +332,8 @@ class AddAction(InterfaceAction):
|
|||||||
create_book(mi, pt.name, fmt=empty_format)
|
create_book(mi, pt.name, fmt=empty_format)
|
||||||
fmts = [pt.name]
|
fmts = [pt.name]
|
||||||
ids.append(db.import_book(mi, fmts))
|
ids.append(db.import_book(mi, fmts))
|
||||||
tuple(map(os.remove, orig_fmts))
|
for path in orig_fmts:
|
||||||
|
os.remove(path)
|
||||||
self.refresh_gui(num)
|
self.refresh_gui(num)
|
||||||
if ids:
|
if ids:
|
||||||
ids.reverse()
|
ids.reverse()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -85,7 +86,7 @@ class GenerateCatalogAction(InterfaceAction):
|
|||||||
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
|
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
|
||||||
self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
|
self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
|
||||||
if job.catalog_sync:
|
if job.catalog_sync:
|
||||||
sync = dynamic.get('catalogs_to_be_synced', set([]))
|
sync = dynamic.get('catalogs_to_be_synced', set())
|
||||||
sync.add(id)
|
sync.add(id)
|
||||||
dynamic.set('catalogs_to_be_synced', sync)
|
dynamic.set('catalogs_to_be_synced', sync)
|
||||||
self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
|
self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -252,7 +252,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
for i in range(5):
|
for i in range(5):
|
||||||
ac = self.create_action(spec=('', None, None, None),
|
ac = self.create_action(spec=('', None, None, None),
|
||||||
attr='switch_action%d'%i)
|
attr='switch_action%d'%i)
|
||||||
ac.setObjectName(str(i))
|
ac.setObjectName(unicode_type(i))
|
||||||
self.switch_actions.append(ac)
|
self.switch_actions.append(ac)
|
||||||
ac.setVisible(False)
|
ac.setVisible(False)
|
||||||
connect_lambda(ac.triggered, self, lambda self:
|
connect_lambda(ac.triggered, self, lambda self:
|
||||||
@ -329,7 +329,7 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
self.prev_lname = self.last_lname
|
self.prev_lname = self.last_lname
|
||||||
self.last_lname = lname
|
self.last_lname = lname
|
||||||
if len(lname) > 16:
|
if len(lname) > 16:
|
||||||
lname = lname[:16] + u'…'
|
lname = lname[:16] + '…'
|
||||||
a = self.qaction
|
a = self.qaction
|
||||||
a.setText(lname.replace('&', '&&&')) # I have no idea why this requires a triple ampersand
|
a.setText(lname.replace('&', '&&&')) # I have no idea why this requires a triple ampersand
|
||||||
self.update_tooltip(db.count())
|
self.update_tooltip(db.count())
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -40,7 +41,7 @@ class ConvertAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -106,7 +107,7 @@ class DeleteAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -165,7 +166,7 @@ class DeleteAction(InterfaceAction):
|
|||||||
if not rows or len(rows) == 0:
|
if not rows or len(rows) == 0:
|
||||||
d = error_dialog(self.gui, err_title, _('No book selected'))
|
d = error_dialog(self.gui, err_title, _('No book selected'))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
return set([])
|
return set()
|
||||||
return set(map(self.gui.library_view.model().id, rows))
|
return set(map(self.gui.library_view.model().id, rows))
|
||||||
|
|
||||||
def remove_format_by_id(self, book_id, fmt):
|
def remove_format_by_id(self, book_id, fmt):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -12,7 +13,7 @@ from calibre.gui2.actions import InterfaceAction
|
|||||||
from calibre.gui2.dialogs.smartdevice import SmartdeviceDialog
|
from calibre.gui2.dialogs.smartdevice import SmartdeviceDialog
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
from calibre.utils.smtp import config as email_config
|
from calibre.utils.smtp import config as email_config
|
||||||
from polyglot.builtins import unicode_type, map
|
from polyglot.builtins import unicode_type
|
||||||
|
|
||||||
|
|
||||||
class ShareConnMenu(QMenu): # {{{
|
class ShareConnMenu(QMenu): # {{{
|
||||||
@ -111,7 +112,8 @@ class ShareConnMenu(QMenu): # {{{
|
|||||||
(alias or account) + ' ' + _('(delete from library)'))
|
(alias or account) + ' ' + _('(delete from library)'))
|
||||||
self.email_to_menu.addAction(action1)
|
self.email_to_menu.addAction(action1)
|
||||||
self.email_to_and_delete_menu.addAction(action2)
|
self.email_to_and_delete_menu.addAction(action2)
|
||||||
tuple(map(self.memory.append, (action1, action2)))
|
self.memory.append(action1)
|
||||||
|
self.memory.append(action2)
|
||||||
if default:
|
if default:
|
||||||
ac = DeviceAction(dest, False, False,
|
ac = DeviceAction(dest, False, False,
|
||||||
I('mail.png'), _('Email to') + ' ' +(alias or
|
I('mail.png'), _('Email to') + ' ' +(alias or
|
||||||
@ -127,12 +129,14 @@ class ShareConnMenu(QMenu): # {{{
|
|||||||
_('Select recipients') + ' ' + _('(delete from library)'))
|
_('Select recipients') + ' ' + _('(delete from library)'))
|
||||||
self.email_to_menu.addAction(action1)
|
self.email_to_menu.addAction(action1)
|
||||||
self.email_to_and_delete_menu.addAction(action2)
|
self.email_to_and_delete_menu.addAction(action2)
|
||||||
tuple(map(self.memory.append, (action1, action2)))
|
self.memory.append(action1)
|
||||||
|
self.memory.append(action2)
|
||||||
tac1 = DeviceAction('choosemail:', False, False, I('mail.png'),
|
tac1 = DeviceAction('choosemail:', False, False, I('mail.png'),
|
||||||
_('Email to selected recipients...'))
|
_('Email to selected recipients...'))
|
||||||
self.addAction(tac1)
|
self.addAction(tac1)
|
||||||
tac1.a_s.connect(sync_menu.action_triggered)
|
tac1.a_s.connect(sync_menu.action_triggered)
|
||||||
self.memory.append(tac1), self.email_actions.append(tac1)
|
self.memory.append(tac1)
|
||||||
|
self.email_actions.append(tac1)
|
||||||
ac = self.addMenu(self.email_to_and_delete_menu)
|
ac = self.addMenu(self.email_to_and_delete_menu)
|
||||||
self.email_actions.append(ac)
|
self.email_actions.append(ac)
|
||||||
action1.a_s.connect(sync_menu.action_triggered)
|
action1.a_s.connect(sync_menu.action_triggered)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -51,7 +52,7 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -648,7 +649,7 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
if not dest_mi.comments:
|
if not dest_mi.comments:
|
||||||
dest_mi.comments = src_mi.comments
|
dest_mi.comments = src_mi.comments
|
||||||
else:
|
else:
|
||||||
dest_mi.comments = unicode_type(dest_mi.comments) + u'\n\n' + unicode_type(src_mi.comments)
|
dest_mi.comments = unicode_type(dest_mi.comments) + '\n\n' + unicode_type(src_mi.comments)
|
||||||
if src_mi.title and (not dest_mi.title or dest_mi.title == _('Unknown')):
|
if src_mi.title and (not dest_mi.title or dest_mi.title == _('Unknown')):
|
||||||
dest_mi.title = src_mi.title
|
dest_mi.title = src_mi.title
|
||||||
if (src_mi.authors and src_mi.authors[0] != _('Unknown')) and (not dest_mi.authors or dest_mi.authors[0] == _('Unknown')):
|
if (src_mi.authors and src_mi.authors[0] != _('Unknown')) and (not dest_mi.authors or dest_mi.authors[0] == _('Unknown')):
|
||||||
@ -701,7 +702,7 @@ class EditMetadataAction(InterfaceAction):
|
|||||||
if not dest_value:
|
if not dest_value:
|
||||||
db.set_custom(dest_id, src_value, num=colnum)
|
db.set_custom(dest_id, src_value, num=colnum)
|
||||||
else:
|
else:
|
||||||
dest_value = unicode_type(dest_value) + u'\n\n' + unicode_type(src_value)
|
dest_value = unicode_type(dest_value) + '\n\n' + unicode_type(src_value)
|
||||||
db.set_custom(dest_id, dest_value, num=colnum)
|
db.set_custom(dest_id, dest_value, num=colnum)
|
||||||
if (dt in {'bool', 'int', 'float', 'rating', 'datetime'} and dest_value is None):
|
if (dt in {'bool', 'int', 'float', 'rating', 'datetime'} and dest_value is None):
|
||||||
db.set_custom(dest_id, src_value, num=colnum)
|
db.set_custom(dest_id, src_value, num=colnum)
|
||||||
|
@ -37,7 +37,7 @@ class EmbedAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -22,6 +23,3 @@ class HelpAction(InterfaceAction):
|
|||||||
|
|
||||||
def show_help(self, *args):
|
def show_help(self, *args):
|
||||||
open_url(QUrl(localize_user_manual_link('https://manual.calibre-ebook.com')))
|
open_url(QUrl(localize_user_manual_link('https://manual.calibre-ebook.com')))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class MarkBooksAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -24,5 +25,3 @@ class OpenFolderAction(InterfaceAction):
|
|||||||
enabled = loc == 'library'
|
enabled = loc == 'library'
|
||||||
self.qaction.setEnabled(enabled)
|
self.qaction.setEnabled(enabled)
|
||||||
self.menuless_qaction.setEnabled(enabled)
|
self.menuless_qaction.setEnabled(enabled)
|
||||||
|
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ class PolishAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -19,5 +20,3 @@ class RestartAction(InterfaceAction):
|
|||||||
|
|
||||||
def restart(self, *args):
|
def restart(self, *args):
|
||||||
self.gui.quit(restart=True)
|
self.gui.quit(restart=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -7,12 +8,11 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import os, numbers
|
import os, numbers
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from polyglot.builtins import itervalues, map
|
|
||||||
|
|
||||||
|
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from calibre.gui2 import error_dialog, Dispatcher, choose_dir
|
from calibre.gui2 import error_dialog, Dispatcher, choose_dir
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
from polyglot.builtins import itervalues, map
|
||||||
|
|
||||||
|
|
||||||
class SaveToDiskAction(InterfaceAction):
|
class SaveToDiskAction(InterfaceAction):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -87,7 +87,7 @@ class ToCEditAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -74,7 +75,7 @@ class TweakEpubAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -308,7 +309,7 @@ class UnpackBookAction(InterfaceAction):
|
|||||||
def drop_event(self, event, mime_data):
|
def drop_event(self, event, mime_data):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if mime_data.hasFormat(mime):
|
if mime_data.hasFormat(mime):
|
||||||
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
self.dropped_ids = tuple(map(int, mime_data.data(mime).data().split()))
|
||||||
QTimer.singleShot(1, self.do_drop)
|
QTimer.singleShot(1, self.do_drop)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -166,7 +167,7 @@ class ViewAction(InterfaceAction):
|
|||||||
rows = [r.row() for r in rows]
|
rows = [r.row() for r in rows]
|
||||||
book_ids = [db.id(r) for r in rows]
|
book_ids = [db.id(r) for r in rows]
|
||||||
formats = [[x.upper() for x in db.new_api.formats(book_id)] for book_id in book_ids]
|
formats = [[x.upper() for x in db.new_api.formats(book_id)] for book_id in book_ids]
|
||||||
all_fmts = set([])
|
all_fmts = set()
|
||||||
for x in formats:
|
for x in formats:
|
||||||
if x:
|
if x:
|
||||||
for f in x:
|
for f in x:
|
||||||
|
@ -286,10 +286,10 @@ class ToolBar(QToolBar): # {{{
|
|||||||
event.ignore()
|
event.ignore()
|
||||||
|
|
||||||
def dropEvent(self, event):
|
def dropEvent(self, event):
|
||||||
data = event.mimeData()
|
md = event.mimeData()
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
if data.hasFormat(mime):
|
if md.hasFormat(mime):
|
||||||
ids = list(map(int, str(data.data(mime)).split()))
|
ids = list(map(int, md.data(mime).data().split()))
|
||||||
tgt = None
|
tgt = None
|
||||||
for ac in self.location_manager.available_actions:
|
for ac in self.location_manager.available_actions:
|
||||||
w = self.widgetForAction(ac)
|
w = self.widgetForAction(ac)
|
||||||
@ -303,8 +303,8 @@ class ToolBar(QToolBar): # {{{
|
|||||||
return
|
return
|
||||||
|
|
||||||
mime = 'application/calibre+from_device'
|
mime = 'application/calibre+from_device'
|
||||||
if data.hasFormat(mime):
|
if md.hasFormat(mime):
|
||||||
paths = [unicode_type(u.toLocalFile()) for u in data.urls()]
|
paths = [unicode_type(u.toLocalFile()) for u in md.urls()]
|
||||||
if paths:
|
if paths:
|
||||||
self.gui.iactions['Add Books'].add_books_from_device(
|
self.gui.iactions['Add Books'].add_books_from_device(
|
||||||
self.gui.current_view(), paths=paths)
|
self.gui.current_view(), paths=paths)
|
||||||
@ -312,7 +312,7 @@ class ToolBar(QToolBar): # {{{
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Give added_actions an opportunity to process the drag&drop event
|
# Give added_actions an opportunity to process the drag&drop event
|
||||||
if self.check_iactions_for_drag(event, data, 'drop_event'):
|
if self.check_iactions_for_drag(event, md, 'drop_event'):
|
||||||
event.accept()
|
event.accept()
|
||||||
else:
|
else:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
from PyQt5.Qt import QWidget, QListWidgetItem
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.catalog.catalog_bibtex_ui import Ui_Form
|
from calibre.gui2.catalog.catalog_bibtex_ui import Ui_Form
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
from PyQt5.Qt import QWidget, QListWidgetItem
|
|
||||||
|
|
||||||
|
|
||||||
class PluginWidget(QWidget, Ui_Form):
|
class PluginWidget(QWidget, Ui_Form):
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
from PyQt5.Qt import QWidget, QListWidgetItem, Qt, QVBoxLayout, QLabel, QListWidget
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import unicode_type, range
|
||||||
from PyQt5.Qt import QWidget, QListWidgetItem, Qt, QVBoxLayout, QLabel, QListWidget
|
|
||||||
|
|
||||||
|
|
||||||
def get_saved_field_data(name, all_fields):
|
def get_saved_field_data(name, all_fields):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -15,7 +15,7 @@ from calibre.gui2 import gprefs, open_url, question_dialog, error_dialog
|
|||||||
from calibre.utils.config import JSONConfig
|
from calibre.utils.config import JSONConfig
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
from calibre.utils.localization import localize_user_manual_link
|
from calibre.utils.localization import localize_user_manual_link
|
||||||
from polyglot.builtins import unicode_type, zip, range
|
from polyglot.builtins import native_string_type, unicode_type, zip, range
|
||||||
|
|
||||||
from .catalog_epub_mobi_ui import Ui_Form
|
from .catalog_epub_mobi_ui import Ui_Form
|
||||||
from PyQt5.Qt import (Qt, QAbstractItemView, QCheckBox, QComboBox,
|
from PyQt5.Qt import (Qt, QAbstractItemView, QCheckBox, QComboBox,
|
||||||
@ -115,7 +115,7 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
'name':_('Wishlist item'),
|
'name':_('Wishlist item'),
|
||||||
'field':_('Tags'),
|
'field':_('Tags'),
|
||||||
'pattern':'Wishlist',
|
'pattern':'Wishlist',
|
||||||
'prefix':u'\u00d7'},],
|
'prefix':'\u00d7'},],
|
||||||
['table_widget','table_widget']))
|
['table_widget','table_widget']))
|
||||||
|
|
||||||
self.OPTION_FIELDS = option_fields
|
self.OPTION_FIELDS = option_fields
|
||||||
@ -423,7 +423,7 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
# Hook Preset signals
|
# Hook Preset signals
|
||||||
self.preset_delete_pb.clicked.connect(self.preset_remove)
|
self.preset_delete_pb.clicked.connect(self.preset_remove)
|
||||||
self.preset_save_pb.clicked.connect(self.preset_save)
|
self.preset_save_pb.clicked.connect(self.preset_save)
|
||||||
self.preset_field.currentIndexChanged[str].connect(self.preset_change)
|
self.preset_field.currentIndexChanged[native_string_type].connect(self.preset_change)
|
||||||
|
|
||||||
self.blocking_all_signals = False
|
self.blocking_all_signals = False
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
# Populate the Presets combo box
|
# Populate the Presets combo box
|
||||||
self.presets = JSONConfig("catalog_presets")
|
self.presets = JSONConfig("catalog_presets")
|
||||||
self.preset_field.addItem("")
|
self.preset_field.addItem("")
|
||||||
self.preset_field_values = sorted([p for p in self.presets], key=sort_key)
|
self.preset_field_values = sorted(self.presets, key=sort_key)
|
||||||
self.preset_field.addItems(self.preset_field_values)
|
self.preset_field.addItems(self.preset_field_values)
|
||||||
|
|
||||||
def preset_change(self, item_name):
|
def preset_change(self, item_name):
|
||||||
@ -1338,127 +1338,127 @@ class PrefixRules(GenericRulesTable):
|
|||||||
|
|
||||||
# Create a list of prefixes for user selection
|
# Create a list of prefixes for user selection
|
||||||
raw_prefix_list = [
|
raw_prefix_list = [
|
||||||
('Ampersand',u'&'),
|
('Ampersand', '&'),
|
||||||
('Angle left double',u'\u00ab'),
|
('Angle left double', '\u00ab'),
|
||||||
('Angle left',u'\u2039'),
|
('Angle left', '\u2039'),
|
||||||
('Angle right double',u'\u00bb'),
|
('Angle right double', '\u00bb'),
|
||||||
('Angle right',u'\u203a'),
|
('Angle right', '\u203a'),
|
||||||
('Arrow carriage return',u'\u21b5'),
|
('Arrow carriage return', '\u21b5'),
|
||||||
('Arrow double',u'\u2194'),
|
('Arrow double', '\u2194'),
|
||||||
('Arrow down',u'\u2193'),
|
('Arrow down', '\u2193'),
|
||||||
('Arrow left',u'\u2190'),
|
('Arrow left', '\u2190'),
|
||||||
('Arrow right',u'\u2192'),
|
('Arrow right', '\u2192'),
|
||||||
('Arrow up',u'\u2191'),
|
('Arrow up', '\u2191'),
|
||||||
('Asterisk',u'*'),
|
('Asterisk', '*'),
|
||||||
('At sign',u'@'),
|
('At sign', '@'),
|
||||||
('Bullet smallest',u'\u22c5'),
|
('Bullet smallest', '\u22c5'),
|
||||||
('Bullet small',u'\u00b7'),
|
('Bullet small', '\u00b7'),
|
||||||
('Bullet',u'\u2022'),
|
('Bullet', '\u2022'),
|
||||||
('Cards clubs',u'\u2663'),
|
('Cards clubs', '\u2663'),
|
||||||
('Cards diamonds',u'\u2666'),
|
('Cards diamonds', '\u2666'),
|
||||||
('Cards hearts',u'\u2665'),
|
('Cards hearts', '\u2665'),
|
||||||
('Cards spades',u'\u2660'),
|
('Cards spades', '\u2660'),
|
||||||
('Caret',u'^'),
|
('Caret', '^'),
|
||||||
('Checkmark',u'\u2713'),
|
('Checkmark', '\u2713'),
|
||||||
('Copyright circle c',u'\u00a9'),
|
('Copyright circle c', '\u00a9'),
|
||||||
('Copyright circle r',u'\u00ae'),
|
('Copyright circle r', '\u00ae'),
|
||||||
('Copyright trademark',u'\u2122'),
|
('Copyright trademark', '\u2122'),
|
||||||
('Currency cent',u'\u00a2'),
|
('Currency cent', '\u00a2'),
|
||||||
('Currency dollar',u'$'),
|
('Currency dollar', '$'),
|
||||||
('Currency euro',u'\u20ac'),
|
('Currency euro', '\u20ac'),
|
||||||
('Currency pound',u'\u00a3'),
|
('Currency pound', '\u00a3'),
|
||||||
('Currency yen',u'\u00a5'),
|
('Currency yen', '\u00a5'),
|
||||||
('Dagger double',u'\u2021'),
|
('Dagger double', '\u2021'),
|
||||||
('Dagger',u'\u2020'),
|
('Dagger', '\u2020'),
|
||||||
('Degree',u'\u00b0'),
|
('Degree', '\u00b0'),
|
||||||
('Dots3',u'\u2234'),
|
('Dots3', '\u2234'),
|
||||||
('Hash',u'#'),
|
('Hash', '#'),
|
||||||
('Infinity',u'\u221e'),
|
('Infinity', '\u221e'),
|
||||||
('Lozenge',u'\u25ca'),
|
('Lozenge', '\u25ca'),
|
||||||
('Math divide',u'\u00f7'),
|
('Math divide', '\u00f7'),
|
||||||
('Math empty',u'\u2205'),
|
('Math empty', '\u2205'),
|
||||||
('Math equals',u'='),
|
('Math equals', '='),
|
||||||
('Math minus',u'\u2212'),
|
('Math minus', '\u2212'),
|
||||||
('Math plus circled',u'\u2295'),
|
('Math plus circled', '\u2295'),
|
||||||
('Math times circled',u'\u2297'),
|
('Math times circled', '\u2297'),
|
||||||
('Math times',u'\u00d7'),
|
('Math times', '\u00d7'),
|
||||||
('Paragraph',u'\u00b6'),
|
('Paragraph', '\u00b6'),
|
||||||
('Percent',u'%'),
|
('Percent', '%'),
|
||||||
('Plus-or-minus',u'\u00b1'),
|
('Plus-or-minus', '\u00b1'),
|
||||||
('Plus',u'+'),
|
('Plus', '+'),
|
||||||
('Punctuation colon',u':'),
|
('Punctuation colon', ':'),
|
||||||
('Punctuation colon-semi',u';'),
|
('Punctuation colon-semi', ';'),
|
||||||
('Punctuation exclamation',u'!'),
|
('Punctuation exclamation', '!'),
|
||||||
('Punctuation question',u'?'),
|
('Punctuation question', '?'),
|
||||||
('Punctuation period',u'.'),
|
('Punctuation period', '.'),
|
||||||
('Punctuation slash back',u'\\'),
|
('Punctuation slash back', '\\'),
|
||||||
('Punctuation slash forward',u'/'),
|
('Punctuation slash forward', '/'),
|
||||||
('Section',u'\u00a7'),
|
('Section', '\u00a7'),
|
||||||
('Tilde',u'~'),
|
('Tilde', '~'),
|
||||||
('Vertical bar',u'|'),
|
('Vertical bar', '|'),
|
||||||
('Vertical bar broken',u'\u00a6'),
|
('Vertical bar broken', '\u00a6'),
|
||||||
('_0',u'0'),
|
('_0', '0'),
|
||||||
('_1',u'1'),
|
('_1', '1'),
|
||||||
('_2',u'2'),
|
('_2', '2'),
|
||||||
('_3',u'3'),
|
('_3', '3'),
|
||||||
('_4',u'4'),
|
('_4', '4'),
|
||||||
('_5',u'5'),
|
('_5', '5'),
|
||||||
('_6',u'6'),
|
('_6', '6'),
|
||||||
('_7',u'7'),
|
('_7', '7'),
|
||||||
('_8',u'8'),
|
('_8', '8'),
|
||||||
('_9',u'9'),
|
('_9', '9'),
|
||||||
('_A',u'A'),
|
('_A', 'A'),
|
||||||
('_B',u'B'),
|
('_B', 'B'),
|
||||||
('_C',u'C'),
|
('_C', 'C'),
|
||||||
('_D',u'D'),
|
('_D', 'D'),
|
||||||
('_E',u'E'),
|
('_E', 'E'),
|
||||||
('_F',u'F'),
|
('_F', 'F'),
|
||||||
('_G',u'G'),
|
('_G', 'G'),
|
||||||
('_H',u'H'),
|
('_H', 'H'),
|
||||||
('_I',u'I'),
|
('_I', 'I'),
|
||||||
('_J',u'J'),
|
('_J', 'J'),
|
||||||
('_K',u'K'),
|
('_K', 'K'),
|
||||||
('_L',u'L'),
|
('_L', 'L'),
|
||||||
('_M',u'M'),
|
('_M', 'M'),
|
||||||
('_N',u'N'),
|
('_N', 'N'),
|
||||||
('_O',u'O'),
|
('_O', 'O'),
|
||||||
('_P',u'P'),
|
('_P', 'P'),
|
||||||
('_Q',u'Q'),
|
('_Q', 'Q'),
|
||||||
('_R',u'R'),
|
('_R', 'R'),
|
||||||
('_S',u'S'),
|
('_S', 'S'),
|
||||||
('_T',u'T'),
|
('_T', 'T'),
|
||||||
('_U',u'U'),
|
('_U', 'U'),
|
||||||
('_V',u'V'),
|
('_V', 'V'),
|
||||||
('_W',u'W'),
|
('_W', 'W'),
|
||||||
('_X',u'X'),
|
('_X', 'X'),
|
||||||
('_Y',u'Y'),
|
('_Y', 'Y'),
|
||||||
('_Z',u'Z'),
|
('_Z', 'Z'),
|
||||||
('_a',u'a'),
|
('_a', 'a'),
|
||||||
('_b',u'b'),
|
('_b', 'b'),
|
||||||
('_c',u'c'),
|
('_c', 'c'),
|
||||||
('_d',u'd'),
|
('_d', 'd'),
|
||||||
('_e',u'e'),
|
('_e', 'e'),
|
||||||
('_f',u'f'),
|
('_f', 'f'),
|
||||||
('_g',u'g'),
|
('_g', 'g'),
|
||||||
('_h',u'h'),
|
('_h', 'h'),
|
||||||
('_i',u'i'),
|
('_i', 'i'),
|
||||||
('_j',u'j'),
|
('_j', 'j'),
|
||||||
('_k',u'k'),
|
('_k', 'k'),
|
||||||
('_l',u'l'),
|
('_l', 'l'),
|
||||||
('_m',u'm'),
|
('_m', 'm'),
|
||||||
('_n',u'n'),
|
('_n', 'n'),
|
||||||
('_o',u'o'),
|
('_o', 'o'),
|
||||||
('_p',u'p'),
|
('_p', 'p'),
|
||||||
('_q',u'q'),
|
('_q', 'q'),
|
||||||
('_r',u'r'),
|
('_r', 'r'),
|
||||||
('_s',u's'),
|
('_s', 's'),
|
||||||
('_t',u't'),
|
('_t', 't'),
|
||||||
('_u',u'u'),
|
('_u', 'u'),
|
||||||
('_v',u'v'),
|
('_v', 'v'),
|
||||||
('_w',u'w'),
|
('_w', 'w'),
|
||||||
('_x',u'x'),
|
('_x', 'x'),
|
||||||
('_y',u'y'),
|
('_y', 'y'),
|
||||||
('_z',u'z'),
|
('_z', 'z'),
|
||||||
]
|
]
|
||||||
raw_prefix_list = sorted(raw_prefix_list, key=prefix_sorter)
|
raw_prefix_list = sorted(raw_prefix_list, key=prefix_sorter)
|
||||||
self.prefix_list = [x[1] for x in raw_prefix_list]
|
self.prefix_list = [x[1] for x in raw_prefix_list]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -338,7 +339,7 @@ class EditorWidget(QWebView, LineEditECM): # {{{
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def html(self):
|
def html(self):
|
||||||
ans = u''
|
ans = ''
|
||||||
try:
|
try:
|
||||||
if not self.page().mainFrame().documentElement().findFirst('meta[name="calibre-dont-sanitize"]').isNull():
|
if not self.page().mainFrame().documentElement().findFirst('meta[name="calibre-dont-sanitize"]').isNull():
|
||||||
# Bypass cleanup if special meta tag exists
|
# Bypass cleanup if special meta tag exists
|
||||||
@ -364,9 +365,9 @@ class EditorWidget(QWebView, LineEditECM): # {{{
|
|||||||
x.tag not in ('script', 'style')]
|
x.tag not in ('script', 'style')]
|
||||||
|
|
||||||
if len(elems) > 1:
|
if len(elems) > 1:
|
||||||
ans = u'<div>%s</div>'%(u''.join(elems))
|
ans = '<div>%s</div>'%(''.join(elems))
|
||||||
else:
|
else:
|
||||||
ans = u''.join(elems)
|
ans = ''.join(elems)
|
||||||
if not ans.startswith('<'):
|
if not ans.startswith('<'):
|
||||||
ans = '<p>%s</p>'%ans
|
ans = '<p>%s</p>'%ans
|
||||||
ans = xml_replace_entities(ans)
|
ans = xml_replace_entities(ans)
|
||||||
@ -482,7 +483,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
if state == State_Comment:
|
if state == State_Comment:
|
||||||
start = pos
|
start = pos
|
||||||
while pos < len_:
|
while pos < len_:
|
||||||
if text[pos:pos+3] == u"-->":
|
if text[pos:pos+3] == "-->":
|
||||||
pos += 3
|
pos += 3
|
||||||
state = State_Text
|
state = State_Text
|
||||||
break
|
break
|
||||||
@ -495,7 +496,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
while pos < len_:
|
while pos < len_:
|
||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
if ch == u'>':
|
if ch == '>':
|
||||||
state = State_Text
|
state = State_Text
|
||||||
break
|
break
|
||||||
self.setFormat(start, pos - start, self.colors['doctype'])
|
self.setFormat(start, pos - start, self.colors['doctype'])
|
||||||
@ -506,7 +507,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
while pos < len_:
|
while pos < len_:
|
||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
if ch == u'>':
|
if ch == '>':
|
||||||
state = State_Text
|
state = State_Text
|
||||||
break
|
break
|
||||||
if not ch.isspace():
|
if not ch.isspace():
|
||||||
@ -524,7 +525,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
pos -= 1
|
pos -= 1
|
||||||
state = State_InsideTag
|
state = State_InsideTag
|
||||||
break
|
break
|
||||||
if ch == u'>':
|
if ch == '>':
|
||||||
state = State_Text
|
state = State_Text
|
||||||
break
|
break
|
||||||
self.setFormat(start, pos - start, self.colors['tag'])
|
self.setFormat(start, pos - start, self.colors['tag'])
|
||||||
@ -537,10 +538,10 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
|
|
||||||
if ch == u'/':
|
if ch == '/':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if ch == u'>':
|
if ch == '>':
|
||||||
state = State_Text
|
state = State_Text
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -557,11 +558,11 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
|
|
||||||
if ch == u'=':
|
if ch == '=':
|
||||||
state = State_AttributeValue
|
state = State_AttributeValue
|
||||||
break
|
break
|
||||||
|
|
||||||
if ch in (u'>', u'/'):
|
if ch in ('>', '/'):
|
||||||
state = State_InsideTag
|
state = State_InsideTag
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -577,12 +578,12 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
pos += 1
|
pos += 1
|
||||||
|
|
||||||
# handle opening single quote
|
# handle opening single quote
|
||||||
if ch == u"'":
|
if ch == "'":
|
||||||
state = State_SingleQuote
|
state = State_SingleQuote
|
||||||
break
|
break
|
||||||
|
|
||||||
# handle opening double quote
|
# handle opening double quote
|
||||||
if ch == u'"':
|
if ch == '"':
|
||||||
state = State_DoubleQuote
|
state = State_DoubleQuote
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -597,7 +598,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
if ch.isspace():
|
if ch.isspace():
|
||||||
break
|
break
|
||||||
if ch in (u'>', u'/'):
|
if ch in ('>', '/'):
|
||||||
break
|
break
|
||||||
pos += 1
|
pos += 1
|
||||||
state = State_InsideTag
|
state = State_InsideTag
|
||||||
@ -610,7 +611,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
while pos < len_:
|
while pos < len_:
|
||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
if ch == u"'":
|
if ch == "'":
|
||||||
break
|
break
|
||||||
|
|
||||||
state = State_InsideTag
|
state = State_InsideTag
|
||||||
@ -624,7 +625,7 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
while pos < len_:
|
while pos < len_:
|
||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
pos += 1
|
pos += 1
|
||||||
if ch == u'"':
|
if ch == '"':
|
||||||
break
|
break
|
||||||
|
|
||||||
state = State_InsideTag
|
state = State_InsideTag
|
||||||
@ -635,18 +636,18 @@ class Highlighter(QSyntaxHighlighter):
|
|||||||
# State_Text and default
|
# State_Text and default
|
||||||
while pos < len_:
|
while pos < len_:
|
||||||
ch = text[pos]
|
ch = text[pos]
|
||||||
if ch == u'<':
|
if ch == '<':
|
||||||
if text[pos:pos+4] == u"<!--":
|
if text[pos:pos+4] == "<!--":
|
||||||
state = State_Comment
|
state = State_Comment
|
||||||
else:
|
else:
|
||||||
if text[pos:pos+9].upper() == u"<!DOCTYPE":
|
if text[pos:pos+9].upper() == "<!DOCTYPE":
|
||||||
state = State_DocType
|
state = State_DocType
|
||||||
else:
|
else:
|
||||||
state = State_TagStart
|
state = State_TagStart
|
||||||
break
|
break
|
||||||
elif ch == u'&':
|
elif ch == '&':
|
||||||
start = pos
|
start = pos
|
||||||
while pos < len_ and text[pos] != u';':
|
while pos < len_ and text[pos] != ';':
|
||||||
self.setFormat(start, pos - start,
|
self.setFormat(start, pos - start,
|
||||||
self.colors['entity'])
|
self.colors['entity'])
|
||||||
pos += 1
|
pos += 1
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -128,7 +128,7 @@ def icon_to_dbus_menu_icon(icon, size=32):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
icon.pixmap(32).save(buf, 'PNG')
|
icon.pixmap(32).save(buf, 'PNG')
|
||||||
return dbus.ByteArray(bytes((ba.data())))
|
return dbus.ByteArray(ba)
|
||||||
|
|
||||||
|
|
||||||
def setup_for_cli_run():
|
def setup_for_cli_run():
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ from calibre.utils.config import tweaks, device_prefs
|
|||||||
from calibre.utils.img import scale_image
|
from calibre.utils.img import scale_image
|
||||||
from calibre.library.save_to_disk import find_plugboard
|
from calibre.library.save_to_disk import find_plugboard
|
||||||
from calibre.ptempfile import PersistentTemporaryFile, force_unicode as filename_to_unicode
|
from calibre.ptempfile import PersistentTemporaryFile, force_unicode as filename_to_unicode
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes
|
from polyglot.builtins import unicode_type, string_or_unicode
|
||||||
from polyglot import queue
|
from polyglot import queue
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
if DEBUG or tb not in self.reported_errors:
|
if DEBUG or tb not in self.reported_errors:
|
||||||
self.reported_errors.add(tb)
|
self.reported_errors.add(tb)
|
||||||
prints('Unable to open device', str(dev))
|
prints('Unable to open device', unicode_type(dev))
|
||||||
prints(tb)
|
prints(tb)
|
||||||
continue
|
continue
|
||||||
self.after_device_connect(dev, device_kind)
|
self.after_device_connect(dev, device_kind)
|
||||||
@ -472,7 +473,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
info = self.device.get_device_information(end_session=False)
|
info = self.device.get_device_information(end_session=False)
|
||||||
if len(info) < 5:
|
if len(info) < 5:
|
||||||
info = tuple(list(info) + [{}])
|
info = tuple(list(info) + [{}])
|
||||||
info = [i.replace('\x00', '').replace('\x01', '') if isinstance(i, string_or_bytes) else i
|
info = [i.replace('\x00', '').replace('\x01', '') if isinstance(i, string_or_unicode) else i
|
||||||
for i in info]
|
for i in info]
|
||||||
cp = self.device.card_prefix(end_session=False)
|
cp = self.device.card_prefix(end_session=False)
|
||||||
fs = self.device.free_space()
|
fs = self.device.free_space()
|
||||||
@ -604,7 +605,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
metadata=None, plugboards=None, add_as_step_to_job=None):
|
metadata=None, plugboards=None, add_as_step_to_job=None):
|
||||||
desc = ngettext('Upload one book to the device', 'Upload {} books to the device', len(names)).format(len(names))
|
desc = ngettext('Upload one book to the device', 'Upload {} books to the device', len(names)).format(len(names))
|
||||||
if titles:
|
if titles:
|
||||||
desc += u': ' + u', '.join(titles)
|
desc += ': ' + ', '.join(titles)
|
||||||
return self.create_job_step(self._upload_books, done, to_job=add_as_step_to_job,
|
return self.create_job_step(self._upload_books, done, to_job=add_as_step_to_job,
|
||||||
args=[files, names],
|
args=[files, names],
|
||||||
kwargs={'on_card':on_card,'metadata':metadata,'plugboards':plugboards}, description=desc)
|
kwargs={'on_card':on_card,'metadata':metadata,'plugboards':plugboards}, description=desc)
|
||||||
@ -930,7 +931,7 @@ class DeviceMixin(object): # {{{
|
|||||||
d.show()
|
d.show()
|
||||||
|
|
||||||
def auto_convert_question(self, msg, autos):
|
def auto_convert_question(self, msg, autos):
|
||||||
autos = u'\n'.join(map(unicode_type, map(force_unicode, autos)))
|
autos = '\n'.join(map(unicode_type, map(force_unicode, autos)))
|
||||||
return self.ask_a_yes_no_question(
|
return self.ask_a_yes_no_question(
|
||||||
_('No suitable formats'), msg,
|
_('No suitable formats'), msg,
|
||||||
ans_when_user_unavailable=True,
|
ans_when_user_unavailable=True,
|
||||||
@ -1343,7 +1344,7 @@ class DeviceMixin(object): # {{{
|
|||||||
self.iactions['Convert Books'].auto_convert_catalogs(auto, format)
|
self.iactions['Convert Books'].auto_convert_catalogs(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
if not files:
|
if not files:
|
||||||
dynamic.set('catalogs_to_be_synced', set([]))
|
dynamic.set('catalogs_to_be_synced', set())
|
||||||
return
|
return
|
||||||
metadata = self.library_view.model().metadata_for(ids)
|
metadata = self.library_view.model().metadata_for(ids)
|
||||||
names = []
|
names = []
|
||||||
@ -1355,7 +1356,7 @@ class DeviceMixin(object): # {{{
|
|||||||
names.append('%s_%d%s'%(prefix, id,
|
names.append('%s_%d%s'%(prefix, id,
|
||||||
os.path.splitext(files[-1])[1]))
|
os.path.splitext(files[-1])[1]))
|
||||||
self.update_thumbnail(mi)
|
self.update_thumbnail(mi)
|
||||||
dynamic.set('catalogs_to_be_synced', set([]))
|
dynamic.set('catalogs_to_be_synced', set())
|
||||||
if files:
|
if files:
|
||||||
remove = []
|
remove = []
|
||||||
space = {self.location_manager.free[0] : None,
|
space = {self.location_manager.free[0] : None,
|
||||||
@ -1627,7 +1628,7 @@ class DeviceMixin(object): # {{{
|
|||||||
|
|
||||||
if job.exception is not None:
|
if job.exception is not None:
|
||||||
if isinstance(job.exception, FreeSpaceError):
|
if isinstance(job.exception, FreeSpaceError):
|
||||||
where = 'in main memory.' if 'memory' in str(job.exception) \
|
where = 'in main memory.' if 'memory' in unicode_type(job.exception) \
|
||||||
else 'on the storage card.'
|
else 'on the storage card.'
|
||||||
titles = '\n'.join(['<li>'+mi.title+'</li>'
|
titles = '\n'.join(['<li>'+mi.title+'</li>'
|
||||||
for mi in metadata])
|
for mi in metadata])
|
||||||
|
@ -156,7 +156,7 @@ class ConfigWidget(QWidget, Ui_ConfigWidget):
|
|||||||
formats = set(self.format_map())
|
formats = set(self.format_map())
|
||||||
extra = formats - set(self.calibre_known_formats)
|
extra = formats - set(self.calibre_known_formats)
|
||||||
if extra:
|
if extra:
|
||||||
fmts = sorted([x.upper() for x in extra])
|
fmts = sorted((x.upper() for x in extra))
|
||||||
if not question_dialog(self, _('Unknown formats'),
|
if not question_dialog(self, _('Unknown formats'),
|
||||||
_('You have enabled the <b>{0}</b> formats for'
|
_('You have enabled the <b>{0}</b> formats for'
|
||||||
' your {1}. The {1} may not support them.'
|
' your {1}. The {1} may not support them.'
|
||||||
|
@ -96,7 +96,7 @@ class Catalog(QDialog, Ui_Dialog):
|
|||||||
self.widgets = sorted(self.widgets, key=lambda x: x.TITLE)
|
self.widgets = sorted(self.widgets, key=lambda x: x.TITLE)
|
||||||
|
|
||||||
# Generate a sorted list of installed catalog formats/sync_enabled pairs
|
# Generate a sorted list of installed catalog formats/sync_enabled pairs
|
||||||
fmts = sorted([x[0] for x in self.fmts])
|
fmts = sorted((x[0] for x in self.fmts))
|
||||||
|
|
||||||
self.sync_enabled_formats = []
|
self.sync_enabled_formats = []
|
||||||
for fmt in self.fmts:
|
for fmt in self.fmts:
|
||||||
|
@ -743,7 +743,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
self.queries = JSONConfig("search_replace_queries")
|
self.queries = JSONConfig("search_replace_queries")
|
||||||
self.saved_search_name = ''
|
self.saved_search_name = ''
|
||||||
self.query_field.addItem("")
|
self.query_field.addItem("")
|
||||||
self.query_field_values = sorted([q for q in self.queries], key=sort_key)
|
self.query_field_values = sorted(self.queries, key=sort_key)
|
||||||
self.query_field.addItems(self.query_field_values)
|
self.query_field.addItems(self.query_field_values)
|
||||||
self.query_field.currentIndexChanged[str].connect(self.s_r_query_change)
|
self.query_field.currentIndexChanged[str].connect(self.s_r_query_change)
|
||||||
self.query_field.setCurrentIndex(0)
|
self.query_field.setCurrentIndex(0)
|
||||||
@ -1323,7 +1323,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
self.query_field.blockSignals(True)
|
self.query_field.blockSignals(True)
|
||||||
self.query_field.clear()
|
self.query_field.clear()
|
||||||
self.query_field.addItem('')
|
self.query_field.addItem('')
|
||||||
self.query_field_values = sorted([q for q in self.queries], key=sort_key)
|
self.query_field_values = sorted(self.queries, key=sort_key)
|
||||||
self.query_field.addItems(self.query_field_values)
|
self.query_field.addItems(self.query_field_values)
|
||||||
self.query_field.blockSignals(False)
|
self.query_field.blockSignals(False)
|
||||||
self.query_field.setCurrentIndex(self.query_field.findText(name))
|
self.query_field.setCurrentIndex(self.query_field.findText(name))
|
||||||
|
@ -76,7 +76,7 @@ def image_to_data(image): # {{{
|
|||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
if not image.save(buf, CACHE_FORMAT):
|
if not image.save(buf, CACHE_FORMAT):
|
||||||
raise EncodeError('Failed to encode thumbnail')
|
raise EncodeError('Failed to encode thumbnail')
|
||||||
ret = bytes(ba.data())
|
ret = ba.data()
|
||||||
buf.close()
|
buf.close()
|
||||||
return ret
|
return ret
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -136,7 +136,7 @@ def get_default_library_path():
|
|||||||
fname.encode(filesystem_encoding)
|
fname.encode(filesystem_encoding)
|
||||||
except Exception:
|
except Exception:
|
||||||
fname = 'Calibre Library'
|
fname = 'Calibre Library'
|
||||||
x = os.path.expanduser('~'+os.sep+fname)
|
x = os.path.expanduser(os.path.join('~', fname))
|
||||||
if not os.path.exists(x):
|
if not os.path.exists(x):
|
||||||
try:
|
try:
|
||||||
os.makedirs(x)
|
os.makedirs(x)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -44,7 +44,7 @@ class DBUSNotifier(Notifier):
|
|||||||
self._notify = dbus.Interface(session_bus.get_object(server, path), interface)
|
self._notify = dbus.Interface(session_bus.get_object(server, path), interface)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.ok = False
|
self.ok = False
|
||||||
self.err = str(err)
|
self.err = unicode_type(err)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
prints(server, 'found' if self.ok else 'not found', 'in', '%.1f' % (time.time() - start), 'seconds')
|
prints(server, 'found' if self.ok else 'not found', 'in', '%.1f' % (time.time() - start), 'seconds')
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -20,7 +20,7 @@ from calibre.gui2.dialogs.confirm_delete import confirm
|
|||||||
from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor
|
from calibre.gui2.dialogs.saved_search_editor import SavedSearchEditor
|
||||||
from calibre.gui2.dialogs.search import SearchDialog
|
from calibre.gui2.dialogs.search import SearchDialog
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
from polyglot.builtins import unicode_type, string_or_bytes, map, range
|
from polyglot.builtins import native_string_type, unicode_type, string_or_bytes, map, range
|
||||||
|
|
||||||
QT_HIDDEN_CLEAR_ACTION = '_q_qlineeditclearaction'
|
QT_HIDDEN_CLEAR_ACTION = '_q_qlineeditclearaction'
|
||||||
|
|
||||||
@ -119,11 +119,11 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
|
|
||||||
c = self.line_edit.completer()
|
c = self.line_edit.completer()
|
||||||
c.setCompletionMode(c.PopupCompletion)
|
c.setCompletionMode(c.PopupCompletion)
|
||||||
c.highlighted[str].connect(self.completer_used)
|
c.highlighted[native_string_type].connect(self.completer_used)
|
||||||
|
|
||||||
self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection)
|
self.line_edit.key_pressed.connect(self.key_pressed, type=Qt.DirectConnection)
|
||||||
# QueuedConnection as workaround for https://bugreports.qt-project.org/browse/QTBUG-40807
|
# QueuedConnection as workaround for https://bugreports.qt-project.org/browse/QTBUG-40807
|
||||||
self.activated[str].connect(self.history_selected, type=Qt.QueuedConnection)
|
self.activated[native_string_type].connect(self.history_selected, type=Qt.QueuedConnection)
|
||||||
self.setEditable(True)
|
self.setEditable(True)
|
||||||
self.as_you_type = True
|
self.as_you_type = True
|
||||||
self.timer = QTimer()
|
self.timer = QTimer()
|
||||||
@ -272,7 +272,7 @@ class SearchBox2(QComboBox): # {{{
|
|||||||
|
|
||||||
def set_search_string(self, txt, store_in_history=False, emit_changed=True):
|
def set_search_string(self, txt, store_in_history=False, emit_changed=True):
|
||||||
if not store_in_history:
|
if not store_in_history:
|
||||||
self.activated[str].disconnect()
|
self.activated[native_string_type].disconnect()
|
||||||
try:
|
try:
|
||||||
self.setFocus(Qt.OtherFocusReason)
|
self.setFocus(Qt.OtherFocusReason)
|
||||||
if not txt:
|
if not txt:
|
||||||
|
@ -28,7 +28,7 @@ from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
|||||||
class WHSmithUKStore(BasicStoreConfig, StorePlugin):
|
class WHSmithUKStore(BasicStoreConfig, StorePlugin):
|
||||||
|
|
||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
url = 'http://www.whsmith.co.uk/'
|
url = 'https://www.whsmith.co.uk/'
|
||||||
url_details = ''
|
url_details = ''
|
||||||
|
|
||||||
if external or self.config.get('open_external', False):
|
if external or self.config.get('open_external', False):
|
||||||
@ -45,7 +45,7 @@ class WHSmithUKStore(BasicStoreConfig, StorePlugin):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
url = ('http://www.whsmith.co.uk/search?keywordCategoryId=wc_dept_ebooks&results=60'
|
url = ('https://www.whsmith.co.uk/search?keywordCategoryId=wc_dept_ebooks&results=60'
|
||||||
'&page=1&keywords=' + quote(query))
|
'&page=1&keywords=' + quote(query))
|
||||||
|
|
||||||
br = browser()
|
br = browser()
|
||||||
@ -59,7 +59,7 @@ class WHSmithUKStore(BasicStoreConfig, StorePlugin):
|
|||||||
id_ = ''.join(data.xpath('./a[@class="product_image_wrap"]/@href'))
|
id_ = ''.join(data.xpath('./a[@class="product_image_wrap"]/@href'))
|
||||||
if not id_:
|
if not id_:
|
||||||
continue
|
continue
|
||||||
id_ = 'http://www.whsmith.co.uk' + id_
|
id_ = 'https://www.whsmith.co.uk' + id_
|
||||||
cover_url = ''.join(data.xpath('.//img[@class="product_image"]/@src'))
|
cover_url = ''.join(data.xpath('.//img[@class="product_image"]/@src'))
|
||||||
title = ''.join(data.xpath('.//h4[@class="product_title"]/text()'))
|
title = ''.join(data.xpath('.//h4[@class="product_title"]/text()'))
|
||||||
author = ', '.join(data.xpath('.//span[@class="product_second"]/text()'))
|
author = ', '.join(data.xpath('.//span[@class="product_second"]/text()'))
|
||||||
|
@ -36,7 +36,7 @@ def as_base64(data):
|
|||||||
|
|
||||||
|
|
||||||
def search(query, max_results=10, timeout=60):
|
def search(query, max_results=10, timeout=60):
|
||||||
url = 'http://woblink.com/publication/ajax?mode=none&query=' + quote_plus(query)
|
url = 'https://woblink.com/publication/ajax?mode=none&query=' + quote_plus(query)
|
||||||
if max_results > 10:
|
if max_results > 10:
|
||||||
if max_results > 20:
|
if max_results > 20:
|
||||||
url += '&limit=30'
|
url += '&limit=30'
|
||||||
@ -47,7 +47,7 @@ def search(query, max_results=10, timeout=60):
|
|||||||
rq = Request(url, headers={
|
rq = Request(url, headers={
|
||||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
'Referrer':'http://woblink.com/ebooki-kategorie',
|
'Referrer':'https://woblink.com/ebooki-kategorie',
|
||||||
'Cache-Control':'max-age=0',
|
'Cache-Control':'max-age=0',
|
||||||
}, data=urlencode({
|
}, data=urlencode({
|
||||||
'nw_filtry_filtr_zakrescen_formularz[min]':'0',
|
'nw_filtry_filtr_zakrescen_formularz[min]':'0',
|
||||||
@ -89,13 +89,13 @@ class WoblinkStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/16/58/'
|
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/16/58/'
|
||||||
url = 'http://woblink.com/publication'
|
url = 'https://woblink.com/publication'
|
||||||
|
|
||||||
aff_url = aff_root + as_base64(url)
|
aff_url = aff_root + as_base64(url)
|
||||||
detail_url = None
|
detail_url = None
|
||||||
|
|
||||||
if detail_item:
|
if detail_item:
|
||||||
detail_url = aff_root + as_base64('http://woblink.com' + detail_item)
|
detail_url = aff_root + as_base64('https://woblink.com' + detail_item)
|
||||||
|
|
||||||
if external or self.config.get('open_external', False):
|
if external or self.config.get('open_external', False):
|
||||||
open_url(QUrl(url_slash_cleaner(detail_url if detail_url else aff_url)))
|
open_url(QUrl(url_slash_cleaner(detail_url if detail_url else aff_url)))
|
||||||
|
@ -29,7 +29,7 @@ class WolneLekturyStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
def open(self, parent=None, detail_item=None, external=False):
|
def open(self, parent=None, detail_item=None, external=False):
|
||||||
|
|
||||||
url = 'http://wolnelektury.pl'
|
url = 'https://wolnelektury.pl'
|
||||||
detail_url = None
|
detail_url = None
|
||||||
|
|
||||||
if detail_item:
|
if detail_item:
|
||||||
@ -44,7 +44,7 @@ class WolneLekturyStore(BasicStoreConfig, StorePlugin):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
url = 'http://wolnelektury.pl/szukaj?q=' + quote_plus(query)
|
url = 'https://wolnelektury.pl/szukaj?q=' + quote_plus(query)
|
||||||
|
|
||||||
br = browser()
|
br = browser()
|
||||||
|
|
||||||
@ -69,13 +69,13 @@ class WolneLekturyStore(BasicStoreConfig, StorePlugin):
|
|||||||
s = SearchResult()
|
s = SearchResult()
|
||||||
for link in data.xpath('.//div[@class="book-box-formats"]/span/a'):
|
for link in data.xpath('.//div[@class="book-box-formats"]/span/a'):
|
||||||
ext = ''.join(link.xpath('./text()'))
|
ext = ''.join(link.xpath('./text()'))
|
||||||
href = 'http://wolnelektury.pl' + link.get('href')
|
href = 'https://wolnelektury.pl' + link.get('href')
|
||||||
s.downloads[ext] = href
|
s.downloads[ext] = href
|
||||||
s.cover_url = 'http://wolnelektury.pl' + cover_url.strip()
|
s.cover_url = 'https://wolnelektury.pl' + cover_url.strip()
|
||||||
s.title = title.strip()
|
s.title = title.strip()
|
||||||
s.author = author
|
s.author = author
|
||||||
s.price = price
|
s.price = price
|
||||||
s.detail_item = 'http://wolnelektury.pl' + id
|
s.detail_item = 'https://wolnelektury.pl' + id
|
||||||
s.formats = ', '.join(s.downloads.keys())
|
s.formats = ', '.join(s.downloads.keys())
|
||||||
s.drm = SearchResult.DRM_UNLOCKED
|
s.drm = SearchResult.DRM_UNLOCKED
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ from calibre.gui2.store.search_result import SearchResult
|
|||||||
|
|
||||||
class XinXiiStore(BasicStoreConfig, OpenSearchOPDSStore):
|
class XinXiiStore(BasicStoreConfig, OpenSearchOPDSStore):
|
||||||
|
|
||||||
open_search_url = 'http://www.xinxii.com/catalog-search/'
|
open_search_url = 'https://www.xinxii.com/catalog-search/'
|
||||||
web_url = 'http://xinxii.com/'
|
web_url = 'https://xinxii.com/'
|
||||||
|
|
||||||
# http://www.xinxii.com/catalog/
|
# https://www.xinxii.com/catalog/
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
'''
|
'''
|
||||||
@ -42,7 +42,7 @@ class XinXiiStore(BasicStoreConfig, OpenSearchOPDSStore):
|
|||||||
function so this one is modified to remove parts that are used.
|
function so this one is modified to remove parts that are used.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
url = 'http://www.xinxii.com/catalog-search/query/?keywords=' + quote_plus(query)
|
url = 'https://www.xinxii.com/catalog-search/query/?keywords=' + quote_plus(query)
|
||||||
|
|
||||||
counter = max_results
|
counter = max_results
|
||||||
br = browser()
|
br = browser()
|
||||||
|
@ -857,7 +857,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
fm['datatype'] == 'composite' and
|
fm['datatype'] == 'composite' and
|
||||||
fm['display'].get('make_category', False)))):
|
fm['display'].get('make_category', False)))):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
ids = list(map(int, str(md.data(mime)).split()))
|
ids = list(map(int, md.data(mime).data().split()))
|
||||||
self.handle_drop(node, ids)
|
self.handle_drop(node, ids)
|
||||||
return True
|
return True
|
||||||
elif node.type == TagTreeItem.CATEGORY:
|
elif node.type == TagTreeItem.CATEGORY:
|
||||||
@ -871,7 +871,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
(fm_src['datatype'] == 'composite' and
|
(fm_src['datatype'] == 'composite' and
|
||||||
fm_src['display'].get('make_category', False))):
|
fm_src['display'].get('make_category', False))):
|
||||||
mime = 'application/calibre+from_library'
|
mime = 'application/calibre+from_library'
|
||||||
ids = list(map(int, str(md.data(mime)).split()))
|
ids = list(map(int, md.data(mime).data().split()))
|
||||||
self.handle_user_category_drop(node, ids, md.column_name)
|
self.handle_user_category_drop(node, ids, md.column_name)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -67,7 +67,7 @@ class AddDictionary(QDialog): # {{{
|
|||||||
download more dictionaries from <a href="{1}">the LibreOffice extensions repository</a>.
|
download more dictionaries from <a href="{1}">the LibreOffice extensions repository</a>.
|
||||||
The dictionary will download as an .oxt file. Simply specify the path to the
|
The dictionary will download as an .oxt file. Simply specify the path to the
|
||||||
downloaded .oxt file here to add the dictionary to {0}.''').format(
|
downloaded .oxt file here to add the dictionary to {0}.''').format(
|
||||||
__appname__, 'http://extensions.libreoffice.org/extension-center?getCategories=Dictionary&getCompatibility=any&sort_on=positive_ratings')+'<p>') # noqa
|
__appname__, 'https://extensions.libreoffice.org/extension-center?getCategories=Dictionary&getCompatibility=any&sort_on=positive_ratings')+'<p>') # noqa
|
||||||
la.setWordWrap(True)
|
la.setWordWrap(True)
|
||||||
la.setOpenExternalLinks(True)
|
la.setOpenExternalLinks(True)
|
||||||
la.setMinimumWidth(450)
|
la.setMinimumWidth(450)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from __future__ import print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
'''
|
'''
|
||||||
@ -23,7 +24,7 @@ from calibre.gui2.progress_indicator import ProgressIndicator as _ProgressIndica
|
|||||||
from calibre.gui2.dnd import (dnd_has_image, dnd_get_image, dnd_get_files,
|
from calibre.gui2.dnd import (dnd_has_image, dnd_get_image, dnd_get_files,
|
||||||
image_extensions, dnd_has_extension, DownloadDialog)
|
image_extensions, dnd_has_extension, DownloadDialog)
|
||||||
from calibre.utils.localization import localize_user_manual_link
|
from calibre.utils.localization import localize_user_manual_link
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import native_string_type, unicode_type, range
|
||||||
|
|
||||||
history = XMLConfig('history')
|
history = XMLConfig('history')
|
||||||
|
|
||||||
@ -45,11 +46,11 @@ class ProgressIndicator(QWidget): # {{{
|
|||||||
pwidth, pheight = view.size().width(), view.size().height()
|
pwidth, pheight = view.size().width(), view.size().height()
|
||||||
self.resize(pwidth, min(pheight, 250))
|
self.resize(pwidth, min(pheight, 250))
|
||||||
if self.pos is None:
|
if self.pos is None:
|
||||||
self.move(0, (pheight-self.size().height())/2.)
|
self.move(0, (pheight-self.size().height())/2)
|
||||||
else:
|
else:
|
||||||
self.move(self.pos[0], self.pos[1])
|
self.move(self.pos[0], self.pos[1])
|
||||||
self.pi.resize(self.pi.sizeHint())
|
self.pi.resize(self.pi.sizeHint())
|
||||||
self.pi.move(int((self.size().width()-self.pi.size().width())/2.), 0)
|
self.pi.move(int((self.size().width()-self.pi.size().width())//2), 0)
|
||||||
self.status.resize(self.size().width(), self.size().height()-self.pi.size().height()-10)
|
self.status.resize(self.size().width(), self.size().height()-self.pi.size().height()-10)
|
||||||
self.status.move(0, self.pi.size().height()+10)
|
self.status.move(0, self.pi.size().height()+10)
|
||||||
self.status.setText('<h1>'+msg+'</h1>')
|
self.status.setText('<h1>'+msg+'</h1>')
|
||||||
@ -137,7 +138,7 @@ class FilenamePattern(QWidget, Ui_Form): # {{{
|
|||||||
self.series.setText(_('No match'))
|
self.series.setText(_('No match'))
|
||||||
|
|
||||||
if mi.series_index is not None:
|
if mi.series_index is not None:
|
||||||
self.series_index.setText(str(mi.series_index))
|
self.series_index.setText(unicode_type(mi.series_index))
|
||||||
else:
|
else:
|
||||||
self.series_index.setText(_('No match'))
|
self.series_index.setText(_('No match'))
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ class FilenamePattern(QWidget, Ui_Form): # {{{
|
|||||||
else:
|
else:
|
||||||
self.pubdate.setText(_('No match'))
|
self.pubdate.setText(_('No match'))
|
||||||
|
|
||||||
self.isbn.setText(_('No match') if mi.isbn is None else str(mi.isbn))
|
self.isbn.setText(_('No match') if mi.isbn is None else unicode_type(mi.isbn))
|
||||||
self.comments.setText(mi.comments if mi.comments else _('No match'))
|
self.comments.setText(mi.comments if mi.comments else _('No match'))
|
||||||
|
|
||||||
def pattern(self):
|
def pattern(self):
|
||||||
@ -304,7 +305,7 @@ def draw_size(p, rect, w, h):
|
|||||||
f = p.font()
|
f = p.font()
|
||||||
f.setBold(True)
|
f.setBold(True)
|
||||||
p.setFont(f)
|
p.setFont(f)
|
||||||
sz = u'\u00a0%d x %d\u00a0'%(w, h)
|
sz = '\u00a0%d x %d\u00a0'%(w, h)
|
||||||
flags = Qt.AlignBottom|Qt.AlignRight|Qt.TextSingleLine
|
flags = Qt.AlignBottom|Qt.AlignRight|Qt.TextSingleLine
|
||||||
szrect = p.boundingRect(rect, flags, sz)
|
szrect = p.boundingRect(rect, flags, sz)
|
||||||
p.fillRect(szrect.adjusted(0, 0, 0, 4), QColor(0, 0, 0, 200))
|
p.fillRect(szrect.adjusted(0, 0, 0, 4), QColor(0, 0, 0, 200))
|
||||||
@ -369,8 +370,8 @@ class ImageView(QWidget, ImageDropMixin):
|
|||||||
pmap = pmap.scaled(int(nw*pmap.devicePixelRatio()), int(nh*pmap.devicePixelRatio()), Qt.IgnoreAspectRatio,
|
pmap = pmap.scaled(int(nw*pmap.devicePixelRatio()), int(nh*pmap.devicePixelRatio()), Qt.IgnoreAspectRatio,
|
||||||
Qt.SmoothTransformation)
|
Qt.SmoothTransformation)
|
||||||
w, h = int(pmap.width()/pmap.devicePixelRatio()), int(pmap.height()/pmap.devicePixelRatio())
|
w, h = int(pmap.width()/pmap.devicePixelRatio()), int(pmap.height()/pmap.devicePixelRatio())
|
||||||
x = int(abs(cw - w)/2.)
|
x = int(abs(cw - w)//2)
|
||||||
y = int(abs(ch - h)/2.)
|
y = int(abs(ch - h)//2)
|
||||||
target = QRect(x, y, w, h)
|
target = QRect(x, y, w, h)
|
||||||
p = QPainter(self)
|
p = QPainter(self)
|
||||||
p.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
|
p.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
|
||||||
@ -570,7 +571,7 @@ class CompleteLineEdit(EnLineEdit): # {{{
|
|||||||
self.completer = ItemsCompleter(self, complete_items)
|
self.completer = ItemsCompleter(self, complete_items)
|
||||||
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
|
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
|
||||||
|
|
||||||
self.completer.activated[str].connect(self.complete_text)
|
self.completer.activated[native_string_type].connect(self.complete_text)
|
||||||
|
|
||||||
self.completer.setWidget(self)
|
self.completer.setWidget(self)
|
||||||
|
|
||||||
@ -888,13 +889,13 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
self.setFormat(0, textLength,
|
self.setFormat(0, textLength,
|
||||||
PythonHighlighter.Formats["normal"])
|
PythonHighlighter.Formats["normal"])
|
||||||
|
|
||||||
if text.startswith(u"Traceback") or text.startswith(u"Error: "):
|
if text.startswith("Traceback") or text.startswith("Error: "):
|
||||||
self.setCurrentBlockState(ERROR)
|
self.setCurrentBlockState(ERROR)
|
||||||
self.setFormat(0, textLength,
|
self.setFormat(0, textLength,
|
||||||
PythonHighlighter.Formats["error"])
|
PythonHighlighter.Formats["error"])
|
||||||
return
|
return
|
||||||
if prevState == ERROR and \
|
if prevState == ERROR and \
|
||||||
not (text.startswith(u'>>>') or text.startswith(u"#")):
|
not (text.startswith('>>>') or text.startswith("#")):
|
||||||
self.setCurrentBlockState(ERROR)
|
self.setCurrentBlockState(ERROR)
|
||||||
self.setFormat(0, textLength,
|
self.setFormat(0, textLength,
|
||||||
PythonHighlighter.Formats["error"])
|
PythonHighlighter.Formats["error"])
|
||||||
@ -913,18 +914,18 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
# PythonHighlighter.Rules.append((QRegExp(r"#.*"), "comment"))
|
# PythonHighlighter.Rules.append((QRegExp(r"#.*"), "comment"))
|
||||||
if not text:
|
if not text:
|
||||||
pass
|
pass
|
||||||
elif text[0] == u"#":
|
elif text[0] == "#":
|
||||||
self.setFormat(0, len(text),
|
self.setFormat(0, len(text),
|
||||||
PythonHighlighter.Formats["comment"])
|
PythonHighlighter.Formats["comment"])
|
||||||
else:
|
else:
|
||||||
stack = []
|
stack = []
|
||||||
for i, c in enumerate(text):
|
for i, c in enumerate(text):
|
||||||
if c in (u'"', u"'"):
|
if c in ('"', "'"):
|
||||||
if stack and stack[-1] == c:
|
if stack and stack[-1] == c:
|
||||||
stack.pop()
|
stack.pop()
|
||||||
else:
|
else:
|
||||||
stack.append(c)
|
stack.append(c)
|
||||||
elif c == u"#" and len(stack) == 0:
|
elif c == "#" and len(stack) == 0:
|
||||||
self.setFormat(i, len(text),
|
self.setFormat(i, len(text),
|
||||||
PythonHighlighter.Formats["comment"])
|
PythonHighlighter.Formats["comment"])
|
||||||
break
|
break
|
||||||
|
@ -23,7 +23,7 @@ if iswindows:
|
|||||||
except:
|
except:
|
||||||
raise RuntimeError('NUL file missing in windows. This indicates a'
|
raise RuntimeError('NUL file missing in windows. This indicates a'
|
||||||
' corrupted windows. You should contact Microsoft'
|
' corrupted windows. You should contact Microsoft'
|
||||||
' for assistance and/or follow the steps described here: http://bytes.com/topic/net/answers/264804-compile-error-null-device-missing')
|
' for assistance and/or follow the steps described here: https://bytes.com/topic/net/answers/264804-compile-error-null-device-missing')
|
||||||
|
|
||||||
|
|
||||||
def renice(niceness):
|
def renice(niceness):
|
||||||
|
@ -90,10 +90,10 @@ def extract_member(
|
|||||||
|
|
||||||
def extract_first_alphabetically(stream):
|
def extract_first_alphabetically(stream):
|
||||||
from calibre.libunzip import sort_key
|
from calibre.libunzip import sort_key
|
||||||
names_ = sorted([
|
names_ = sorted((
|
||||||
x for x in names(stream)
|
x for x in names(stream)
|
||||||
if os.path.splitext(x)[1][1:].lower() in {
|
if os.path.splitext(x)[1][1:].lower() in {
|
||||||
'png', 'jpg', 'jpeg', 'gif', 'webp'}],
|
'png', 'jpg', 'jpeg', 'gif', 'webp'}),
|
||||||
key=sort_key)
|
key=sort_key)
|
||||||
return extract_member(stream, name=names_[0], match=None)
|
return extract_member(stream, name=names_[0], match=None)
|
||||||
|
|
||||||
|
@ -68,4 +68,4 @@ def to_png(bmp):
|
|||||||
buf = QBuffer(ba)
|
buf = QBuffer(ba)
|
||||||
buf.open(QBuffer.WriteOnly)
|
buf.open(QBuffer.WriteOnly)
|
||||||
i.save(buf, 'png')
|
i.save(buf, 'png')
|
||||||
return bytes(ba.data())
|
return ba.data()
|
||||||
|
@ -72,6 +72,7 @@ if is_py3:
|
|||||||
codepoint_to_chr = chr
|
codepoint_to_chr = chr
|
||||||
unicode_type = str
|
unicode_type = str
|
||||||
string_or_bytes = str, bytes
|
string_or_bytes = str, bytes
|
||||||
|
string_or_unicode = str
|
||||||
long_type = int
|
long_type = int
|
||||||
raw_input = input
|
raw_input = input
|
||||||
getcwd = os.getcwd
|
getcwd = os.getcwd
|
||||||
@ -126,6 +127,7 @@ else:
|
|||||||
codepoint_to_chr = unichr
|
codepoint_to_chr = unichr
|
||||||
unicode_type = unicode
|
unicode_type = unicode
|
||||||
string_or_bytes = unicode, bytes
|
string_or_bytes = unicode, bytes
|
||||||
|
string_or_unicode = str, unicode
|
||||||
long_type = long
|
long_type = long
|
||||||
exec_path = execfile
|
exec_path = execfile
|
||||||
raw_input = builtins.raw_input
|
raw_input = builtins.raw_input
|
||||||
|
Loading…
x
Reference in New Issue
Block a user