mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
2a8f7de119
commit
064b1660c6
@ -1742,7 +1742,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
if show_debug:
|
if show_debug:
|
||||||
debug_print(f"KoboTouch:update_booklist - title='{title}'", f'ContentType={ContentType}', 'isdownloaded=', isdownloaded)
|
debug_print(f"KoboTouch:update_booklist - title='{title}'", f'ContentType={ContentType}', 'isdownloaded=', isdownloaded)
|
||||||
debug_print(
|
debug_print(
|
||||||
f' prefix={prefix}, DateCreated={DateCreated}, readstatus={readstatus}, MimeType={MimeType}, expired={expired}, favouritesindex={favouritesindex}, accessibility={accessibility}, isdownloaded={isdownloaded}')
|
f' prefix={prefix}, DateCreated={DateCreated}, readstatus={readstatus}, MimeType={MimeType},'
|
||||||
|
f' expired={expired}, favouritesindex={favouritesindex}, accessibility={accessibility}, isdownloaded={isdownloaded}')
|
||||||
changed = False
|
changed = False
|
||||||
try:
|
try:
|
||||||
lpath = path.partition(self.normalize_path(prefix))[2]
|
lpath = path.partition(self.normalize_path(prefix))[2]
|
||||||
@ -2720,7 +2721,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
debug_print('KoboTouch:update_device_database_collections - about to clear empty bookshelves')
|
debug_print('KoboTouch:update_device_database_collections - about to clear empty bookshelves')
|
||||||
self.delete_empty_bookshelves(connection)
|
self.delete_empty_bookshelves(connection)
|
||||||
debug_print(f'KoboTouch:update_device_database_collections - Number of series set={self.series_set} Number of books={books_in_library}')
|
debug_print(f'KoboTouch:update_device_database_collections - Number of series set={self.series_set} Number of books={books_in_library}')
|
||||||
debug_print(f'KoboTouch:update_device_database_collections - Number of core metadata set={self.core_metadata_set} Number of books={books_in_library}')
|
debug_print(f'KoboTouch:update_device_database_collections - Number of core metadata set={self.core_metadata_set}'
|
||||||
|
f' Number of books={books_in_library}')
|
||||||
|
|
||||||
self.dump_bookshelves(connection)
|
self.dump_bookshelves(connection)
|
||||||
|
|
||||||
@ -2914,7 +2916,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
for ending, cover_options in self.cover_file_endings().items():
|
for ending, cover_options in self.cover_file_endings().items():
|
||||||
kobo_size, min_dbversion, max_dbversion, is_full_size = cover_options
|
kobo_size, min_dbversion, max_dbversion, is_full_size = cover_options
|
||||||
if show_debug:
|
if show_debug:
|
||||||
debug_print(f'KoboTouch:_upload_cover - library_cover_size={library_cover_size} -> kobo_size={kobo_size}, min_dbversion={min_dbversion} max_dbversion={max_dbversion}, is_full_size={is_full_size}')
|
debug_print(f'KoboTouch:_upload_cover - library_cover_size={library_cover_size} -> kobo_size={kobo_size},'
|
||||||
|
f' min_dbversion={min_dbversion} max_dbversion={max_dbversion}, is_full_size={is_full_size}')
|
||||||
|
|
||||||
if self.dbversion >= min_dbversion and self.dbversion <= max_dbversion:
|
if self.dbversion >= min_dbversion and self.dbversion <= max_dbversion:
|
||||||
if show_debug:
|
if show_debug:
|
||||||
|
@ -179,7 +179,10 @@ class USB_DEVICE_DESCRIPTOR(Structure):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'USBDevice(class=0x{self.bDeviceClass:x} sub_class=0x{self.bDeviceSubClass:x} protocol=0x{self.bDeviceProtocol:x} vendor_id=0x{self.idVendor:x} product_id=0x{self.idProduct:x} bcd=0x{self.bcdDevice:x} manufacturer={self.iManufacturer} product={self.iProduct} serial_number={self.iSerialNumber})'
|
return (
|
||||||
|
f'USBDevice(class=0x{self.bDeviceClass:x} sub_class=0x{self.bDeviceSubClass:x} protocol=0x{self.bDeviceProtocol:x}'
|
||||||
|
f' vendor_id=0x{self.idVendor:x} product_id=0x{self.idProduct:x} bcd=0x{self.bcdDevice:x} manufacturer={self.iManufacturer}'
|
||||||
|
f'product={self.iProduct} serial_number={self.iSerialNumber})')
|
||||||
|
|
||||||
|
|
||||||
class USB_ENDPOINT_DESCRIPTOR(Structure):
|
class USB_ENDPOINT_DESCRIPTOR(Structure):
|
||||||
|
@ -396,7 +396,7 @@ class DirectoryEntry:
|
|||||||
self.size = size
|
self.size = size
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'DirectoryEntry(name={repr(self.name)}, section={self.section}, offset={self.offset}, size={self.size})'
|
return f'DirectoryEntry(name={self.name!r}, section={self.section}, offset={self.offset}, size={self.size})'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self)
|
return repr(self)
|
||||||
@ -427,7 +427,9 @@ class ManifestItem:
|
|||||||
return self.internal == other
|
return self.internal == other
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"ManifestItem(internal={self.internal!r}, path={self.path!r}, mime_type={self.mime_type!r}, offset={self.offset}, root={self.root!r}, state={self.state!r})"
|
return (
|
||||||
|
f'ManifestItem(internal={self.internal!r}, path={self.path!r}, mime_type={self.mime_type!r},'
|
||||||
|
f' offset={self.offset}, root={self.root!r}, state={self.state!r})')
|
||||||
|
|
||||||
|
|
||||||
def preserve(function):
|
def preserve(function):
|
||||||
|
@ -932,7 +932,9 @@ class Image(LRFObject):
|
|||||||
data = property(fget=lambda self: self._document.objects[self.refstream].stream)
|
data = property(fget=lambda self: self._document.objects[self.refstream].stream)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'<Image objid="{self.id}" x0="{self.x0}" y0="{self.y0}" x1="{self.x1}" y1="{self.y1}" xsize="{self.xsize}" ysize="{self.ysize}" refstream="{self.refstream}" />\n'
|
return (
|
||||||
|
f'<Image objid="{self.id}" x0="{self.x0}" y0="{self.y0}" x1="{self.x1}" y1="{self.y1}"'
|
||||||
|
f' xsize="{self.xsize}" ysize="{self.ysize}" refstream="{self.refstream}" />\n')
|
||||||
|
|
||||||
|
|
||||||
class PutObj(EmptyPageElement):
|
class PutObj(EmptyPageElement):
|
||||||
|
@ -591,7 +591,7 @@ class TBSIndexing: # {{{
|
|||||||
if entries:
|
if entries:
|
||||||
ans.append(f'\t{typ}:')
|
ans.append(f'\t{typ}:')
|
||||||
for x in entries:
|
for x in entries:
|
||||||
ans.append(f"\t\tIndex Entry: {x.index} (Parent index: {x.parent_index}, Depth: {x.depth}, Offset: {x.offset}, Size: {x.size}) [{x.label}]")
|
ans.append(f'\t\tIndex Entry: {x.index} (Parent index: {x.parent_index}, Depth: {x.depth}, Offset: {x.offset}, Size: {x.size}) [{x.label}]')
|
||||||
|
|
||||||
def bin4(num):
|
def bin4(num):
|
||||||
ans = bin(num)[2:]
|
ans = bin(num)[2:]
|
||||||
@ -646,7 +646,9 @@ class TBSIndexing: # {{{
|
|||||||
raise ValueError('Dont know how to interpret flags'
|
raise ValueError('Dont know how to interpret flags'
|
||||||
f' {extra!r} while reading section transitions')
|
f' {extra!r} while reading section transitions')
|
||||||
nsi = self.get_index(psi.index+1)
|
nsi = self.get_index(psi.index+1)
|
||||||
ans.append(f'Last article in this record of section {psi.index} (relative to next section index [{nsi.index}]): {ai} [{ai + nsi.index} absolute index]')
|
ans.append(
|
||||||
|
f'Last article in this record of section {psi.index} (relative to next section index [{nsi.index}]):'
|
||||||
|
f' {ai} [{ai + nsi.index} absolute index]')
|
||||||
psi = nsi
|
psi = nsi
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -654,9 +656,9 @@ class TBSIndexing: # {{{
|
|||||||
|
|
||||||
num = extra.get(0b0100, None)
|
num = extra.get(0b0100, None)
|
||||||
if num is None:
|
if num is None:
|
||||||
msg = f"The section {psi.index} has at most one article in this record"
|
msg = f'The section {psi.index} has at most one article in this record'
|
||||||
else:
|
else:
|
||||||
msg = f"Number of articles in this record of section {psi.index}: {num}"
|
msg = f'Number of articles in this record of section {psi.index}: {num}'
|
||||||
ans.append(msg)
|
ans.append(msg)
|
||||||
|
|
||||||
offset = extra.get(0b0001, None)
|
offset = extra.get(0b0001, None)
|
||||||
@ -664,7 +666,9 @@ class TBSIndexing: # {{{
|
|||||||
if offset == 0:
|
if offset == 0:
|
||||||
ans.append(f'This record is spanned by the article:{ai + psi.index}')
|
ans.append(f'This record is spanned by the article:{ai + psi.index}')
|
||||||
else:
|
else:
|
||||||
ans.append(f'->Offset to start of next section ({psi.index + 1}) from start of record: {offset} [{offset + record_offset} absolute offset]')
|
ans.append(
|
||||||
|
f'->Offset to start of next section ({psi.index + 1}) from start of record:'
|
||||||
|
f' {offset} [{offset + record_offset} absolute offset]')
|
||||||
return byts
|
return byts
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ class Reader(FormatReader):
|
|||||||
vmajor = (self.header_record.version & 0x0000FF00) >> 8
|
vmajor = (self.header_record.version & 0x0000FF00) >> 8
|
||||||
vminor = self.header_record.version & 0x000000FF
|
vminor = self.header_record.version & 0x000000FF
|
||||||
if vmajor < 1 or (vmajor == 1 and vminor < 40):
|
if vmajor < 1 or (vmajor == 1 and vminor < 40):
|
||||||
raise zTXTError(f'Unsupported ztxt version ({vmajor}.{vminor}). Only versions newer than {SUPPORTED_VERSION[0]}.{SUPPORTED_VERSION[1]} are supported.')
|
raise zTXTError(f'Unsupported ztxt version ({vmajor}.{vminor}).'
|
||||||
|
f' Only versions newer than {SUPPORTED_VERSION[0]}.{SUPPORTED_VERSION[1]} are supported.')
|
||||||
|
|
||||||
if (self.header_record.flags & 0x01) == 0:
|
if (self.header_record.flags & 0x01) == 0:
|
||||||
raise zTXTError('Only compression method 1 (random access) is supported')
|
raise zTXTError('Only compression method 1 (random access) is supported')
|
||||||
|
@ -271,8 +271,8 @@ class Text(Element):
|
|||||||
if self.font_size_em == other.font_size_em \
|
if self.font_size_em == other.font_size_em \
|
||||||
and False \
|
and False \
|
||||||
and self.font.id == other.font.id \
|
and self.font.id == other.font.id \
|
||||||
and re.match(r'<span style="font-size:', self.raw) is not None \
|
and self.raw.startswith(r'<span style="font-size:') \
|
||||||
and re.match(r'<span style="font-size:', other.raw) is not None:
|
and other.raw.startswith(r'<span style="font-size:'):
|
||||||
# We have the same class, so merge
|
# We have the same class, so merge
|
||||||
m_self = re.match(r'^(.+)</span>$', self.raw)
|
m_self = re.match(r'^(.+)</span>$', self.raw)
|
||||||
m_other = re.match(r'^<span style="font-size:.+em">(.+</span>)$', other.raw)
|
m_other = re.match(r'^<span style="font-size:.+em">(.+</span>)$', other.raw)
|
||||||
@ -281,7 +281,7 @@ class Text(Element):
|
|||||||
other.raw = m_other.group(1)
|
other.raw = m_other.group(1)
|
||||||
elif self.font_size_em != other.font_size_em \
|
elif self.font_size_em != other.font_size_em \
|
||||||
and self.font_size_em != 1.00:
|
and self.font_size_em != 1.00:
|
||||||
if re.match(r'<span', self.raw) is None:
|
if not self.raw.startswith(r'<span'):
|
||||||
self.raw = f'<span style="font-size:{self.font_size_em!s}em">{self.raw}</span>'
|
self.raw = f'<span style="font-size:{self.font_size_em!s}em">{self.raw}</span>'
|
||||||
# Try to allow for a very large initial character
|
# Try to allow for a very large initial character
|
||||||
elif len(self.text_as_string) <= 2 \
|
elif len(self.text_as_string) <= 2 \
|
||||||
|
@ -159,7 +159,9 @@ class TabStop(str):
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f'TabStop(text={str.__repr__(self)} num={self.num} start={self.start} is_mirror={self.is_mirror} takes_selection={self.takes_selection} is_toplevel={self.is_toplevel})'
|
return (
|
||||||
|
f'TabStop(text={str.__repr__(self)} num={self.num} start={self.start} is_mirror={self.is_mirror}'
|
||||||
|
f' takes_selection={self.takes_selection} is_toplevel={self.is_toplevel})')
|
||||||
|
|
||||||
|
|
||||||
def parse_template(template, start_offset=0, is_toplevel=True, grouped=True):
|
def parse_template(template, start_offset=0, is_toplevel=True, grouped=True):
|
||||||
|
@ -219,7 +219,7 @@ class UpdateMixin:
|
|||||||
green, _('Update available'), version_url, calibre_version, plt)
|
green, _('Update available'), version_url, calibre_version, plt)
|
||||||
else:
|
else:
|
||||||
plt = ngettext('plugin update available', 'plugin updates available', number_of_plugin_updates)
|
plt = ngettext('plugin update available', 'plugin updates available', number_of_plugin_updates)
|
||||||
msg = f"<a href=\"update:{version_url}\">{number_of_plugin_updates} {plt}</a>"
|
msg = f'<a href="update:{version_url}">{number_of_plugin_updates} {plt}</a>'
|
||||||
self.status_bar.update_label.setText(msg)
|
self.status_bar.update_label.setText(msg)
|
||||||
self.status_bar.update_label.setVisible(True)
|
self.status_bar.update_label.setVisible(True)
|
||||||
|
|
||||||
|
@ -377,7 +377,8 @@ class Importer:
|
|||||||
raise ValueError(f'The exported data in {name} is not valid, tail too small')
|
raise ValueError(f'The exported data in {name} is not valid, tail too small')
|
||||||
part_num, version, is_last = struct.unpack(Exporter.TAIL_FMT, raw)
|
part_num, version, is_last = struct.unpack(Exporter.TAIL_FMT, raw)
|
||||||
if version > Exporter.VERSION:
|
if version > Exporter.VERSION:
|
||||||
raise ValueError(f'The exported data in {name} is not valid, version ({version}) is higher than maximum supported version. You might need to upgrade calibre first.')
|
raise ValueError(f'The exported data in {name} is not valid, version ({version})'
|
||||||
|
' is higher than maximum supported version. You might need to upgrade calibre first.')
|
||||||
part_map[part_num] = path, is_last, size_of_part
|
part_map[part_num] = path, is_last, size_of_part
|
||||||
if self.version == -1:
|
if self.version == -1:
|
||||||
self.version = version
|
self.version = version
|
||||||
|
@ -47,4 +47,4 @@ def diff_hists(h1, h2):
|
|||||||
if k not in h2:
|
if k not in h2:
|
||||||
h2[k] = 0
|
h2[k] = 0
|
||||||
if h1[k] != h2[k]:
|
if h1[k] != h2[k]:
|
||||||
print(f"{k}: {h1[k]} -> {h2[k]} ({h2[k] > h1[k] and '+' or ''}{h2[k] - h1[k]})")
|
print(f"{k}: {h1[k]} -> {h2[k]} ({(h2[k] > h1[k] and '+') or ''}{h2[k] - h1[k]})")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user