mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Automated upgrade of code to python 3.7+
Done by https://github.com/asottile/pyupgrade Consists mainly of moving string formatting to f-strings and removing encoding declarations
This commit is contained in:
parent
224db2bb02
commit
eb78a761a9
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from polyglot.builtins import environ_item, hasenv
|
from polyglot.builtins import environ_item, hasenv
|
||||||
import sys, locale, codecs, os, collections, collections.abc
|
import sys, locale, codecs, os, collections, collections.abc
|
||||||
|
@ -565,7 +565,7 @@ class CatalogPlugin(Plugin): # {{{
|
|||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
|
|
||||||
if not type(self) in builtin_plugins and self.name not in config['disabled_plugins']:
|
if not type(self) in builtin_plugins and self.name not in config['disabled_plugins']:
|
||||||
files_to_copy = ["%s.%s" % (self.name.lower(),ext) for ext in ["ui","py"]]
|
files_to_copy = [f"{self.name.lower()}.{ext}" for ext in ["ui","py"]]
|
||||||
resources = zipfile.ZipFile(self.plugin_path,'r')
|
resources = zipfile.ZipFile(self.plugin_path,'r')
|
||||||
|
|
||||||
if self.resources_path is None:
|
if self.resources_path is None:
|
||||||
@ -575,7 +575,7 @@ class CatalogPlugin(Plugin): # {{{
|
|||||||
try:
|
try:
|
||||||
resources.extract(file, self.resources_path)
|
resources.extract(file, self.resources_path)
|
||||||
except:
|
except:
|
||||||
print(" customize:__init__.initialize(): %s not found in %s" % (file, os.path.basename(self.plugin_path)))
|
print(f" customize:__init__.initialize(): {file} not found in {os.path.basename(self.plugin_path)}")
|
||||||
continue
|
continue
|
||||||
resources.close()
|
resources.close()
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Defines the plugin system for conversions.
|
Defines the plugin system for conversions.
|
||||||
'''
|
'''
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -849,7 +849,7 @@ def main(args=sys.argv):
|
|||||||
type_len = name_len = 0
|
type_len = name_len = 0
|
||||||
for plugin in initialized_plugins():
|
for plugin in initialized_plugins():
|
||||||
type_len, name_len = max(type_len, len(plugin.type)), max(name_len, len(plugin.name))
|
type_len, name_len = max(type_len, len(plugin.type)), max(name_len, len(plugin.name))
|
||||||
fmt = '%-{}s%-{}s%-15s%-15s%s'.format(type_len+1, name_len+1)
|
fmt = f'%-{type_len+1}s%-{name_len+1}s%-15s%-15s%s'
|
||||||
print(fmt%tuple('Type|Name|Version|Disabled|Site Customization'.split('|')))
|
print(fmt%tuple('Type|Name|Version|Disabled|Site Customization'.split('|')))
|
||||||
print()
|
print()
|
||||||
for plugin in initialized_plugins():
|
for plugin in initialized_plugins():
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -242,7 +241,7 @@ def add_catalog(cache, path, title, dbapi=None):
|
|||||||
new_book_added = False
|
new_book_added = False
|
||||||
with lopen(path, 'rb') as stream:
|
with lopen(path, 'rb') as stream:
|
||||||
with cache.write_lock:
|
with cache.write_lock:
|
||||||
matches = cache._search('title:="%s" and tags:="%s"' % (title.replace('"', '\\"'), _('Catalog')), None)
|
matches = cache._search('title:="{}" and tags:="{}"'.format(title.replace('"', '\\"'), _('Catalog')), None)
|
||||||
db_id = None
|
db_id = None
|
||||||
if matches:
|
if matches:
|
||||||
db_id = list(matches)[0]
|
db_id = list(matches)[0]
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -59,7 +58,7 @@ from polyglot.builtins import (
|
|||||||
class FTSQueryError(ValueError):
|
class FTSQueryError(ValueError):
|
||||||
|
|
||||||
def __init__(self, query, sql_statement, apsw_error):
|
def __init__(self, query, sql_statement, apsw_error):
|
||||||
ValueError.__init__(self, 'Failed to parse search query: {} with error: {}'.format(query, apsw_error))
|
ValueError.__init__(self, f'Failed to parse search query: {query} with error: {apsw_error}')
|
||||||
self.query = query
|
self.query = query
|
||||||
self.sql_statement = sql_statement
|
self.sql_statement = sql_statement
|
||||||
|
|
||||||
@ -1263,7 +1262,7 @@ class DB:
|
|||||||
author = ascii_filename(_('Unknown'))
|
author = ascii_filename(_('Unknown'))
|
||||||
if author.upper() in WINDOWS_RESERVED_NAMES:
|
if author.upper() in WINDOWS_RESERVED_NAMES:
|
||||||
author += 'w'
|
author += 'w'
|
||||||
return '%s/%s%s' % (author, title, book_id)
|
return f'{author}/{title}{book_id}'
|
||||||
|
|
||||||
def construct_file_name(self, book_id, title, author, extlen):
|
def construct_file_name(self, book_id, title, author, extlen):
|
||||||
'''
|
'''
|
||||||
@ -1450,7 +1449,7 @@ class DB:
|
|||||||
f = lopen(path, 'rb')
|
f = lopen(path, 'rb')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
# Ensure the path that caused this error is reported
|
# Ensure the path that caused this error is reported
|
||||||
raise Exception('Failed to open %r with error: %s' % (path, e))
|
raise Exception(f'Failed to open {path!r} with error: {e}')
|
||||||
|
|
||||||
with f:
|
with f:
|
||||||
if hasattr(dest, 'write'):
|
if hasattr(dest, 'write'):
|
||||||
@ -1825,11 +1824,11 @@ class DB:
|
|||||||
fts_table=fts_table, highlight_start=highlight_start, highlight_end=highlight_end,
|
fts_table=fts_table, highlight_start=highlight_start, highlight_end=highlight_end,
|
||||||
snippet_size=max(1, min(snippet_size, 64)))
|
snippet_size=max(1, min(snippet_size, 64)))
|
||||||
else:
|
else:
|
||||||
text = 'highlight({}, 0, "{}", "{}")'.format(fts_table, highlight_start, highlight_end)
|
text = f'highlight({fts_table}, 0, "{highlight_start}", "{highlight_end}")'
|
||||||
query = 'SELECT {0}.id, {0}.book, {0}.format, {0}.user_type, {0}.user, {0}.annot_data, {1} FROM {0} '
|
query = 'SELECT {0}.id, {0}.book, {0}.format, {0}.user_type, {0}.user, {0}.annot_data, {1} FROM {0} '
|
||||||
query = query.format('annotations', text)
|
query = query.format('annotations', text)
|
||||||
query += ' JOIN {fts_table} ON annotations.id = {fts_table}.rowid'.format(fts_table=fts_table)
|
query += ' JOIN {fts_table} ON annotations.id = {fts_table}.rowid'.format(fts_table=fts_table)
|
||||||
query += ' WHERE {fts_table} MATCH ?'.format(fts_table=fts_table)
|
query += f' WHERE {fts_table} MATCH ?'
|
||||||
data = [fts_engine_query]
|
data = [fts_engine_query]
|
||||||
if restrict_to_user:
|
if restrict_to_user:
|
||||||
query += ' AND annotations.user_type = ? AND annotations.user = ?'
|
query += ' AND annotations.user_type = ? AND annotations.user = ?'
|
||||||
@ -1837,7 +1836,7 @@ class DB:
|
|||||||
if annotation_type:
|
if annotation_type:
|
||||||
query += ' AND annotations.annot_type = ? '
|
query += ' AND annotations.annot_type = ? '
|
||||||
data.append(annotation_type)
|
data.append(annotation_type)
|
||||||
query += ' ORDER BY {}.rank '.format(fts_table)
|
query += f' ORDER BY {fts_table}.rank '
|
||||||
ls = json.loads
|
ls = json.loads
|
||||||
try:
|
try:
|
||||||
for (rowid, book_id, fmt, user_type, user, annot_data, text) in self.execute(query, tuple(data)):
|
for (rowid, book_id, fmt, user_type, user, annot_data, text) in self.execute(query, tuple(data)):
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -2437,11 +2436,11 @@ class Cache:
|
|||||||
format_metadata[book_id] = {}
|
format_metadata[book_id] = {}
|
||||||
for fmt in self._formats(book_id):
|
for fmt in self._formats(book_id):
|
||||||
mdata = self.format_metadata(book_id, fmt)
|
mdata = self.format_metadata(book_id, fmt)
|
||||||
key = '%s:%s:%s' % (key_prefix, book_id, fmt)
|
key = f'{key_prefix}:{book_id}:{fmt}'
|
||||||
format_metadata[book_id][fmt] = key
|
format_metadata[book_id][fmt] = key
|
||||||
with exporter.start_file(key, mtime=mdata.get('mtime')) as dest:
|
with exporter.start_file(key, mtime=mdata.get('mtime')) as dest:
|
||||||
self._copy_format_to(book_id, fmt, dest, report_file_size=dest.ensure_space)
|
self._copy_format_to(book_id, fmt, dest, report_file_size=dest.ensure_space)
|
||||||
cover_key = '%s:%s:%s' % (key_prefix, book_id, '.cover')
|
cover_key = '{}:{}:{}'.format(key_prefix, book_id, '.cover')
|
||||||
with exporter.start_file(cover_key) as dest:
|
with exporter.start_file(cover_key) as dest:
|
||||||
if not self.copy_cover_to(book_id, dest, report_file_size=dest.ensure_space):
|
if not self.copy_cover_to(book_id, dest, report_file_size=dest.ensure_space):
|
||||||
dest.discard()
|
dest.discard()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ class BackupProgress:
|
|||||||
else:
|
else:
|
||||||
self.count += 1
|
self.count += 1
|
||||||
prints(
|
prints(
|
||||||
'%.1f%% %s - %s' % ((self.count * 100) / float(self.total), book_id,
|
'{:.1f}% {} - {}'.format((self.count * 100) / float(self.total), book_id,
|
||||||
getattr(mi, 'title', 'Unknown'))
|
getattr(mi, 'title', 'Unknown'))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
@ -148,7 +147,7 @@ def main(opts, args, dbctx):
|
|||||||
export(opts, dbctx, book_id, dest, dbproxy, length, i == 0)
|
export(opts, dbctx, book_id, dest, dbproxy, length, i == 0)
|
||||||
if opts.progress:
|
if opts.progress:
|
||||||
num = i + 1
|
num = i + 1
|
||||||
print('\r {:.0%} [{}/{}]'.format(num / total, num, total), end=' '*20)
|
print(f'\r {num / total:.0%} [{num}/{total}]', end=' '*20)
|
||||||
if opts.progress:
|
if opts.progress:
|
||||||
print()
|
print()
|
||||||
return 0
|
return 0
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ def implementation(
|
|||||||
fields = sorted(afields)
|
fields = sorted(afields)
|
||||||
sort_by = sort_by or 'id'
|
sort_by = sort_by or 'id'
|
||||||
if sort_by not in afields:
|
if sort_by not in afields:
|
||||||
return 'Unknown sort field: {}'.format(sort_by)
|
return f'Unknown sort field: {sort_by}'
|
||||||
if not set(fields).issubset(afields):
|
if not set(fields).issubset(afields):
|
||||||
return 'Unknown fields: {}'.format(', '.join(set(fields) - afields))
|
return 'Unknown fields: {}'.format(', '.join(set(fields) - afields))
|
||||||
if search_text:
|
if search_text:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import json
|
import json
|
||||||
@ -140,7 +139,7 @@ class DBCtx:
|
|||||||
parts = urlparse(self.library_path)
|
parts = urlparse(self.library_path)
|
||||||
self.library_id = parts.fragment or None
|
self.library_id = parts.fragment or None
|
||||||
self.url = urlunparse(parts._replace(fragment='')).rstrip('/')
|
self.url = urlunparse(parts._replace(fragment='')).rstrip('/')
|
||||||
self.br = browser(handle_refresh=False, user_agent='{} {}'.format(__appname__, __version__))
|
self.br = browser(handle_refresh=False, user_agent=f'{__appname__} {__version__}')
|
||||||
self.is_remote = True
|
self.is_remote = True
|
||||||
username, password = read_credentials(opts)
|
username, password = read_credentials(opts)
|
||||||
self.has_credentials = False
|
self.has_credentials = False
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -14,5 +13,5 @@ class NoSuchFormat(ValueError):
|
|||||||
class NoSuchBook(KeyError):
|
class NoSuchBook(KeyError):
|
||||||
|
|
||||||
def __init__(self, book_id):
|
def __init__(self, book_id):
|
||||||
KeyError.__init__(self, 'No book with id: {} in database'.format(book_id))
|
KeyError.__init__(self, f'No book with id: {book_id} in database')
|
||||||
self.book_id = book_id
|
self.book_id = book_id
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import weakref
|
import weakref
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -296,7 +295,7 @@ class ManyToOneTable(Table):
|
|||||||
# this is a many-to-one mapping we know that we can delete
|
# this is a many-to-one mapping we know that we can delete
|
||||||
# links without checking the item ID
|
# links without checking the item ID
|
||||||
db.executemany(
|
db.executemany(
|
||||||
'DELETE FROM {} WHERE book=?'.format(self.link_table), tuple((x,) for x in books_to_delete))
|
f'DELETE FROM {self.link_table} WHERE book=?', tuple((x,) for x in books_to_delete))
|
||||||
affected_books |= books_to_delete
|
affected_books |= books_to_delete
|
||||||
else:
|
else:
|
||||||
# Process normally any items where the VL was not significant
|
# Process normally any items where the VL was not significant
|
||||||
@ -327,7 +326,7 @@ class ManyToOneTable(Table):
|
|||||||
if existing_item is None or existing_item == item_id:
|
if existing_item is None or existing_item == item_id:
|
||||||
# A simple rename will do the trick
|
# A simple rename will do the trick
|
||||||
self.id_map[item_id] = new_name
|
self.id_map[item_id] = new_name
|
||||||
db.execute('UPDATE {} SET {}=? WHERE id=?'.format(table, col), (new_name, item_id))
|
db.execute(f'UPDATE {table} SET {col}=? WHERE id=?', (new_name, item_id))
|
||||||
else:
|
else:
|
||||||
# We have to replace
|
# We have to replace
|
||||||
new_id = existing_item
|
new_id = existing_item
|
||||||
@ -466,7 +465,7 @@ class ManyToManyTable(ManyToOneTable):
|
|||||||
if existing_item is None or existing_item == item_id:
|
if existing_item is None or existing_item == item_id:
|
||||||
# A simple rename will do the trick
|
# A simple rename will do the trick
|
||||||
self.id_map[item_id] = new_name
|
self.id_map[item_id] = new_name
|
||||||
db.execute('UPDATE {} SET {}=? WHERE id=?'.format(table, col), (new_name, item_id))
|
db.execute(f'UPDATE {table} SET {col}=? WHERE id=?', (new_name, item_id))
|
||||||
else:
|
else:
|
||||||
# We have to replace
|
# We have to replace
|
||||||
new_id = existing_item
|
new_id = existing_item
|
||||||
@ -478,7 +477,7 @@ class ManyToManyTable(ManyToOneTable):
|
|||||||
for book_id in books:
|
for book_id in books:
|
||||||
self.book_col_map[book_id] = tuple((existing_item if x == item_id else x) for x in self.book_col_map.get(book_id, ()) if x != existing_item)
|
self.book_col_map[book_id] = tuple((existing_item if x == item_id else x) for x in self.book_col_map.get(book_id, ()) if x != existing_item)
|
||||||
self.col_book_map[existing_item].update(books)
|
self.col_book_map[existing_item].update(books)
|
||||||
db.executemany('DELETE FROM {} WHERE book=? AND {}=?'.format(self.link_table, lcol), [
|
db.executemany(f'DELETE FROM {self.link_table} WHERE book=? AND {lcol}=?', [
|
||||||
(book_id, existing_item) for book_id in books])
|
(book_id, existing_item) for book_id in books])
|
||||||
db.execute('UPDATE {0} SET {1}=? WHERE {1}=?; DELETE FROM {2} WHERE id=?'.format(
|
db.execute('UPDATE {0} SET {1}=? WHERE {1}=?; DELETE FROM {2} WHERE id=?'.format(
|
||||||
self.link_table, lcol, table), (existing_item, item_id, item_id))
|
self.link_table, lcol, table), (existing_item, item_id, item_id))
|
||||||
@ -515,7 +514,7 @@ class ManyToManyTable(ManyToOneTable):
|
|||||||
tuple((main_id, x, book_id) for x in v))
|
tuple((main_id, x, book_id) for x in v))
|
||||||
else:
|
else:
|
||||||
# duplicates
|
# duplicates
|
||||||
db.execute('DELETE FROM {} WHERE book=?'.format(self.link_table), (book_id,))
|
db.execute(f'DELETE FROM {self.link_table} WHERE book=?', (book_id,))
|
||||||
db.executemany(
|
db.executemany(
|
||||||
'INSERT INTO {} (book,{}) VALUES (?,?)'.format(self.link_table, self.metadata['link_column']),
|
'INSERT INTO {} (book,{}) VALUES (?,?)'.format(self.link_table, self.metadata['link_column']),
|
||||||
tuple((book_id, x) for x in vals))
|
tuple((book_id, x) for x in vals))
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -30,7 +29,7 @@ class ET:
|
|||||||
legacy = self.legacy or test.init_legacy(test.cloned_library)
|
legacy = self.legacy or test.init_legacy(test.cloned_library)
|
||||||
oldres = getattr(old, self.func_name)(*self.args, **self.kwargs)
|
oldres = getattr(old, self.func_name)(*self.args, **self.kwargs)
|
||||||
newres = getattr(legacy, self.func_name)(*self.args, **self.kwargs)
|
newres = getattr(legacy, self.func_name)(*self.args, **self.kwargs)
|
||||||
test.assertEqual(oldres, newres, 'Equivalence test for %s with args: %s and kwargs: %s failed' % (
|
test.assertEqual(oldres, newres, 'Equivalence test for {} with args: {} and kwargs: {} failed'.format(
|
||||||
self.func_name, reprlib.repr(self.args), reprlib.repr(self.kwargs)))
|
self.func_name, reprlib.repr(self.args), reprlib.repr(self.kwargs)))
|
||||||
self.retval = newres
|
self.retval = newres
|
||||||
return newres
|
return newres
|
||||||
@ -49,7 +48,7 @@ def compare_argspecs(old, new, attr):
|
|||||||
|
|
||||||
ok = len(old.args) == len(new.args) and get_defaults(old) == get_defaults(new)
|
ok = len(old.args) == len(new.args) and get_defaults(old) == get_defaults(new)
|
||||||
if not ok:
|
if not ok:
|
||||||
raise AssertionError('The argspec for %s does not match. %r != %r' % (attr, old, new))
|
raise AssertionError(f'The argspec for {attr} does not match. {old!r} != {new!r}')
|
||||||
|
|
||||||
|
|
||||||
def run_funcs(self, db, ndb, funcs):
|
def run_funcs(self, db, ndb, funcs):
|
||||||
@ -69,7 +68,7 @@ def run_funcs(self, db, ndb, funcs):
|
|||||||
args = args[:-1]
|
args = args[:-1]
|
||||||
meth = meth[1:]
|
meth = meth[1:]
|
||||||
res1, res2 = fmt(getattr(db, meth)(*args)), fmt(getattr(ndb, meth)(*args))
|
res1, res2 = fmt(getattr(db, meth)(*args)), fmt(getattr(ndb, meth)(*args))
|
||||||
self.assertEqual(res1, res2, 'The method: %s() returned different results for argument %s' % (meth, args))
|
self.assertEqual(res1, res2, f'The method: {meth}() returned different results for argument {args}')
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
@ -265,7 +264,7 @@ class LegacyTest(BaseTest):
|
|||||||
fmt = lambda val:{x[0]:tuple(x[1:]) for x in val}
|
fmt = lambda val:{x[0]:tuple(x[1:]) for x in val}
|
||||||
for a in args:
|
for a in args:
|
||||||
self.assertEqual(fmt(getattr(db, meth)(*a)), fmt(getattr(ndb, meth)(*a)),
|
self.assertEqual(fmt(getattr(db, meth)(*a)), fmt(getattr(ndb, meth)(*a)),
|
||||||
'The method: %s() returned different results for argument %s' % (meth, a))
|
f'The method: {meth}() returned different results for argument {a}')
|
||||||
|
|
||||||
def f(x, y): # get_top_level_move_items is broken in the old db on case-insensitive file systems
|
def f(x, y): # get_top_level_move_items is broken in the old db on case-insensitive file systems
|
||||||
x.discard('metadata_db_prefs_backup.json')
|
x.discard('metadata_db_prefs_backup.json')
|
||||||
@ -318,7 +317,7 @@ class LegacyTest(BaseTest):
|
|||||||
meth, args = x[0], x[1:]
|
meth, args = x[0], x[1:]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
decode(getattr(db, meth)(*args)), decode(getattr(ndb, meth)(*args)),
|
decode(getattr(db, meth)(*args)), decode(getattr(ndb, meth)(*args)),
|
||||||
'The method: %s() returned different results for argument %s' % (meth, args)
|
f'The method: {meth}() returned different results for argument {args}'
|
||||||
)
|
)
|
||||||
db.close()
|
db.close()
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -186,7 +185,7 @@ class TestLock(BaseTest):
|
|||||||
break
|
break
|
||||||
t.join(left)
|
t.join(left)
|
||||||
live = [t for t in threads if t.is_alive()]
|
live = [t for t in threads if t.is_alive()]
|
||||||
self.assertEqual(len(live), 0, 'ShLock hung or very slow, {} threads alive'.format(len(live)))
|
self.assertEqual(len(live), 0, f'ShLock hung or very slow, {len(live)} threads alive')
|
||||||
self.assertEqual(len(done), len(threads), 'SHLock locking failed')
|
self.assertEqual(len(done), len(threads), 'SHLock locking failed')
|
||||||
self.assertFalse(lock.is_shared)
|
self.assertFalse(lock.is_shared)
|
||||||
self.assertFalse(lock.is_exclusive)
|
self.assertFalse(lock.is_exclusive)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -609,9 +608,9 @@ class ReadingTest(BaseTest):
|
|||||||
if field == 'formats':
|
if field == 'formats':
|
||||||
f = lambda x: x if x is None else tuple(x)
|
f = lambda x: x if x is None else tuple(x)
|
||||||
self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)),
|
self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)),
|
||||||
'Standard field: %s not the same for book %s' % (field, book_id))
|
f'Standard field: {field} not the same for book {book_id}')
|
||||||
self.assertEqual(mi.format_field(field), pmi.format_field(field),
|
self.assertEqual(mi.format_field(field), pmi.format_field(field),
|
||||||
'Standard field format: %s not the same for book %s' % (field, book_id))
|
f'Standard field format: {field} not the same for book {book_id}')
|
||||||
|
|
||||||
def f(x):
|
def f(x):
|
||||||
try:
|
try:
|
||||||
@ -627,9 +626,9 @@ class ReadingTest(BaseTest):
|
|||||||
for field, meta in cache.field_metadata.custom_iteritems():
|
for field, meta in cache.field_metadata.custom_iteritems():
|
||||||
if meta['datatype'] != 'composite':
|
if meta['datatype'] != 'composite':
|
||||||
self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)),
|
self.assertEqual(f(getattr(mi, field)), f(getattr(pmi, field)),
|
||||||
'Custom field: %s not the same for book %s' % (field, book_id))
|
f'Custom field: {field} not the same for book {book_id}')
|
||||||
self.assertEqual(mi.format_field(field), pmi.format_field(field),
|
self.assertEqual(mi.format_field(field), pmi.format_field(field),
|
||||||
'Custom field format: %s not the same for book %s' % (field, book_id))
|
f'Custom field format: {field} not the same for book {book_id}')
|
||||||
|
|
||||||
# Test handling of recursive templates
|
# Test handling of recursive templates
|
||||||
cache.create_custom_column('comp2', 'comp2', 'composite', False, display={'composite_template':'{title}'})
|
cache.create_custom_column('comp2', 'comp2', 'composite', False, display={'composite_template':'{title}'})
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -402,10 +401,10 @@ class WritingTest(BaseTest):
|
|||||||
mi = cache.get_metadata(1)
|
mi = cache.get_metadata(1)
|
||||||
old_path = cache.field_for('path', 1)
|
old_path = cache.field_for('path', 1)
|
||||||
old_title, old_author = mi.title, mi.authors[0]
|
old_title, old_author = mi.title, mi.authors[0]
|
||||||
ae(old_path, '%s/%s (1)' % (old_author, old_title))
|
ae(old_path, f'{old_author}/{old_title} (1)')
|
||||||
mi.title, mi.authors = 'New Title', ['New Author']
|
mi.title, mi.authors = 'New Title', ['New Author']
|
||||||
cache.set_metadata(1, mi)
|
cache.set_metadata(1, mi)
|
||||||
ae(cache.field_for('path', 1), '%s/%s (1)' % (mi.authors[0], mi.title))
|
ae(cache.field_for('path', 1), f'{mi.authors[0]}/{mi.title} (1)')
|
||||||
p = cache.format_abspath(1, 'FMT1')
|
p = cache.format_abspath(1, 'FMT1')
|
||||||
self.assertTrue(mi.authors[0] in p and mi.title in p)
|
self.assertTrue(mi.authors[0] in p and mi.title in p)
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -279,7 +278,7 @@ class View:
|
|||||||
def _build_restriction_string(self, restriction):
|
def _build_restriction_string(self, restriction):
|
||||||
if self.base_restriction:
|
if self.base_restriction:
|
||||||
if restriction:
|
if restriction:
|
||||||
return '(%s) and (%s)' % (self.base_restriction, restriction)
|
return f'({self.base_restriction}) and ({restriction})'
|
||||||
else:
|
else:
|
||||||
return self.base_restriction
|
return self.base_restriction
|
||||||
else:
|
else:
|
||||||
@ -295,7 +294,7 @@ class View:
|
|||||||
else:
|
else:
|
||||||
q = query
|
q = query
|
||||||
if search_restriction:
|
if search_restriction:
|
||||||
q = '(%s) and (%s)' % (search_restriction, query)
|
q = f'({search_restriction}) and ({query})'
|
||||||
if not q:
|
if not q:
|
||||||
if set_restriction_count:
|
if set_restriction_count:
|
||||||
self.search_restriction_book_count = len(self._map)
|
self.search_restriction_book_count = len(self._map)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -208,7 +208,7 @@ def print_basic_debug_info(out=None):
|
|||||||
from calibre.customize.ui import has_external_plugins, initialized_plugins
|
from calibre.customize.ui import has_external_plugins, initialized_plugins
|
||||||
if has_external_plugins():
|
if has_external_plugins():
|
||||||
from calibre.customize import PluginInstallationType
|
from calibre.customize import PluginInstallationType
|
||||||
names = ('{} {}'.format(p.name, p.version) for p in initialized_plugins()
|
names = (f'{p.name} {p.version}' for p in initialized_plugins()
|
||||||
if getattr(p, 'installation_type', None) is not PluginInstallationType.BUILTIN)
|
if getattr(p, 'installation_type', None) is not PluginInstallationType.BUILTIN)
|
||||||
out('Successfully initialized third party plugins:', ' && '.join(names))
|
out('Successfully initialized third party plugins:', ' && '.join(names))
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__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'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# vim:fileencoding=utf-8
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2013, Jellby <jellby at yahoo.com>'
|
__copyright__ = '2013, Jellby <jellby at yahoo.com>'
|
||||||
'''
|
'''
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__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'
|
||||||
@ -86,7 +83,7 @@ class TOLINO(EB600):
|
|||||||
|
|
||||||
def get_device_information(self, end_session=True):
|
def get_device_information(self, end_session=True):
|
||||||
self.set_device_name()
|
self.set_device_name()
|
||||||
return super(TOLINO, self).get_device_information(end_session)
|
return super().get_device_information(end_session)
|
||||||
|
|
||||||
# There are apparently two versions of this device, one with swapped
|
# There are apparently two versions of this device, one with swapped
|
||||||
# drives and one without, see https://bugs.launchpad.net/bugs/1240504
|
# drives and one without, see https://bugs.launchpad.net/bugs/1240504
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal'
|
__copyright__ = '2009, Kovid Goyal'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
|
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, James Ralston <jralston at mindspring.com>'
|
__copyright__ = '2009, James Ralston <jralston at mindspring.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -58,7 +55,7 @@ class JETBOOK(USBMS):
|
|||||||
au = mi.format_authors()
|
au = mi.format_authors()
|
||||||
if not au:
|
if not au:
|
||||||
au = 'Unknown'
|
au = 'Unknown'
|
||||||
return '%s#%s%s' % (au, title, fileext)
|
return f'{au}#{title}{fileext}'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def metadata_from_path(cls, path):
|
def metadata_from_path(cls, path):
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2011, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2011, John Schember <john at nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -557,7 +554,7 @@ class KINDLE2(KINDLE):
|
|||||||
shutil.copyfileobj(src, dest)
|
shutil.copyfileobj(src, dest)
|
||||||
fsync(dest)
|
fsync(dest)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
prints('Restored {} cover thumbnails that were destroyed by Amazon'.format(count))
|
prints(f'Restored {count} cover thumbnails that were destroyed by Amazon')
|
||||||
|
|
||||||
def delete_single_book(self, path):
|
def delete_single_book(self, path):
|
||||||
try:
|
try:
|
||||||
@ -569,7 +566,7 @@ class KINDLE2(KINDLE):
|
|||||||
os.remove(tp)
|
os.remove(tp)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
if err.errno != errno.ENOENT:
|
if err.errno != errno.ENOENT:
|
||||||
prints('Failed to delete thumbnail for {!r} at {!r} with error: {}'.format(path, tp, err))
|
prints(f'Failed to delete thumbnail for {path!r} at {tp!r} with error: {err}')
|
||||||
except Exception:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2011, Timothy Legge <timlegge@gmail.com> and Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Timothy Legge <timlegge@gmail.com> and Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -57,7 +54,7 @@ class Bookmark(): # {{{
|
|||||||
'ORDER BY bm.ContentID, bm.chapterprogress'
|
'ORDER BY bm.ContentID, bm.chapterprogress'
|
||||||
)
|
)
|
||||||
|
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub chapters: contentId={}".format(self.contentId))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub chapters: contentId={self.contentId}")
|
||||||
cursor.execute(kepub_chapter_query, book_query_values)
|
cursor.execute(kepub_chapter_query, book_query_values)
|
||||||
kepub_chapters = {}
|
kepub_chapters = {}
|
||||||
if self.kepub:
|
if self.kepub:
|
||||||
@ -69,7 +66,7 @@ class Bookmark(): # {{{
|
|||||||
'chapter_title': chapter_row['Title'],
|
'chapter_title': chapter_row['Title'],
|
||||||
'chapter_index': chapter_row['VolumeIndex']
|
'chapter_index': chapter_row['VolumeIndex']
|
||||||
}
|
}
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub chapter: kepub chapters={}".format(kepub_chapters))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub chapter: kepub chapters={kepub_chapters}")
|
||||||
except:
|
except:
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - No chapters found")
|
debug_print("Kobo::Bookmark::get_bookmark_data - No chapters found")
|
||||||
|
|
||||||
@ -83,20 +80,20 @@ class Bookmark(): # {{{
|
|||||||
# For kepubs on newer firmware, the title needs to come from an 899 row.
|
# For kepubs on newer firmware, the title needs to come from an 899 row.
|
||||||
if self.kepub:
|
if self.kepub:
|
||||||
chapter_contentID = row['ContentID']
|
chapter_contentID = row['ContentID']
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub: chapter chapter_contentID='{}'".format(chapter_contentID))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub: chapter chapter_contentID='{chapter_contentID}'")
|
||||||
filename_index = chapter_contentID.find('!')
|
filename_index = chapter_contentID.find('!')
|
||||||
book_contentID_part = chapter_contentID[:filename_index]
|
book_contentID_part = chapter_contentID[:filename_index]
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub: chapter book_contentID_part='{}'".format(book_contentID_part))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub: chapter book_contentID_part='{book_contentID_part}'")
|
||||||
file_contentID_part = chapter_contentID[filename_index + 1:]
|
file_contentID_part = chapter_contentID[filename_index + 1:]
|
||||||
filename_index = file_contentID_part.find('!')
|
filename_index = file_contentID_part.find('!')
|
||||||
opf_reference = file_contentID_part[:filename_index]
|
opf_reference = file_contentID_part[:filename_index]
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub: chapter opf_reference='{}'".format(opf_reference))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub: chapter opf_reference='{opf_reference}'")
|
||||||
file_contentID_part = file_contentID_part[filename_index + 1:]
|
file_contentID_part = file_contentID_part[filename_index + 1:]
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub: chapter file_contentID_part='{}'".format(file_contentID_part))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub: chapter file_contentID_part='{file_contentID_part}'")
|
||||||
# from urllib import quote
|
# from urllib import quote
|
||||||
# file_contentID_part = quote(file_contentID_part)
|
# file_contentID_part = quote(file_contentID_part)
|
||||||
chapter_contentID = book_contentID_part + "!" + opf_reference + "!" + file_contentID_part
|
chapter_contentID = book_contentID_part + "!" + opf_reference + "!" + file_contentID_part
|
||||||
debug_print("Kobo::Bookmark::get_bookmark_data - getting kepub chapter chapter_contentID='{}'".format(chapter_contentID))
|
debug_print(f"Kobo::Bookmark::get_bookmark_data - getting kepub chapter chapter_contentID='{chapter_contentID}'")
|
||||||
kepub_chapter = kepub_chapters.get(chapter_contentID, None)
|
kepub_chapter = kepub_chapters.get(chapter_contentID, None)
|
||||||
if kepub_chapter is not None:
|
if kepub_chapter is not None:
|
||||||
chapter_title = kepub_chapter['chapter_title']
|
chapter_title = kepub_chapter['chapter_title']
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
@ -1573,11 +1572,11 @@ class KOBOTOUCH(KOBO):
|
|||||||
if main and carda and not self.is_main_drive(main):
|
if main and carda and not self.is_main_drive(main):
|
||||||
drives['main'] = carda
|
drives['main'] = carda
|
||||||
drives['carda'] = main
|
drives['carda'] = main
|
||||||
debug_print('KoboTouch::sort_drives - swapped drives - main=%s, carda=%s' % (drives['main'], drives['carda']))
|
debug_print('KoboTouch::sort_drives - swapped drives - main={}, carda={}'.format(drives['main'], drives['carda']))
|
||||||
return drives
|
return drives
|
||||||
|
|
||||||
def is_main_drive(self, drive):
|
def is_main_drive(self, drive):
|
||||||
debug_print('KoboTouch::is_main_drive - drive=%s, path=%s' % (drive, os.path.join(drive, '.kobo')))
|
debug_print('KoboTouch::is_main_drive - drive={}, path={}'.format(drive, os.path.join(drive, '.kobo')))
|
||||||
return os.path.exists(self.normalize_path(os.path.join(drive, '.kobo')))
|
return os.path.exists(self.normalize_path(os.path.join(drive, '.kobo')))
|
||||||
|
|
||||||
def books(self, oncard=None, end_session=True):
|
def books(self, oncard=None, end_session=True):
|
||||||
@ -2128,13 +2127,13 @@ class KOBOTOUCH(KOBO):
|
|||||||
from css_parser import parseFile as cssparseFile
|
from css_parser import parseFile as cssparseFile
|
||||||
try:
|
try:
|
||||||
extra_sheet = cssparseFile(extra_css_path)
|
extra_sheet = cssparseFile(extra_css_path)
|
||||||
debug_print("KoboTouch:get_extra_css: Using extra CSS in {} ({} rules)".format(extra_css_path, len(extra_sheet.cssRules)))
|
debug_print(f"KoboTouch:get_extra_css: Using extra CSS in {extra_css_path} ({len(extra_sheet.cssRules)} rules)")
|
||||||
if len(extra_sheet.cssRules) ==0:
|
if len(extra_sheet.cssRules) ==0:
|
||||||
debug_print("KoboTouch:get_extra_css: Extra CSS file has no valid rules. CSS will not be modified.")
|
debug_print("KoboTouch:get_extra_css: Extra CSS file has no valid rules. CSS will not be modified.")
|
||||||
extra_sheet = None
|
extra_sheet = None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug_print("KoboTouch:get_extra_css: Problem parsing extra CSS file {}".format(extra_css_path))
|
debug_print(f"KoboTouch:get_extra_css: Problem parsing extra CSS file {extra_css_path}")
|
||||||
debug_print("KoboTouch:get_extra_css: Exception {}".format(e))
|
debug_print(f"KoboTouch:get_extra_css: Exception {e}")
|
||||||
|
|
||||||
# create dictionary of features enabled in kobo extra css
|
# create dictionary of features enabled in kobo extra css
|
||||||
self.extra_css_options = {}
|
self.extra_css_options = {}
|
||||||
@ -2166,7 +2165,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
i = 0
|
i = 0
|
||||||
for file, n, mi in zip(files, names, metadata):
|
for file, n, mi in zip(files, names, metadata):
|
||||||
debug_print("KoboTouch:upload_books: Processing book: {} by {}".format(mi.title, " and ".join(mi.authors)))
|
debug_print("KoboTouch:upload_books: Processing book: {} by {}".format(mi.title, " and ".join(mi.authors)))
|
||||||
debug_print("KoboTouch:upload_books: file=%s, name=%s" % (file, n))
|
debug_print(f"KoboTouch:upload_books: file={file}, name={n}")
|
||||||
self.report_progress(i / float(len(files)), "Processing book: {} by {}".format(mi.title, " and ".join(mi.authors)))
|
self.report_progress(i / float(len(files)), "Processing book: {} by {}".format(mi.title, " and ".join(mi.authors)))
|
||||||
mi.kte_calibre_name = n
|
mi.kte_calibre_name = n
|
||||||
self._modify_epub(file, mi)
|
self._modify_epub(file, mi)
|
||||||
@ -2208,7 +2207,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _modify_epub(self, book_file, metadata, container=None):
|
def _modify_epub(self, book_file, metadata, container=None):
|
||||||
debug_print("KoboTouch:_modify_epub:Processing {} - {}".format(metadata.author_sort, metadata.title))
|
debug_print(f"KoboTouch:_modify_epub:Processing {metadata.author_sort} - {metadata.title}")
|
||||||
|
|
||||||
# Currently only modifying CSS, so if no stylesheet, don't do anything
|
# Currently only modifying CSS, so if no stylesheet, don't do anything
|
||||||
if not self.extra_sheet:
|
if not self.extra_sheet:
|
||||||
@ -2229,9 +2228,9 @@ class KOBOTOUCH(KOBO):
|
|||||||
|
|
||||||
# future css mods may be epub/kepub specific, so pass file extension arg
|
# future css mods may be epub/kepub specific, so pass file extension arg
|
||||||
fileext = os.path.splitext(book_file)[-1].lower()
|
fileext = os.path.splitext(book_file)[-1].lower()
|
||||||
debug_print("KoboTouch:_modify_epub: Modifying {}".format(cssname))
|
debug_print(f"KoboTouch:_modify_epub: Modifying {cssname}")
|
||||||
if self._modify_stylesheet(newsheet, fileext):
|
if self._modify_stylesheet(newsheet, fileext):
|
||||||
debug_print("KoboTouch:_modify_epub:CSS rules {} -> {} ({})".format(oldrules, len(newsheet.cssRules), cssname))
|
debug_print(f"KoboTouch:_modify_epub:CSS rules {oldrules} -> {len(newsheet.cssRules)} ({cssname})")
|
||||||
container.dirty(cssname)
|
container.dirty(cssname)
|
||||||
is_dirty = True
|
is_dirty = True
|
||||||
|
|
||||||
@ -2285,8 +2284,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
container = get_container(book_file)
|
container = get_container(book_file)
|
||||||
container.css_preprocessor = DummyCSSPreProcessor()
|
container.css_preprocessor = DummyCSSPreProcessor()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug_print("KoboTouch:create_container: exception from get_container {} - {}".format(metadata.author_sort, metadata.title))
|
debug_print(f"KoboTouch:create_container: exception from get_container {metadata.author_sort} - {metadata.title}")
|
||||||
debug_print("KoboTouch:create_container: exception is: {}".format(e))
|
debug_print(f"KoboTouch:create_container: exception is: {e}")
|
||||||
else:
|
else:
|
||||||
commit_container = False
|
commit_container = False
|
||||||
debug_print("KoboTouch:create_container: received container")
|
debug_print("KoboTouch:create_container: received container")
|
||||||
@ -3090,7 +3089,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
debug_print(' Did not find a record - adding shelf "%s"' % bookshelf_name)
|
debug_print(' Did not find a record - adding shelf "%s"' % bookshelf_name)
|
||||||
cursor.execute(addquery, add_values)
|
cursor.execute(addquery, add_values)
|
||||||
elif result['_IsDeleted'] == 'true':
|
elif result['_IsDeleted'] == 'true':
|
||||||
debug_print("KoboTouch:check_for_bookshelf - Shelf '%s' is deleted - undeleting. result['_IsDeleted']='%s'" % (
|
debug_print("KoboTouch:check_for_bookshelf - Shelf '{}' is deleted - undeleting. result['_IsDeleted']='{}'".format(
|
||||||
bookshelf_name, str(result['_IsDeleted'])))
|
bookshelf_name, str(result['_IsDeleted'])))
|
||||||
cursor.execute(updatequery, test_values)
|
cursor.execute(updatequery, test_values)
|
||||||
|
|
||||||
@ -3177,7 +3176,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
# debug_print('KoboTouch:set_core_metadata book="%s"' % book.title)
|
# debug_print('KoboTouch:set_core_metadata book="%s"' % book.title)
|
||||||
show_debug = self.is_debugging_title(book.title)
|
show_debug = self.is_debugging_title(book.title)
|
||||||
if show_debug:
|
if show_debug:
|
||||||
debug_print('KoboTouch:set_core_metadata book="%s", \nseries_only="%s"' % (book, series_only))
|
debug_print(f'KoboTouch:set_core_metadata book="{book}", \nseries_only="{series_only}"')
|
||||||
|
|
||||||
plugboard = None
|
plugboard = None
|
||||||
if self.plugboard_func and not series_only:
|
if self.plugboard_func and not series_only:
|
||||||
@ -3204,11 +3203,11 @@ class KOBOTOUCH(KOBO):
|
|||||||
kobo_metadata = book.kobo_metadata
|
kobo_metadata = book.kobo_metadata
|
||||||
|
|
||||||
if show_debug:
|
if show_debug:
|
||||||
debug_print('KoboTouch:set_core_metadata newmi.series="%s"' % (newmi.series, ))
|
debug_print(f'KoboTouch:set_core_metadata newmi.series="{newmi.series}"')
|
||||||
debug_print('KoboTouch:set_core_metadata kobo_metadata.series="%s"' % (kobo_metadata.series, ))
|
debug_print(f'KoboTouch:set_core_metadata kobo_metadata.series="{kobo_metadata.series}"')
|
||||||
debug_print('KoboTouch:set_core_metadata newmi.series_index="%s"' % (newmi.series_index, ))
|
debug_print(f'KoboTouch:set_core_metadata newmi.series_index="{newmi.series_index}"')
|
||||||
debug_print('KoboTouch:set_core_metadata kobo_metadata.series_index="%s"' % (kobo_metadata.series_index, ))
|
debug_print(f'KoboTouch:set_core_metadata kobo_metadata.series_index="{kobo_metadata.series_index}"')
|
||||||
debug_print('KoboTouch:set_core_metadata book.kobo_series_number="%s"' % (book.kobo_series_number, ))
|
debug_print(f'KoboTouch:set_core_metadata book.kobo_series_number="{book.kobo_series_number}"')
|
||||||
|
|
||||||
if newmi.series is not None:
|
if newmi.series is not None:
|
||||||
new_series = newmi.series
|
new_series = newmi.series
|
||||||
@ -3223,10 +3222,10 @@ class KOBOTOUCH(KOBO):
|
|||||||
series_changed = not (new_series == kobo_metadata.series)
|
series_changed = not (new_series == kobo_metadata.series)
|
||||||
series_number_changed = not (new_series_number == book.kobo_series_number)
|
series_number_changed = not (new_series_number == book.kobo_series_number)
|
||||||
if show_debug:
|
if show_debug:
|
||||||
debug_print('KoboTouch:set_core_metadata new_series="%s"' % (new_series, ))
|
debug_print(f'KoboTouch:set_core_metadata new_series="{new_series}"')
|
||||||
debug_print('KoboTouch:set_core_metadata new_series_number="%s"' % (new_series_number, ))
|
debug_print(f'KoboTouch:set_core_metadata new_series_number="{new_series_number}"')
|
||||||
debug_print('KoboTouch:set_core_metadata series_number_changed="%s"' % (series_number_changed, ))
|
debug_print(f'KoboTouch:set_core_metadata series_number_changed="{series_number_changed}"')
|
||||||
debug_print('KoboTouch:set_core_metadata series_changed="%s"' % (series_changed, ))
|
debug_print(f'KoboTouch:set_core_metadata series_changed="{series_changed}"')
|
||||||
|
|
||||||
if series_changed or series_number_changed:
|
if series_changed or series_number_changed:
|
||||||
update_values.append(new_series)
|
update_values.append(new_series)
|
||||||
@ -3250,7 +3249,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
update_values.append(newmi.series_index)
|
update_values.append(newmi.series_index)
|
||||||
set_clause += ', SeriesNumberFloat = ? '
|
set_clause += ', SeriesNumberFloat = ? '
|
||||||
if show_debug:
|
if show_debug:
|
||||||
debug_print("KoboTouch:set_core_metadata Setting SeriesID - new_series='%s', series_id='%s'" % (new_series, series_id))
|
debug_print(f"KoboTouch:set_core_metadata Setting SeriesID - new_series='{new_series}', series_id='{series_id}'")
|
||||||
|
|
||||||
if not series_only:
|
if not series_only:
|
||||||
if not (newmi.title == kobo_metadata.title):
|
if not (newmi.title == kobo_metadata.title):
|
||||||
@ -3900,8 +3899,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
debug_print('KoboTouch:dump_bookshelves - end')
|
debug_print('KoboTouch:dump_bookshelves - end')
|
||||||
|
|
||||||
def __str__(self, *args, **kwargs):
|
def __str__(self, *args, **kwargs):
|
||||||
options = ', '.join(['%s: %s' % (x.name, self.get_pref(x.name)) for x in self._config().preferences])
|
options = ', '.join([f'{x.name}: {self.get_pref(x.name)}' for x in self._config().preferences])
|
||||||
return "Driver:%s, Options - %s" % (self.name, options)
|
return f"Driver:{self.name}, Options - {options}"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
|
|
||||||
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user