Misc fixes for the last py3 porting merge

This commit is contained in:
Kovid Goyal 2019-03-25 16:03:25 +05:30
parent c8688930ad
commit 5918acabad
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
10 changed files with 11 additions and 11 deletions

View File

@ -2,8 +2,6 @@
max-line-length = 160
builtins = _,dynamic_property,__,P,I,lopen,icu_lower,icu_upper,icu_title,ngettext,connect_lambda
ignore = E12,E203,E22,E231,E241,E401,E402,E731,W391,E722,E741,W504
per-file-ignores =
src/polyglot/*:F401
[yapf]
based_on_style = pep8

View File

@ -270,7 +270,7 @@ class RecentUAs(Command): # {{{
from setup.browser_data import get_data
data = get_data()
with open(self.UA_PATH, 'wb') as f:
f.write(json.dumps(data, indent=2).encode('utf-8'))
f.write(json.dumps(data, indent=2, ensure_ascii=False).encode('utf-8'))
# }}}

View File

@ -193,6 +193,7 @@ def prints(*args, **kwargs):
Returns the number of bytes written.
'''
file = kwargs.get('file', sys.stdout)
file = getattr(file, 'buffer', file)
sep = bytes(kwargs.get('sep', ' '))
end = bytes(kwargs.get('end', '\n'))
enc = 'utf-8' if 'CALIBRE_WORKER' in os.environ else preferred_encoding

View File

@ -212,7 +212,7 @@ class Plugin(object): # {{{
For example to load an image::
pixmap = QPixmap()
next(pixmap.loadFromData(self.load_resources(['images/icon.png']).values())
pixmap.loadFromData(tuple(self.load_resources(['images/icon.png']).values())[0])
icon = QIcon(pixmap)
:param names: List of paths to resources in the ZIP file using / as separator

View File

@ -18,7 +18,7 @@ from calibre.ebooks.oeb.polish.replace import remove_links_to
from calibre.ebooks.oeb.polish.cover import get_raster_cover_name
from calibre.ebooks.oeb.polish.utils import guess_type, actual_case_for_name, corrected_case_for_name
from calibre.ebooks.oeb.polish.check.base import BaseError, WARN, INFO
from polyglot.builtins import iteritems, map, range
from polyglot.builtins import iteritems, map, range, itervalues
from polyglot.urllib import urlparse
from polyglot.queue import Queue, Empty

View File

@ -7,6 +7,7 @@ __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import sys, os, numbers
from itertools import count
from lxml import etree
@ -623,7 +624,7 @@ class PDFDocument(object):
self.opts, self.log = opts, log
parser = etree.XMLParser(recover=True)
self.root = etree.fromstring(xml, parser=parser)
idc = iter(range(sys.maxint))
idc = count()
self.fonts = []
self.font_map = {}

View File

@ -72,7 +72,7 @@ class J2H (object):
if len(text) >= length:
if text.startswith(k):
for (yomi, tail) in v:
if tail is '':
if tail == '':
if max_len < length:
Hstr = yomi
max_len = length

View File

@ -278,7 +278,7 @@ class InterfaceAction(QObject):
For example to load an image::
pixmap = QPixmap()
next(pixmap.loadFromData(self.load_resources(['images/icon.png']).values()))
pixmap.loadFromData(tuple(self.load_resources(['images/icon.png']).values())[0])
icon = QIcon(pixmap)
:param names: List of paths to resources in the ZIP file using / as separator

View File

@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
import os, numbers
from functools import partial
from polyglot.builtins itervalues, import map
from polyglot.builtins import itervalues, map
from calibre.utils.config import prefs

View File

@ -355,7 +355,7 @@ class DeviceManager(Thread): # {{{
# anything besides set a flag that the right thread will see.
self.connected_device.unmount_device()
def next(self):
def next_job(self):
if not self.job_steps.empty():
try:
return self.job_steps.get_nowait()
@ -411,7 +411,7 @@ class DeviceManager(Thread): # {{{
do_sleep = True
while True:
job = next(self)
job = self.next_job()
if job is not None:
do_sleep = False
self.current_job = job