py3: more work toward universal __future__s

This commit is contained in:
Eli Schwartz 2019-08-28 16:50:30 -04:00
parent cf24ed3d00
commit b4dfa7378f
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
55 changed files with 111 additions and 57 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
@ -271,7 +271,7 @@ class Widget(QWidget):
def setup_widget_help(self, g):
w = textwrap.TextWrapper(80)
htext = u'<div>%s</div>'%prepare_string_for_xml('\n'.join(w.wrap(g._help)))
htext = '<div>%s</div>'%prepare_string_for_xml('\n'.join(w.wrap(g._help)))
g.setToolTip(htext)
g.setWhatsThis(htext)
g.__class__.enterEvent = lambda obj, event: self.set_help(getattr(obj, '_help', obj.toolTip()))

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
@ -24,8 +25,8 @@ class HeuristicsWidget(Widget, Ui_Form):
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent, OPTIONS['pipe']['heuristics'])
self.db, self.book_id = db, book_id
self.rssb_defaults = [u'', u'<hr />', u' ', u'• • •', u'♦ ♦ ♦',
u'† †', u'‡ ‡ ‡', u'∞ ∞ ∞', u'¤ ¤ ¤', u'§']
self.rssb_defaults = ['', '<hr />', ' ', '• • •', '♦ ♦ ♦',
'† †', '‡ ‡ ‡', '∞ ∞ ∞', '¤ ¤ ¤', '§']
self.initialize_options(get_option, get_help, db, book_id)
self.load_histories()

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
@ -204,7 +204,7 @@ class MetadataWidget(Widget, Ui_Form):
cover = f.read()
except IOError as e:
d = error_dialog(self.parent(), _('Error reading file'),
_("<p>There was an error reading from file: <br /><b>") + _file + "</b></p><br />"+str(e))
_("<p>There was an error reading from file: <br /><b>") + _file + "</b></p><br />"+unicode_type(e))
d.exec_()
if cover:
pix = QPixmap()

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
@ -101,7 +102,7 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
if self.match_locs:
self.next.setEnabled(True)
self.previous.setEnabled(True)
self.occurrences.setText(str(len(self.match_locs)))
self.occurrences.setText(unicode_type(len(self.match_locs)))
def goto_previous(self):
pos = self.preview.textCursor().position()

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>, 2012 Eli Algranti <idea00@hotmail.com>'
@ -131,7 +132,7 @@ class SearchAndReplaceWidget(Widget, Ui_Form):
if filename:
with codecs.open(filename, 'w', 'utf-8') as f:
for search, replace in self.get_definitions():
f.write(escape(search) + u'\n' + escape(replace) + u'\n\n')
f.write(escape(search) + '\n' + escape(replace) + '\n\n')
def sr_up_clicked(self):
self.cell_rearrange(-1)

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2010, Li Fanxi <lifanxi@freemindworld.com>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement
from __future__ import print_function
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -11,7 +11,7 @@ from PyQt5.Qt import (
QObject, QMenuBar, QAction, QEvent, QSystemTrayIcon, QApplication, Qt)
from calibre.constants import iswindows, isosx
from polyglot.builtins import range
from polyglot.builtins import range, unicode_type
UNITY_WINDOW_REGISTRAR = ('com.canonical.AppMenu.Registrar', '/com/canonical/AppMenu/Registrar', 'com.canonical.AppMenu.Registrar')
STATUS_NOTIFIER = ("org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher", "org.kde.StatusNotifierWatcher")
@ -124,7 +124,7 @@ class Factory(QObject):
import dbus
self.dbus = dbus
except ImportError as err:
log('Failed to import dbus, with error:', str(err))
log('Failed to import dbus, with error:', unicode_type(err))
self.dbus = None
self.menu_registrar = None
@ -163,7 +163,7 @@ class Factory(QObject):
self._bus.watch_name_owner(UNITY_WINDOW_REGISTRAR[0], self.window_registrar_changed)
self._bus.watch_name_owner(STATUS_NOTIFIER[0], self.status_notifier_registrar_changed)
except Exception as err:
log('Failed to connect to DBUS session bus, with error:', str(err))
log('Failed to connect to DBUS session bus, with error:', unicode_type(err))
self._bus = False
return self._bus or None
@ -177,7 +177,7 @@ class Factory(QObject):
self.detect_menu_registrar()
except Exception as err:
self.menu_registrar = False
log('Failed to detect window menu registrar, with error:', str(err))
log('Failed to detect window menu registrar, with error:', unicode_type(err))
return bool(self.menu_registrar)
def detect_menu_registrar(self):
@ -195,7 +195,7 @@ class Factory(QObject):
self.detect_status_notifier()
except Exception as err:
self.status_notifier = False
log('Failed to detect window status notifier, with error:', str(err))
log('Failed to detect window status notifier, with error:', unicode_type(err))
return bool(self.status_notifier)
def detect_status_notifier(self):

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL 3'
__copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'

View File

@ -1,3 +1,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''Various dialogs used in the GUI'''

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__license__ = 'GPL v3'

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__license__ = 'GPL v3'

View File

@ -1,4 +1,5 @@
from __future__ import print_function
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>'

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__license__ = 'GPL v3'

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net' \
'2010, John Schember <john@nachtimwald.com>'

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
@ -19,4 +21,3 @@ class ConversionErrorDialog(QDialog, Ui_ConversionErrorDialog):
def set_message(self, html):
self.text.setHtml('<html><body>%s</body></html'%(html,))

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__license__ = 'GPL v3'

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__license__ = 'GPL v3'

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
@ -417,7 +417,7 @@ class JobError(QDialog): # {{{
d = QTextDocument()
d.setHtml(self.msg_label.text())
QApplication.clipboard().setText(
u'calibre, version %s (%s, embedded-python: %s)\n%s: %s\n\n%s' %
'calibre, version %s (%s, embedded-python: %s)\n%s: %s\n\n%s' %
(__version__, sys.platform, isfrozen,
unicode_type(self.windowTitle()), unicode_type(d.toPlainText()),
unicode_type(self.det_msg.toPlainText())))
@ -444,7 +444,7 @@ class JobError(QDialog): # {{{
self.bb.button(self.bb.Close).setFocus(Qt.OtherFocusReason)
return ret
def show_error(self, title, msg, det_msg=u'', retry_func=None):
def show_error(self, title, msg, det_msg='', retry_func=None):
self.queue.append((title, msg, det_msg, retry_func))
self.update_suppress_state()
self.pop()

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import print_function
from __future__ import absolute_import, division, print_function, unicode_literals
import re, numbers
from collections import defaultdict, namedtuple
@ -32,7 +32,9 @@ from calibre.utils.date import qt_to_dt, internal_iso_format_string
from calibre.utils.icu import capitalize, sort_key
from calibre.utils.titlecase import titlecase
from calibre.gui2.widgets import LineEditECM
from polyglot.builtins import iteritems, itervalues, unicode_type, error_message, filter
from polyglot.builtins import (
error_message, filter, iteritems, itervalues, native_string_type, unicode_type
)
Settings = namedtuple('Settings',
'remove_all remove add au aus do_aus rating pub do_series do_autonumber '
@ -715,10 +717,10 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.destination_field.currentIndexChanged[int].connect(self.s_r_destination_field_changed)
self.replace_mode.currentIndexChanged[int].connect(self.s_r_paint_results)
self.replace_func.currentIndexChanged[str].connect(self.s_r_paint_results)
self.search_for.editTextChanged[str].connect(self.s_r_paint_results)
self.replace_with.editTextChanged[str].connect(self.s_r_paint_results)
self.test_text.editTextChanged[str].connect(self.s_r_paint_results)
self.replace_func.currentIndexChanged[native_string_type].connect(self.s_r_paint_results)
self.search_for.editTextChanged[native_string_type].connect(self.s_r_paint_results)
self.replace_with.editTextChanged[native_string_type].connect(self.s_r_paint_results)
self.test_text.editTextChanged[native_string_type].connect(self.s_r_paint_results)
self.comma_separated.stateChanged.connect(self.s_r_paint_results)
self.case_sensitive.stateChanged.connect(self.s_r_paint_results)
self.s_r_src_ident.currentIndexChanged[int].connect(self.s_r_identifier_type_changed)
@ -745,7 +747,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
self.query_field.addItem("")
self.query_field_values = sorted(self.queries, key=sort_key)
self.query_field.addItems(self.query_field_values)
self.query_field.currentIndexChanged[str].connect(self.s_r_query_change)
self.query_field.currentIndexChanged[native_string_type].connect(self.s_r_query_change)
self.query_field.setCurrentIndex(0)
self.search_field.setCurrentIndex(0)
self.s_r_search_field_changed(0)
@ -774,14 +776,14 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
else:
val = mi.get(field, None)
if isinstance(val, (numbers.Number, bool)):
val = str(val)
val = unicode_type(val)
elif fm['is_csp']:
# convert the csp dict into a list
id_type = unicode_type(self.s_r_src_ident.currentText())
if id_type:
val = [val.get(id_type, '')]
else:
val = [u'%s:%s'%(t[0], t[1]) for t in iteritems(val)]
val = ['%s:%s'%(t[0], t[1]) for t in iteritems(val)]
if val is None:
val = [] if fm['is_multiple'] else ['']
elif not fm['is_multiple']:
@ -959,7 +961,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
dest_val = [dest_val.get(dst_id_type, '')]
else:
# convert the csp dict into a list
dest_val = [u'%s:%s'%(t[0], t[1]) for t in iteritems(dest_val)]
dest_val = ['%s:%s'%(t[0], t[1]) for t in iteritems(dest_val)]
if dest_val is None:
dest_val = []
elif not isinstance(dest_val, list):

View File

@ -1,5 +1,8 @@
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import re
from PyQt5.Qt import QDialog, QLineEdit, Qt

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
@ -16,7 +18,7 @@ class ProgressDialog(QDialog):
canceled_signal = pyqtSignal()
def __init__(self, title, msg=u'\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None):
def __init__(self, title, msg='\u00a0', min=0, max=99, parent=None, cancelable=True, icon=None):
QDialog.__init__(self, parent)
if icon is None:
self.l = l = QVBoxLayout(self)

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from PyQt5.Qt import (

View File

@ -1,4 +1,5 @@
from __future__ import with_statement
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
@ -477,7 +478,7 @@ class SchedulerDialog(QDialog):
self.recipe_model.un_schedule_recipe(urn)
add_title_tag = self.add_title_tag.isChecked()
keep_issues = u'0'
keep_issues = '0'
if self.keep_issues.isEnabled():
keep_issues = unicode_type(self.keep_issues.value())
custom_tags = unicode_type(self.custom_tags.text()).strip()
@ -556,7 +557,7 @@ class SchedulerDialog(QDialog):
self.schedule_stack.currentWidget().initialize(typ, sch)
add_title_tag, custom_tags, keep_issues = customize_info
self.add_title_tag.setChecked(add_title_tag)
self.custom_tags.setText(u', '.join(custom_tags))
self.custom_tags.setText(', '.join(custom_tags))
self.last_downloaded.setText(_('Last downloaded:') + ' ' + ld_text)
try:
keep_issues = int(keep_issues)

View File

@ -1,4 +1,5 @@
from __future__ import print_function
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
@ -200,7 +201,7 @@ def create_date_tab(self, db):
dm.addItem(text, val)
self.date_day = dd = add(_('&day'), QSpinBox(w))
dd.setRange(0, 31)
dd.setSpecialValueText(u' \xa0')
dd.setSpecialValueText(' \xa0')
h.addStretch(10)
w.h3 = h = QHBoxLayout()

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement
from __future__ import print_function
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,5 +1,6 @@
__license__ = 'GPL v3'
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
from PyQt5.Qt import (

View File

@ -1,4 +1,5 @@
from __future__ import print_function
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
from PyQt5.Qt import (Qt, QDialog, QTableWidgetItem, QIcon, QByteArray, QSize,
@ -68,7 +67,7 @@ class NameTableWidgetItem(QTableWidgetItem):
class CountTableWidgetItem(QTableWidgetItem):
def __init__(self, count):
QTableWidgetItem.__init__(self, str(count))
QTableWidgetItem.__init__(self, unicode_type(count))
self._count = count
def __ge__(self, other):

View File

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import absolute_import, division, print_function, unicode_literals
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__license__ = 'GPL v3'
@ -20,7 +22,7 @@ from calibre.ebooks.metadata.book.formatter import SafeFormat
from calibre.library.coloring import (displayable_columns, color_row_key)
from calibre.gui2 import error_dialog, choose_files, pixmap_to_data
from calibre.utils.localization import localize_user_manual_link
from polyglot.builtins import unicode_type
from polyglot.builtins import native_string_type, unicode_type
class ParenPosition:
@ -330,7 +332,7 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
self.function.addItem('')
self.function.addItems(func_names)
self.function.setCurrentIndex(0)
self.function.currentIndexChanged[str].connect(self.function_changed)
self.function.currentIndexChanged[native_string_type].connect(self.function_changed)
self.textbox_changed()
self.rule = (None, '')

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2
# 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'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
@ -51,7 +52,7 @@ class UpdateEditorGeometry(object):
else:
# The line edit box seems to extend by the space consumed by an 'M'.
# So add that to the text
text = self.displayText(index.data(Qt.DisplayRole), QLocale()) + u'M'
text = self.displayText(index.data(Qt.DisplayRole), QLocale()) + 'M'
srect = style.itemTextRect(fm, editor.geometry(), Qt.AlignLeft, False, text)
new_width = srect.width()
@ -581,7 +582,7 @@ class CcNumberDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
val = editor.maximum()
text = editor.textFromValue(val)
srect = style.itemTextRect(fm, editor.geometry(), Qt.AlignLeft, False,
text + u'M')
text + 'M')
return srect.width()
# }}}
@ -619,7 +620,7 @@ class CcEnumDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
def get_required_width(self, editor, style, fm):
srect = style.itemTextRect(fm, editor.geometry(), Qt.AlignLeft, False,
self.longest_text + u'M')
self.longest_text + 'M')
return srect.width()
def setEditorData(self, editor, index):
@ -722,7 +723,7 @@ class CcBoolDelegate(QStyledItemDelegate, UpdateEditorGeometry): # {{{
def get_required_width(self, editor, style, fm):
srect = style.itemTextRect(fm, editor.geometry(), Qt.AlignLeft, False,
self.longest_text + u'M')
self.longest_text + 'M')
return srect.width() + editor.iconSize().width()
def setModelData(self, editor, model, index):
@ -754,7 +755,7 @@ class CcTemplateDelegate(QStyledItemDelegate): # {{{
m = index.model()
mi = m.db.get_metadata(index.row(), index_is_id=False)
if check_key_modifier(Qt.ControlModifier):
text = u''
text = ''
else:
text = m.custom_columns[m.column_map[index.column()]]['display']['composite_template']
editor = TemplateDialog(parent, text, mi)