1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-17 11:43:30 +02:00

Finalizing logging transition.

This commit is contained in:
2021-06-24 20:31:37 +02:00
parent 230fe90e69
commit 0a9536b180
16 changed files with 74 additions and 94 deletions

View File

@@ -62,7 +62,7 @@ class HTMLTOCAdder(object):
title = self.title or oeb.translate(DEFAULT_TITLE)
style = self.style
if style not in STYLE_CSS:
oeb.logger.error('Unknown TOC style %r' % style)
oeb.logger.error('Unknown TOC style %r', style)
style = 'nested'
id, css_href = oeb.manifest.generate('tocstyle', 'tocstyle.css')
oeb.manifest.add(id, css_href, base.CSS_MIME, data=STYLE_CSS[style])

View File

@@ -65,17 +65,19 @@ class SVGRasterizer(object):
box = [float(x) for x in filter(None, re.split('[, ]', view_box))]
sizes = [box[2]-box[0], box[3] - box[1]]
except (TypeError, ValueError, IndexError):
logger.warn('SVG image has invalid viewBox="%s", ignoring the viewBox' % view_box)
logger.warning('SVG image has invalid viewBox="%s", ignoring '
'the viewBox', view_box)
else:
for image in elem.xpath('descendant::*[local-name()="image" and '
'@height and contains(@height, "%")]'):
logger.info('Found SVG image height in %, trying to convert...')
logger.info('Found SVG image height in %, trying to '
'convert...')
try:
h = float(image.get('height').replace('%', ''))/100.
image.set('height', str(h*sizes[1]))
except:
logger.exception('Failed to convert percentage height:',
image.get('height'))
logger.exception('Failed to convert percentage '
'height: %s', image.get('height'))
data = QByteArray(xml2str(elem, with_tail=False))
svg = QSvgRenderer(data)
@@ -85,8 +87,8 @@ class SVGRasterizer(object):
size.setHeight(sizes[1])
if width or height:
size.scale(width, height, Qt.KeepAspectRatio)
logger.info('Rasterizing %r to %dx%d'
% (elem, size.width(), size.height()))
logger.info('Rasterizing %r to %dx%d', elem, size.width(),
size.height())
image = QImage(size, QImage.Format_ARGB32_Premultiplied)
image.fill(QColor("white").rgb())
painter = QPainter(image)
@@ -186,8 +188,8 @@ class SVGRasterizer(object):
href = self.images[key]
else:
logger = self.oeb.logger
logger.info('Rasterizing %r to %dx%d'
% (svgitem.href, size.width(), size.height()))
logger.info('Rasterizing %r to %dx%d', svgitem.href, size.width(),
size.height())
image = QImage(size, QImage.Format_ARGB32_Premultiplied)
image.fill(QColor("white").rgb())
painter = QPainter(image)
@@ -219,7 +221,7 @@ class SVGRasterizer(object):
if not covers:
return
if str(covers[0]) not in self.oeb.manifest.ids:
self.oeb.logger.warn('Cover not in manifest, skipping.')
self.oeb.logger.warning('Cover not in manifest, skipping.')
self.oeb.metadata.clear('cover')
return
cover = self.oeb.manifest.ids[str(covers[0])]

View File

@@ -7,10 +7,6 @@ from ebook_converter.ebooks.oeb.base import CSS_MIME, OEB_DOCS
from ebook_converter.ebooks.oeb.base import urlnormalize, iterlinks
__license__ = 'GPL v3'
__copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
class ManifestTrimmer(object):
@classmethod
@@ -69,5 +65,5 @@ class ManifestTrimmer(object):
unchecked = new
for item in oeb.manifest.values():
if item not in used:
oeb.logger.info('Trimming %r from manifest' % item.href)
oeb.logger.info('Trimming %r from manifest', item.href)
oeb.manifest.remove(item)