From 471bedf9f226be08f3e3b4b0506187b4cffed9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= <6774676+eumiro@users.noreply.github.com> Date: Mon, 1 Feb 2021 21:35:52 +0100 Subject: [PATCH] Fix logging % format --- svglib/svglib.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/svglib/svglib.py b/svglib/svglib.py index ec09614..241c4a7 100755 --- a/svglib/svglib.py +++ b/svglib/svglib.py @@ -258,7 +258,7 @@ def convertTransform(self, svgAttr): ops = ops.replace(',', ' ').split() if len(ops) != len(indices): - logger.warning("Unable to parse transform expression '%s'" % svgAttr) + logger.warning("Unable to parse transform expression %r", svgAttr) return [] result = [] @@ -309,7 +309,7 @@ def convertLength(self, svgAttr, em_base=12, attr_name=None, default=0.0): elif attr_name in ('y', 'cy', 'y1', 'y2', 'height'): full = self.main_box.height else: - logger.error("Unable to detect if node '%s' is width or height" % attr_name) + logger.error("Unable to detect if node %r is width or height", attr_name) return float(text[:-1]) return float(text[:-1]) / 100 * full elif text.endswith("pc"): @@ -372,7 +372,7 @@ def convertColor(self, svgAttr): except AttributeError: pass if color is None: - logger.warning("Can't handle color: %s" % text) + logger.warning("Can't handle color: %s", text) else: return self.color_converter(color) @@ -481,7 +481,7 @@ def __init__(self, obj): self.usedAttrs = [] def __repr__(self): - return '' % self.object + return '', self.object def getAttribute(self, name): # add argument to the history, if not already present @@ -543,7 +543,7 @@ def render(self, svg_node): main_group = self.renderSvg(node, outermost=True) for xlink in self.waiting_use_nodes.keys(): - logger.debug("Ignoring unavailable object width ID '%s'." % xlink) + logger.debug("Ignoring unavailable object width ID %r.", xlink) main_group.translate(0 - view_box.x, -view_box.height - view_box.y) @@ -610,7 +610,7 @@ def renderNode(self, node, parent=None): parent.add(item) else: ignored = True - logger.debug("Ignoring node: %s" % name) + logger.debug("Ignoring node: %s", name) if not ignored: if nid and item: @@ -663,7 +663,7 @@ def get_shape_from_node(node): return ref = m.groups()[0] if ref not in self.definitions: - logger.warning("Unable to find a clipping path with id %s" % ref) + logger.warning("Unable to find a clipping path with id %s", ref) return shape = get_shape_from_node(self.definitions[ref]) @@ -683,7 +683,7 @@ def get_shape_from_node(node): elif isinstance(shape, Path): return ClippingPath(copy_from=shape) elif shape: - logging.error("Unsupported shape type %s for clipping" % shape.__class__.__name__) + logging.error("Unsupported shape type %s for clipping", shape.__class__.__name__) def print_unused_attributes(self, node, n): if logger.level > logging.DEBUG: @@ -691,7 +691,7 @@ def print_unused_attributes(self, node, n): all_attrs = self.attrConverter.getAllAttributes(node).keys() unused_attrs = [attr for attr in all_attrs if attr not in n.usedAttrs] if unused_attrs: - logger.debug("Unused attrs: %s %s" % (node_name(n), unused_attrs)) + logger.debug("Unused attrs: %s %s", node_name(n), unused_attrs) def apply_node_attr_to_group(self, node, group): getAttr = node.getAttribute @@ -769,7 +769,7 @@ def xlink_href_target(self, node, group=None): # This will catch invalid images PDFImage(path, 0, 0) except IOError: - logger.error("Unable to read the image %s. Skipping..." % path) + logger.error("Unable to read the image %s. Skipping...", path) return None return path @@ -1261,7 +1261,7 @@ def convertPath(self, node): path.closePath() else: - logger.debug("Suspicious path operator: %s" % op) + logger.debug("Suspicious path operator: %s", op) lastop = op gr = Group() @@ -1335,7 +1335,7 @@ def applyTransformOnGroup(self, transform, group): elif op == "matrix": group.transform = values else: - logger.debug("Ignoring transform: %s %s" % (op, values)) + logger.debug("Ignoring transform: %s %s", op, values) def applyStyleOnShape(self, shape, node, only_explicit=False): """ @@ -1449,7 +1449,7 @@ def load_svg_file(path, resolve_entities=False): doc = etree.parse(path, parser=parser) svg_root = doc.getroot() except Exception as exc: - logger.error("Failed to load input file! (%s)" % exc) + logger.error("Failed to load input file! (%s)", exc) else: return svg_root