From 08666176c9842ce1aac42dee4e3f1450a16cb1e4 Mon Sep 17 00:00:00 2001 From: Ryan Jarvis Date: Fri, 30 Mar 2018 12:19:46 -0700 Subject: [PATCH] Ensure Python2.6 compatibility for older Inkscape --- inkscape_contributed/eggbot_acrostic.py | 4 ++-- inkscape_contributed/eggbot_maze.py | 16 ++++++++-------- inkscape_contributed/eggbot_pptb.py | 2 +- inkscape_contributed/eggbot_sineandlace.py | 8 ++++---- inkscape_contributed/eggbot_spiraltext.py | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/inkscape_contributed/eggbot_acrostic.py b/inkscape_contributed/eggbot_acrostic.py index 3d4d8fa..a4dad55 100755 --- a/inkscape_contributed/eggbot_acrostic.py +++ b/inkscape_contributed/eggbot_acrostic.py @@ -251,9 +251,9 @@ class AcrosticText(inkex.Effect): # approximate position, etc.). if self.options.flip: - attribs = {'transform': 'matrix(-{:f},0,0,-{:f},{:d},{:d})'.format(scale_x, scale_y, doc_width, doc_height)} + attribs = {'transform': 'matrix(-{0:f},0,0,-{1:f},{2:d},{3:d})'.format(scale_x, scale_y, doc_width, doc_height)} else: - attribs = {'transform': 'scale({:f},{:f})'.format(scale_x, scale_y)} + attribs = {'transform': 'scale({0:f},{1:f})'.format(scale_x, scale_y)} container = inkex.etree.SubElement(self.document.getroot(), 'g', attribs) # Finally, we render each line of text diff --git a/inkscape_contributed/eggbot_maze.py b/inkscape_contributed/eggbot_maze.py index 5add74c..e487c93 100755 --- a/inkscape_contributed/eggbot_maze.py +++ b/inkscape_contributed/eggbot_maze.py @@ -76,9 +76,9 @@ def draw_SVG_path(pts, c, t, parent): return if isinstance(pts, list): assert len(pts) % 3 == 0, "len(pts) must be a multiple of three" - d = "{} {:d},{:d}".format(pts[0], pts[1], pts[2]) + d = "{0} {1:d},{2:d}".format(pts[0], pts[1], pts[2]) for i in range(3, len(pts), 3): - d += " {} {:d},{:d}".format(pts[i], pts[i + 1], pts[i + 2]) + d += " {0} {1:d},{2:d}".format(pts[i], pts[i + 1], pts[i + 2]) elif isinstance(pts, str): d = pts else: @@ -264,7 +264,7 @@ class Maze(inkex.Effect): translate_y = float(PLOT_HEIGHT - TARGET_HEIGHT) / 2.0 # And the SVG transform is thus - t = 'translate({:f},{:f}) scale({:f},{:f})'.format(translate_x, translate_y, scale_x, scale_y) + t = 'translate({0:f},{1:f}) scale({2:f},{3:f})'.format(translate_x, translate_y, scale_x, scale_y) # For scaling line thicknesses. We'll typically draw a line of # thickness 1 but will need to make the SVG path have a thickness @@ -535,16 +535,16 @@ class Maze(inkex.Effect): if self.last_point is not None: if (self.last_point[0] == x1) and (self.last_point[1] == y1): - self.path += ' L {:d},{:d}'.format(x2, y2) + self.path += ' L {0:d},{1:d}'.format(x2, y2) self.last_point = [x2, y2] elif (self.last_point[0] == x2) and (self.last_point[1] == y2): - self.path += ' L {:d},{:d} L {:d},{:d}'.format(x1, y1, x2, y2) + self.path += ' L {0:d},{1:d} L {2:d},{3:d}'.format(x1, y1, x2, y2) # self.last_point unchanged else: - self.path += ' M {:d},{:d} L {:d},{:d}'.format(x1, y1, x2, y2) + self.path += ' M {0:d},{1:d} L {2:d},{3:d}'.format(x1, y1, x2, y2) self.last_point = [x2, y2] else: - self.path = 'M {:d},{:d} L {:d},{:d}'.format(x1, y1, x2, y2) + self.path = 'M {0:d},{1:d} L {2:d},{3:d}'.format(x1, y1, x2, y2) self.last_point = [x2, y2] def draw_wall(self, x, y, d, dir_): @@ -650,7 +650,7 @@ class Maze(inkex.Effect): tracing = False segment = y_start for y in range(y_start, y_finis, dy): - assert 0 <= y < self.h, "y ({:d}) is out of range".format(y) + assert 0 <= y < self.h, "y ({0:d}) is out of range".format(y) if self.is_wall(x, y, wall): if not tracing: # Starting a new segment diff --git a/inkscape_contributed/eggbot_pptb.py b/inkscape_contributed/eggbot_pptb.py index c41c059..320bab8 100755 --- a/inkscape_contributed/eggbot_pptb.py +++ b/inkscape_contributed/eggbot_pptb.py @@ -84,7 +84,7 @@ class EggBot_PostProcessTraceBitmap(inkex.Effect): # Add Inkscape layer attributes to this new group count += 1 layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') - layer.set(inkex.addNS('label', 'inkscape'), '{:d} - {}'.format(count, color)) + layer.set(inkex.addNS('label', 'inkscape'), '{0:d} - {1}'.format(count, color)) # Now move this path from where it was to being a child # of this new group/layer we just made diff --git a/inkscape_contributed/eggbot_sineandlace.py b/inkscape_contributed/eggbot_sineandlace.py index 7fa45f9..c2653a2 100755 --- a/inkscape_contributed/eggbot_sineandlace.py +++ b/inkscape_contributed/eggbot_sineandlace.py @@ -176,7 +176,7 @@ def drawSine(cycles=8, rn=0, rm=0, nPoints=50, offset=None, dYs = lambda s: -y_scale * cos(x_min + (x_max - x_min) * s) * (x_max - x_min) dYdXs = lambda s: dYs(s) / dXs(s) else: - inkex.errormsg('Unknown function {} specified'.format(fun)) + inkex.errormsg('Unknown function {0} specified'.format(fun)) return # Derivatives: remember the chain rule.... @@ -243,9 +243,9 @@ def drawSine(cycles=8, rn=0, rm=0, nPoints=50, offset=None, dy1 = dy2 path_desc = \ - 'version:{:d};style:linear;function:sin(x);'.format(VERSION) + \ - 'cycles:{:f};rn:{:d};rm:{:d};points:{:d};'.format(cycles, rn, rm, nPoints) + \ - 'width:{:d};height:{:d};x:{:d};y:{:d}'.format(width, height, offset[0], offset[1]) + 'version:{0:d};style:linear;function:sin(x);'.format(VERSION) + \ + 'cycles:{0:f};rn:{1:d};rm:{2:d};points:{3:d};'.format(cycles, rn, rm, nPoints) + \ + 'width:{0:d};height:{1:d};x:{2:d};y:{3:d}'.format(width, height, offset[0], offset[1]) return path_data, path_desc diff --git a/inkscape_contributed/eggbot_spiraltext.py b/inkscape_contributed/eggbot_spiraltext.py index 818d96f..a95e7bc 100755 --- a/inkscape_contributed/eggbot_spiraltext.py +++ b/inkscape_contributed/eggbot_spiraltext.py @@ -261,7 +261,7 @@ def processMarkup(text, family='sans'): outstr += entity_refs[eref] i = j + 1 else: - inkex.errormsg('Ignoring the unrecognized entity reference {}.'.format(eref)) + inkex.errormsg('Ignoring the unrecognized entity reference {0}.'.format(eref)) outstr += eref i = j + 1 else: @@ -285,12 +285,12 @@ def processMarkup(text, family='sans'): # We'll pop the most recent tag from the queue of opened tags and see if # it matches if len(tags_used) == 0: - inkex.errormsg('The ending tag appeared before any start tag <{}>.'.format(tag, tag)) + inkex.errormsg('The ending tag appeared before any start tag <{1}>.'.format(tag, tag)) break else: old_tag = tags_used.pop() if old_tag != tag: - inkex.errormsg('The ending tag does not appear to be correctly nested; it tried to close the tag <{}>. Sorry, but all tags must be properly nested.'.format(tag, old_tag)) + inkex.errormsg('The ending tag does not appear to be correctly nested; it tried to close the tag <{1}>. Sorry, but all tags must be properly nested.'.format(tag, old_tag)) break else: # Start tag (opening tag) @@ -337,9 +337,9 @@ def processMarkup(text, family='sans'): tag = normalize_possible_EMS_string(tag) if (tag not in generic_families) and (tag not in map_our_names_to_hersheydata) and (not b_valid_ems_name): if close: - inkex.errormsg('Ignoring the unrecognized tag .'.format(tag)) + inkex.errormsg('Ignoring the unrecognized tag .'.format(tag)) else: - inkex.errormsg('Ignoring the unrecognized tag <{}>.'.format(tag)) + inkex.errormsg('Ignoring the unrecognized tag <{0}>.'.format(tag)) else: if outstr != '': markup.append([face, outstr]) @@ -435,10 +435,10 @@ class SpiralText(inkex.Effect): if self.options.flip: angle += 180.0 - t = 'translate({:f},{:f}) rotate({:f},{:f},0) scale({:f},{:f})'.format(-w * scale_x, h * scale_y, angle, + t = 'translate({0:f},{1:f}) rotate({2:f},{3:f},0) scale({4:f},{5:f})'.format(-w * scale_x, h * scale_y, angle, w * scale_x, scale_x, scale_y) else: - t = 'translate(0,{:f}) rotate({:f},0,0) scale({:f},{:f})'.format(h, angle, scale_x, scale_y) + t = 'translate(0,{0:f}) rotate({1:f},0,0) scale({2:f},{3:f})'.format(h, angle, scale_x, scale_y) g.set('transform', t)