mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
python3: PEP 3114 compliance for next() and iterators
This commit is contained in:
parent
9ecadb9c13
commit
391ca722e0
@ -212,7 +212,7 @@ class Plugin(object): # {{{
|
|||||||
For example to load an image::
|
For example to load an image::
|
||||||
|
|
||||||
pixmap = QPixmap()
|
pixmap = QPixmap()
|
||||||
pixmap.loadFromData(self.load_resources(['images/icon.png']).itervalues().next())
|
next(pixmap.loadFromData(self.load_resources(['images/icon.png']).itervalues())
|
||||||
icon = QIcon(pixmap)
|
icon = QIcon(pixmap)
|
||||||
|
|
||||||
:param names: List of paths to resources in the ZIP file using / as separator
|
:param names: List of paths to resources in the ZIP file using / as separator
|
||||||
|
@ -46,7 +46,7 @@ from calibre.db.tables import (OneToOneTable, ManyToOneTable, ManyToManyTable,
|
|||||||
Differences in semantics from pysqlite:
|
Differences in semantics from pysqlite:
|
||||||
|
|
||||||
1. execute/executemany operate in autocommit mode
|
1. execute/executemany operate in autocommit mode
|
||||||
2. There is no fetchone() method on cursor objects, instead use next()
|
2. There is no fetchone() method on cursor objects, instead use next(cursor)
|
||||||
3. There is no executescript
|
3. There is no executescript
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -120,7 +120,7 @@ class DBPrefs(dict): # {{{
|
|||||||
raw = self.to_raw(val)
|
raw = self.to_raw(val)
|
||||||
with self.db.conn:
|
with self.db.conn:
|
||||||
try:
|
try:
|
||||||
dbraw = self.db.execute('SELECT id,val FROM preferences WHERE key=?', (key,)).next()
|
dbraw = next(self.db.execute('SELECT id,val FROM preferences WHERE key=?', (key,)))
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
dbraw = None
|
dbraw = None
|
||||||
if dbraw is None or dbraw[1] != raw:
|
if dbraw is None or dbraw[1] != raw:
|
||||||
@ -271,7 +271,7 @@ class Connection(apsw.Connection): # {{{
|
|||||||
self.execute('pragma cache_size=-5000')
|
self.execute('pragma cache_size=-5000')
|
||||||
self.execute('pragma temp_store=2')
|
self.execute('pragma temp_store=2')
|
||||||
|
|
||||||
encoding = self.execute('pragma encoding').next()[0]
|
encoding = next(self.execute('pragma encoding'))[0]
|
||||||
self.createcollation('PYNOCASE', partial(pynocase,
|
self.createcollation('PYNOCASE', partial(pynocase,
|
||||||
encoding=encoding))
|
encoding=encoding))
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ class Connection(apsw.Connection): # {{{
|
|||||||
if kw.get('all', True):
|
if kw.get('all', True):
|
||||||
return ans.fetchall()
|
return ans.fetchall()
|
||||||
try:
|
try:
|
||||||
return ans.next()[0]
|
return next(ans)[0]
|
||||||
except (StopIteration, IndexError):
|
except (StopIteration, IndexError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -875,7 +875,7 @@ class DB(object):
|
|||||||
if kw.get('all', True):
|
if kw.get('all', True):
|
||||||
return ans.fetchall()
|
return ans.fetchall()
|
||||||
try:
|
try:
|
||||||
return ans.next()[0]
|
return next(ans)[0]
|
||||||
except (StopIteration, IndexError):
|
except (StopIteration, IndexError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class SchemaUpgrade(object):
|
|||||||
# Upgrade database
|
# Upgrade database
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
uv = self.db.execute('pragma user_version').next()[0]
|
uv = next(self.db.execute('pragma user_version'))[0]
|
||||||
meth = getattr(self, 'upgrade_version_%d'%uv, None)
|
meth = getattr(self, 'upgrade_version_%d'%uv, None)
|
||||||
if meth is None:
|
if meth is None:
|
||||||
break
|
break
|
||||||
|
@ -62,7 +62,7 @@ class Bookmark(): # {{{
|
|||||||
kepub_chapter_data = ('{0}-%'.format(row[1]), )
|
kepub_chapter_data = ('{0}-%'.format(row[1]), )
|
||||||
cursor2.execute(kepub_chapter_query, kepub_chapter_data)
|
cursor2.execute(kepub_chapter_query, kepub_chapter_data)
|
||||||
try:
|
try:
|
||||||
kepub_chapter = cursor2.next()
|
kepub_chapter = next(cursor2)
|
||||||
chapter_title = kepub_chapter[0]
|
chapter_title = kepub_chapter[0]
|
||||||
current_chapter = kepub_chapter[1]
|
current_chapter = kepub_chapter[1]
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
|
@ -185,7 +185,7 @@ class KOBO(USBMS):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute('SELECT version FROM dbversion')
|
cursor.execute('SELECT version FROM dbversion')
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
dbversion = result['version']
|
dbversion = result['version']
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
dbversion = 0
|
dbversion = 0
|
||||||
@ -572,7 +572,7 @@ class KOBO(USBMS):
|
|||||||
metadata = iter(metadata)
|
metadata = iter(metadata)
|
||||||
for i, location in enumerate(locations):
|
for i, location in enumerate(locations):
|
||||||
self.report_progress((i+1) / float(len(locations)), _('Adding books to device metadata listing...'))
|
self.report_progress((i+1) / float(len(locations)), _('Adding books to device metadata listing...'))
|
||||||
info = metadata.next()
|
info = next(metadata)
|
||||||
debug_print("KoboTouch::add_books_to_metadata - info=%s" % info)
|
debug_print("KoboTouch::add_books_to_metadata - info=%s" % info)
|
||||||
blist = 2 if location[1] == 'cardb' else 1 if location[1] == 'carda' else 0
|
blist = 2 if location[1] == 'cardb' else 1 if location[1] == 'carda' else 0
|
||||||
|
|
||||||
@ -790,7 +790,7 @@ class KOBO(USBMS):
|
|||||||
t = (ContentID,)
|
t = (ContentID,)
|
||||||
cursor.execute('select DateLastRead, ReadStatus from Content where BookID is Null and ContentID = ?', t)
|
cursor.execute('select DateLastRead, ReadStatus from Content where BookID is Null and ContentID = ?', t)
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
datelastread = result['DateLastRead']
|
datelastread = result['DateLastRead']
|
||||||
current_ReadStatus = result['ReadStatus']
|
current_ReadStatus = result['ReadStatus']
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
@ -1020,7 +1020,7 @@ class KOBO(USBMS):
|
|||||||
t = (ContentID,)
|
t = (ContentID,)
|
||||||
cursor.execute('select ImageId from Content where BookID is Null and ContentID = ?', t)
|
cursor.execute('select ImageId from Content where BookID is Null and ContentID = ?', t)
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
# debug_print("ImageId: ", result[0])
|
# debug_print("ImageId: ", result[0])
|
||||||
ImageID = result[0]
|
ImageID = result[0]
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
@ -2649,7 +2649,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
t = (ContentID,)
|
t = (ContentID,)
|
||||||
cursor.execute('select ImageId from Content where BookID is Null and ContentID = ?', t)
|
cursor.execute('select ImageId from Content where BookID is Null and ContentID = ?', t)
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
ImageID = result[0]
|
ImageID = result[0]
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
ImageID = self.imageid_from_contentid(ContentID)
|
ImageID = self.imageid_from_contentid(ContentID)
|
||||||
@ -2752,7 +2752,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute(test_query, test_values)
|
cursor.execute(test_query, test_values)
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
@ -2860,7 +2860,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute(test_query, test_values)
|
cursor.execute(test_query, test_values)
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
@ -2909,7 +2909,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
cursor.execute(test_query, test_values)
|
cursor.execute(test_query, test_values)
|
||||||
try:
|
try:
|
||||||
result = cursor.next()
|
result = next(cursor)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
result = None
|
result = None
|
||||||
|
|
||||||
|
@ -705,8 +705,8 @@ class XMLCache(object):
|
|||||||
child.text = '\n'+'\t'*(level+1)
|
child.text = '\n'+'\t'*(level+1)
|
||||||
for gc in child:
|
for gc in child:
|
||||||
gc.tail = '\n'+'\t'*(level+1)
|
gc.tail = '\n'+'\t'*(level+1)
|
||||||
child.iterchildren(reversed=True).next().tail = '\n'+'\t'*level
|
next(child.iterchildren(reversed=True)).tail = '\n'+'\t'*level
|
||||||
root.iterchildren(reversed=True).next().tail = '\n'+'\t'*(level-1)
|
next(root.iterchildren(reversed=True)).tail = '\n'+'\t'*(level-1)
|
||||||
|
|
||||||
def move_playlists_to_bottom(self):
|
def move_playlists_to_bottom(self):
|
||||||
for root in self.record_roots.values():
|
for root in self.record_roots.values():
|
||||||
@ -799,4 +799,3 @@ class XMLCache(object):
|
|||||||
self.namespaces[i] = ns
|
self.namespaces[i] = ns
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -1471,7 +1471,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
metadata = iter(metadata)
|
metadata = iter(metadata)
|
||||||
|
|
||||||
for i, infile in enumerate(files):
|
for i, infile in enumerate(files):
|
||||||
mdata, fname = metadata.next(), names.next()
|
mdata, fname = next(metadata), next(names)
|
||||||
lpath = self._create_upload_path(mdata, fname, create_dirs=False)
|
lpath = self._create_upload_path(mdata, fname, create_dirs=False)
|
||||||
self._debug('lpath', lpath)
|
self._debug('lpath', lpath)
|
||||||
if not hasattr(infile, 'read'):
|
if not hasattr(infile, 'read'):
|
||||||
@ -1497,7 +1497,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
for i, location in enumerate(locations):
|
for i, location in enumerate(locations):
|
||||||
self.report_progress((i + 1) / float(len(locations)),
|
self.report_progress((i + 1) / float(len(locations)),
|
||||||
_('Adding books to device metadata listing...'))
|
_('Adding books to device metadata listing...'))
|
||||||
info = metadata.next()
|
info = next(metadata)
|
||||||
lpath = location[0]
|
lpath = location[0]
|
||||||
length = location[1]
|
length = location[1]
|
||||||
lpath = self._strip_prefix(lpath)
|
lpath = self._strip_prefix(lpath)
|
||||||
|
@ -311,7 +311,7 @@ class USBMS(CLI, Device):
|
|||||||
metadata = iter(metadata)
|
metadata = iter(metadata)
|
||||||
|
|
||||||
for i, infile in enumerate(files):
|
for i, infile in enumerate(files):
|
||||||
mdata, fname = metadata.next(), names.next()
|
mdata, fname = next(metadata), next(names)
|
||||||
filepath = self.normalize_path(self.create_upload_path(path, mdata, fname))
|
filepath = self.normalize_path(self.create_upload_path(path, mdata, fname))
|
||||||
if not hasattr(infile, 'read'):
|
if not hasattr(infile, 'read'):
|
||||||
infile = self.normalize_path(infile)
|
infile = self.normalize_path(infile)
|
||||||
@ -350,7 +350,7 @@ class USBMS(CLI, Device):
|
|||||||
metadata = iter(metadata)
|
metadata = iter(metadata)
|
||||||
for i, location in enumerate(locations):
|
for i, location in enumerate(locations):
|
||||||
self.report_progress((i+1) / float(len(locations)), _('Adding books to device metadata listing...'))
|
self.report_progress((i+1) / float(len(locations)), _('Adding books to device metadata listing...'))
|
||||||
info = metadata.next()
|
info = next(metadata)
|
||||||
blist = 2 if location[1] == 'cardb' else 1 if location[1] == 'carda' else 0
|
blist = 2 if location[1] == 'cardb' else 1 if location[1] == 'carda' else 0
|
||||||
|
|
||||||
# Extract the correct prefix from the pathname. To do this correctly,
|
# Extract the correct prefix from the pathname. To do this correctly,
|
||||||
|
@ -332,7 +332,7 @@ class PageElement:
|
|||||||
g = generator()
|
g = generator()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
i = g.next()
|
i = next(g)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
if i:
|
if i:
|
||||||
|
@ -18,7 +18,7 @@ def decrypt_font_data(key, data, algorithm):
|
|||||||
crypt_len = 1024 if is_adobe else 1040
|
crypt_len = 1024 if is_adobe else 1040
|
||||||
crypt = bytearray(data[:crypt_len])
|
crypt = bytearray(data[:crypt_len])
|
||||||
key = cycle(iter(bytearray(key)))
|
key = cycle(iter(bytearray(key)))
|
||||||
decrypt = bytes(bytearray(x^key.next() for x in crypt))
|
decrypt = bytes(bytearray(x^next(key) for x in crypt))
|
||||||
return decrypt + data[crypt_len:]
|
return decrypt + data[crypt_len:]
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ class EPUBOutput(OutputFormatPlugin):
|
|||||||
if self.oeb.toc.count() == 0:
|
if self.oeb.toc.count() == 0:
|
||||||
self.log.warn('This EPUB file has no Table of Contents. '
|
self.log.warn('This EPUB file has no Table of Contents. '
|
||||||
'Creating a default TOC')
|
'Creating a default TOC')
|
||||||
first = iter(self.oeb.spine).next()
|
first = next(iter(self.oeb.spine))
|
||||||
self.oeb.toc.add(_('Start'), first.href)
|
self.oeb.toc.add(_('Start'), first.href)
|
||||||
|
|
||||||
from calibre.ebooks.oeb.base import OPF
|
from calibre.ebooks.oeb.base import OPF
|
||||||
@ -422,7 +422,7 @@ class EPUBOutput(OutputFormatPlugin):
|
|||||||
if br.getparent() is None:
|
if br.getparent() is None:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
prior = br.itersiblings(preceding=True).next()
|
prior = next(br.itersiblings(preceding=True))
|
||||||
priortag = barename(prior.tag)
|
priortag = barename(prior.tag)
|
||||||
priortext = prior.tail
|
priortext = prior.tail
|
||||||
except:
|
except:
|
||||||
|
@ -125,10 +125,10 @@ class SNBOutput(OutputFormatPlugin):
|
|||||||
if oeb_book.toc.count() == 0:
|
if oeb_book.toc.count() == 0:
|
||||||
log.warn('This SNB file has no Table of Contents. '
|
log.warn('This SNB file has no Table of Contents. '
|
||||||
'Creating a default TOC')
|
'Creating a default TOC')
|
||||||
first = iter(oeb_book.spine).next()
|
first = next(iter(oeb_book.spine))
|
||||||
oeb_book.toc.add(_('Start page'), first.href)
|
oeb_book.toc.add(_('Start page'), first.href)
|
||||||
else:
|
else:
|
||||||
first = iter(oeb_book.spine).next()
|
first = next(iter(oeb_book.spine))
|
||||||
if oeb_book.toc[0].href != first.href:
|
if oeb_book.toc[0].href != first.href:
|
||||||
# The pages before the fist item in toc will be stored as
|
# The pages before the fist item in toc will be stored as
|
||||||
# "Cover Pages".
|
# "Cover Pages".
|
||||||
|
@ -32,7 +32,7 @@ def filter_name(name):
|
|||||||
def build_name_for(expr):
|
def build_name_for(expr):
|
||||||
if not expr:
|
if not expr:
|
||||||
counter = count(1)
|
counter = count(1)
|
||||||
return lambda elem: str(counter.next())
|
return lambda elem: str(next(counter))
|
||||||
selector = XPath(expr, namespaces=NSMAP)
|
selector = XPath(expr, namespaces=NSMAP)
|
||||||
|
|
||||||
def name_for(elem):
|
def name_for(elem):
|
||||||
@ -55,7 +55,7 @@ def add_page_map(opfpath, opts):
|
|||||||
name = name_for(elem)
|
name = name_for(elem)
|
||||||
id = elem.get('id', None)
|
id = elem.get('id', None)
|
||||||
if id is None:
|
if id is None:
|
||||||
id = elem.attrib['id'] = idgen.next()
|
id = elem.attrib['id'] = next(idgen)
|
||||||
href = '#'.join((item.href, id))
|
href = '#'.join((item.href, id))
|
||||||
oeb.pages.add(name, href)
|
oeb.pages.add(name, href)
|
||||||
writer = None # DirWriter(version='2.0', page_map=True)
|
writer = None # DirWriter(version='2.0', page_map=True)
|
||||||
|
@ -349,7 +349,7 @@ class Table(object):
|
|||||||
nc = self.rows[r].cell_iterator()
|
nc = self.rows[r].cell_iterator()
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
cell = nc.next()
|
cell = next(nc)
|
||||||
cellmatrix[r][rowpos[r]] = cell
|
cellmatrix[r][rowpos[r]] = cell
|
||||||
rowpos[r] += cell.colspan
|
rowpos[r] += cell.colspan
|
||||||
for k in range(1, cell.rowspan):
|
for k in range(1, cell.rowspan):
|
||||||
|
@ -455,7 +455,7 @@ class Indexer(object): # {{{
|
|||||||
self.is_periodical else 'book'))
|
self.is_periodical else 'book'))
|
||||||
self.is_flat_periodical = False
|
self.is_flat_periodical = False
|
||||||
if self.is_periodical:
|
if self.is_periodical:
|
||||||
periodical_node = iter(oeb.toc).next()
|
periodical_node = next(iter(oeb.toc))
|
||||||
sections = tuple(periodical_node)
|
sections = tuple(periodical_node)
|
||||||
self.is_flat_periodical = len(sections) == 1
|
self.is_flat_periodical = len(sections) == 1
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ class Indexer(object): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def create_periodical_index(self): # {{{
|
def create_periodical_index(self): # {{{
|
||||||
periodical_node = iter(self.oeb.toc).next()
|
periodical_node = next(iter(self.oeb.toc))
|
||||||
periodical_node_offset = self.serializer.body_start_offset
|
periodical_node_offset = self.serializer.body_start_offset
|
||||||
periodical_node_size = (self.serializer.body_end_offset -
|
periodical_node_size = (self.serializer.body_end_offset -
|
||||||
periodical_node_offset)
|
periodical_node_offset)
|
||||||
|
@ -1782,7 +1782,7 @@ class PageList(object):
|
|||||||
for page in self.pages:
|
for page in self.pages:
|
||||||
id = page.id or uuid_id()
|
id = page.id or uuid_id()
|
||||||
type = page.type
|
type = page.type
|
||||||
value = str(values[type].next())
|
value = str(next(values[type]))
|
||||||
attrib = {'id': id, 'value': value, 'type': type, 'playOrder': '0'}
|
attrib = {'id': id, 'value': value, 'type': type, 'playOrder': '0'}
|
||||||
if page.klass:
|
if page.klass:
|
||||||
attrib['class'] = page.klass
|
attrib['class'] = page.klass
|
||||||
|
@ -98,7 +98,7 @@ def add_or_replace_jacket(container):
|
|||||||
if not found:
|
if not found:
|
||||||
# Insert new jacket into spine
|
# Insert new jacket into spine
|
||||||
index = 0
|
index = 0
|
||||||
sp = container.abspath_to_name(container.spine_items.next())
|
sp = container.abspath_to_name(next(container.spine_items))
|
||||||
if sp == find_cover_page(container):
|
if sp == find_cover_page(container):
|
||||||
index = 1
|
index = 1
|
||||||
itemref = container.opf.makeelement(OPF('itemref'),
|
itemref = container.opf.makeelement(OPF('itemref'),
|
||||||
|
@ -243,7 +243,7 @@ class FlowSplitter(object):
|
|||||||
|
|
||||||
self.trees = [orig_tree]
|
self.trees = [orig_tree]
|
||||||
while ordered_ids:
|
while ordered_ids:
|
||||||
pb_id, (pattern, before) = ordered_ids.iteritems().next()
|
pb_id, (pattern, before) = next(ordered_ids.iteritems())
|
||||||
del ordered_ids[pb_id]
|
del ordered_ids[pb_id]
|
||||||
for i in range(len(self.trees)-1, -1, -1):
|
for i in range(len(self.trees)-1, -1, -1):
|
||||||
tree = self.trees[i]
|
tree = self.trees[i]
|
||||||
|
@ -85,8 +85,8 @@ class DetectStructure(object):
|
|||||||
for item in oeb.spine:
|
for item in oeb.spine:
|
||||||
for elem in pb_xpath(item.data):
|
for elem in pb_xpath(item.data):
|
||||||
try:
|
try:
|
||||||
prev = elem.itersiblings(tag=etree.Element,
|
prev = next(elem.itersiblings(tag=etree.Element,
|
||||||
preceding=True).next()
|
preceding=True))
|
||||||
if (barename(elem.tag) in {'h1', 'h2'} and barename(
|
if (barename(elem.tag) in {'h1', 'h2'} and barename(
|
||||||
prev.tag) in {'h1', 'h2'} and (not prev.tail or
|
prev.tag) in {'h1', 'h2'} and (not prev.tail or
|
||||||
not prev.tail.split())):
|
not prev.tail.split())):
|
||||||
|
@ -40,7 +40,7 @@ class Image(Element):
|
|||||||
def __init__(self, img, opts, log, idc):
|
def __init__(self, img, opts, log, idc):
|
||||||
Element.__init__(self)
|
Element.__init__(self)
|
||||||
self.opts, self.log = opts, log
|
self.opts, self.log = opts, log
|
||||||
self.id = idc.next()
|
self.id = next(idc)
|
||||||
self.top, self.left, self.width, self.height, self.iwidth, self.iheight = \
|
self.top, self.left, self.width, self.height, self.iwidth, self.iheight = \
|
||||||
map(float, map(img.get, ('top', 'left', 'rwidth', 'rheight', 'iwidth',
|
map(float, map(img.get, ('top', 'left', 'rwidth', 'rheight', 'iwidth',
|
||||||
'iheight')))
|
'iheight')))
|
||||||
@ -61,7 +61,7 @@ class Text(Element):
|
|||||||
|
|
||||||
def __init__(self, text, font_map, opts, log, idc):
|
def __init__(self, text, font_map, opts, log, idc):
|
||||||
Element.__init__(self)
|
Element.__init__(self)
|
||||||
self.id = idc.next()
|
self.id = next(idc)
|
||||||
self.opts, self.log = opts, log
|
self.opts, self.log = opts, log
|
||||||
self.font_map = font_map
|
self.font_map = font_map
|
||||||
self.top, self.left, self.width, self.height = map(float, map(text.get,
|
self.top, self.left, self.width, self.height = map(float, map(text.get,
|
||||||
|
@ -278,7 +278,7 @@ class InterfaceAction(QObject):
|
|||||||
For example to load an image::
|
For example to load an image::
|
||||||
|
|
||||||
pixmap = QPixmap()
|
pixmap = QPixmap()
|
||||||
pixmap.loadFromData(self.load_resources(['images/icon.png']).itervalues().next())
|
next(pixmap.loadFromData(self.load_resources(['images/icon.png']).itervalues()))
|
||||||
icon = QIcon(pixmap)
|
icon = QIcon(pixmap)
|
||||||
|
|
||||||
:param names: List of paths to resources in the ZIP file using / as separator
|
:param names: List of paths to resources in the ZIP file using / as separator
|
||||||
|
@ -837,7 +837,7 @@ class BulkBase(Base):
|
|||||||
break
|
break
|
||||||
ans = None
|
ans = None
|
||||||
if len(values) == 1:
|
if len(values) == 1:
|
||||||
ans = iter(values).next()
|
ans = next(iter(values))
|
||||||
if isinstance(ans, frozenset):
|
if isinstance(ans, frozenset):
|
||||||
ans = list(ans)
|
ans = list(ans)
|
||||||
return ans
|
return ans
|
||||||
|
@ -411,7 +411,7 @@ class DeviceManager(Thread): # {{{
|
|||||||
|
|
||||||
do_sleep = True
|
do_sleep = True
|
||||||
while True:
|
while True:
|
||||||
job = self.next()
|
job = next(self)
|
||||||
if job is not None:
|
if job is not None:
|
||||||
do_sleep = False
|
do_sleep = False
|
||||||
self.current_job = job
|
self.current_job = job
|
||||||
@ -1494,8 +1494,8 @@ class DeviceMixin(object): # {{{
|
|||||||
|
|
||||||
bad, good, gf, names, remove_ids = [], [], [], [], []
|
bad, good, gf, names, remove_ids = [], [], [], [], []
|
||||||
for f in _files:
|
for f in _files:
|
||||||
mi = imetadata.next()
|
mi = next(imetadata)
|
||||||
id = ids.next()
|
id = next(ids)
|
||||||
if f is None:
|
if f is None:
|
||||||
bad.append(mi.title)
|
bad.append(mi.title)
|
||||||
else:
|
else:
|
||||||
|
@ -521,10 +521,9 @@ class Document(QGraphicsScene):
|
|||||||
self.next_match()
|
self.next_match()
|
||||||
|
|
||||||
def next_match(self):
|
def next_match(self):
|
||||||
page_num = self.last_search.next()[0]
|
page_num = next(self.last_search)[0]
|
||||||
if self.current_page == page_num:
|
if self.current_page == page_num:
|
||||||
self.update()
|
self.update()
|
||||||
else:
|
else:
|
||||||
self.add_to_history()
|
self.add_to_history()
|
||||||
self.show_page(page_num)
|
self.show_page(page_num)
|
||||||
|
|
||||||
|
@ -532,12 +532,12 @@ class Line(QGraphicsItem):
|
|||||||
matches = []
|
matches = []
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
word = words.next()
|
word = next(words)
|
||||||
word.highlight = False
|
word.highlight = False
|
||||||
if tokens[0] in unicode_type(word.string).lower():
|
if tokens[0] in unicode_type(word.string).lower():
|
||||||
matches.append(word)
|
matches.append(word)
|
||||||
for c in range(1, len(tokens)):
|
for c in range(1, len(tokens)):
|
||||||
word = words.next()
|
word = next(words)
|
||||||
print(tokens[c], word.string)
|
print(tokens[c], word.string)
|
||||||
if tokens[c] not in unicode_type(word.string):
|
if tokens[c] not in unicode_type(word.string):
|
||||||
return None
|
return None
|
||||||
|
@ -255,7 +255,7 @@ class CreateVirtualLibrary(QDialog): # {{{
|
|||||||
search = ['%s:"=%s"'%(prefix, x.replace('"', '\\"')) for x in d.names]
|
search = ['%s:"=%s"'%(prefix, x.replace('"', '\\"')) for x in d.names]
|
||||||
if search:
|
if search:
|
||||||
if not self.editing:
|
if not self.editing:
|
||||||
self.vl_name.lineEdit().setText(d.names.next())
|
self.vl_name.lineEdit().setText(next(d.names))
|
||||||
self.vl_name.lineEdit().setCursorPosition(0)
|
self.vl_name.lineEdit().setCursorPosition(0)
|
||||||
self.vl_text.setText(d.match_type.join(search))
|
self.vl_text.setText(d.match_type.join(search))
|
||||||
self.vl_text.setCursorPosition(0)
|
self.vl_text.setCursorPosition(0)
|
||||||
|
@ -1337,10 +1337,10 @@ ALTER TABLE books ADD COLUMN isbn TEXT DEFAULT "" COLLATE NOCASE;
|
|||||||
formats, metadata, uris = iter(formats), iter(metadata), iter(uris)
|
formats, metadata, uris = iter(formats), iter(metadata), iter(uris)
|
||||||
duplicates = []
|
duplicates = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
mi = metadata.next()
|
mi = next(metadata)
|
||||||
format = formats.next()
|
format = next(formats)
|
||||||
try:
|
try:
|
||||||
uri = uris.next()
|
uri = next(uris)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
uri = None
|
uri = None
|
||||||
if not add_duplicates and self.has_book(mi):
|
if not add_duplicates and self.has_book(mi):
|
||||||
|
@ -3498,9 +3498,9 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
ids = []
|
ids = []
|
||||||
postimport = []
|
postimport = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
mi = metadata.next()
|
mi = next(metadata)
|
||||||
self._add_newbook_tag(mi)
|
self._add_newbook_tag(mi)
|
||||||
format = formats.next()
|
format = next(formats)
|
||||||
if not add_duplicates and self.has_book(mi):
|
if not add_duplicates and self.has_book(mi):
|
||||||
duplicates.append((path, format, mi))
|
duplicates.append((path, format, mi))
|
||||||
continue
|
continue
|
||||||
|
@ -217,23 +217,23 @@ class NavBarTemplate(Template):
|
|||||||
navbar.append(BR())
|
navbar.append(BR())
|
||||||
navbar.append(BR())
|
navbar.append(BR())
|
||||||
else:
|
else:
|
||||||
next = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
|
next_art = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
|
||||||
else 'article_%d'%(art+1)
|
else 'article_%d'%(art+1)
|
||||||
up = '../..' if art == number_of_articles_in_feed - 1 else '..'
|
up = '../..' if art == number_of_articles_in_feed - 1 else '..'
|
||||||
href = '%s%s/%s/index.html'%(prefix, up, next)
|
href = '%s%s/%s/index.html'%(prefix, up, next_art)
|
||||||
navbar.text = '| '
|
navbar.text = '| '
|
||||||
navbar.append(A(_('Next'), href=href))
|
navbar.append(A(_('Next'), href=href))
|
||||||
href = '%s../index.html#article_%d'%(prefix, art)
|
href = '%s../index.html#article_%d'%(prefix, art)
|
||||||
navbar.iterchildren(reversed=True).next().tail = ' | '
|
next(navbar.iterchildren(reversed=True)).tail = ' | '
|
||||||
navbar.append(A(_('Section menu'), href=href))
|
navbar.append(A(_('Section menu'), href=href))
|
||||||
href = '%s../../index.html#feed_%d'%(prefix, feed)
|
href = '%s../../index.html#feed_%d'%(prefix, feed)
|
||||||
navbar.iterchildren(reversed=True).next().tail = ' | '
|
next(navbar.iterchildren(reversed=True)).tail = ' | '
|
||||||
navbar.append(A(_('Main menu'), href=href))
|
navbar.append(A(_('Main menu'), href=href))
|
||||||
if art > 0 and not bottom:
|
if art > 0 and not bottom:
|
||||||
href = '%s../article_%d/index.html'%(prefix, art-1)
|
href = '%s../article_%d/index.html'%(prefix, art-1)
|
||||||
navbar.iterchildren(reversed=True).next().tail = ' | '
|
next(navbar.iterchildren(reversed=True)).tail = ' | '
|
||||||
navbar.append(A(_('Previous'), href=href))
|
navbar.append(A(_('Previous'), href=href))
|
||||||
navbar.iterchildren(reversed=True).next().tail = ' | '
|
next(navbar.iterchildren(reversed=True)).tail = ' | '
|
||||||
if not bottom:
|
if not bottom:
|
||||||
navbar.append(HR())
|
navbar.append(HR())
|
||||||
|
|
||||||
@ -413,11 +413,11 @@ class TouchscreenNavBarTemplate(Template):
|
|||||||
navbar_tr.append(TD(CLASS('article_sections_list'),link))
|
navbar_tr.append(TD(CLASS('article_sections_list'),link))
|
||||||
|
|
||||||
# | Next
|
# | Next
|
||||||
next = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
|
next_art = 'feed_%d'%(feed+1) if art == number_of_articles_in_feed - 1 \
|
||||||
else 'article_%d'%(art+1)
|
else 'article_%d'%(art+1)
|
||||||
up = '../..' if art == number_of_articles_in_feed - 1 else '..'
|
up = '../..' if art == number_of_articles_in_feed - 1 else '..'
|
||||||
|
|
||||||
link = A(CLASS('article_link'), _('Next'), href='%s%s/%s/index.html'%(prefix, up, next))
|
link = A(CLASS('article_link'), _('Next'), href='%s%s/%s/index.html'%(prefix, up, next_art))
|
||||||
navbar_tr.append(TD(CLASS('article_next'),link))
|
navbar_tr.append(TD(CLASS('article_next'),link))
|
||||||
navbar_t.append(navbar_tr)
|
navbar_t.append(navbar_tr)
|
||||||
navbar.append(navbar_t)
|
navbar.append(navbar_t)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user