diff --git a/extensions/fablabchemnitz/box_maker_elliptical_box/box_maker_elliptical_box.py b/extensions/fablabchemnitz/box_maker_elliptical_box/box_maker_elliptical_box.py index a264b4a..00f4fda 100644 --- a/extensions/fablabchemnitz/box_maker_elliptical_box/box_maker_elliptical_box.py +++ b/extensions/fablabchemnitz/box_maker_elliptical_box/box_maker_elliptical_box.py @@ -4,10 +4,8 @@ from inkscape_helper.Coordinate import Coordinate import inkscape_helper.Effect as eff import inkscape_helper.SVG as svg from inkscape_helper.Ellipse import Ellipse - from inkscape_helper.Line import Line from inkscape_helper.EllipticArc import EllipticArc - from math import * import inkex diff --git a/extensions/fablabchemnitz/box_maker_elliptical_box/inkscape_helper/SVG.py b/extensions/fablabchemnitz/box_maker_elliptical_box/inkscape_helper/SVG.py index e3a300f..afb054e 100644 --- a/extensions/fablabchemnitz/box_maker_elliptical_box/inkscape_helper/SVG.py +++ b/extensions/fablabchemnitz/box_maker_elliptical_box/inkscape_helper/SVG.py @@ -1,5 +1,4 @@ import inkex -import simplestyle from lxml import etree def _format_1st(command, is_absolute): diff --git a/extensions/fablabchemnitz/box_maker_generic_generator/th_inkscape_path.py b/extensions/fablabchemnitz/box_maker_generic_generator/th_inkscape_path.py index 135ab58..b42a147 100644 --- a/extensions/fablabchemnitz/box_maker_generic_generator/th_inkscape_path.py +++ b/extensions/fablabchemnitz/box_maker_generic_generator/th_inkscape_path.py @@ -2,9 +2,6 @@ # We will use the inkex module with the predefined Effect base class. import inkex -# The simplestyle module provides functions for style parsing. - -import simplestyle import math from lxml import etree diff --git a/extensions/fablabchemnitz/box_maker_tabbed/box_maker_tabbed.py b/extensions/fablabchemnitz/box_maker_tabbed/box_maker_tabbed.py index 5108d37..b5bd57d 100644 --- a/extensions/fablabchemnitz/box_maker_tabbed/box_maker_tabbed.py +++ b/extensions/fablabchemnitz/box_maker_tabbed/box_maker_tabbed.py @@ -60,7 +60,11 @@ along with this program. If not, see . ''' __version__ = "1.0" ### please report bugs, suggestions etc at https://github.com/paulh-rnd/TabbedBoxMaker ### -import os,sys,inkex,simplestyle,gettext,math +import os +import sys +import inkex +import gettext +import math from copy import deepcopy _ = gettext.gettext @@ -91,18 +95,6 @@ def getCircle(r, c): log("putting circle at (%d,%d)" % (cx,cy)) circle = inkex.PathElement.arc((cx, cy), r) circle.style = { 'stroke': '#000000', 'stroke-width': str(linethickness), 'fill': 'none' } - - # ell_attribs = {'style':simplestyle.formatStyle(style), - # inkex.addNS('cx','sodipodi') :str(cx), - # inkex.addNS('cy','sodipodi') :str(cy), - # inkex.addNS('rx','sodipodi') :str(r), - # inkex.addNS('ry','sodipodi') :str(r), - # inkex.addNS('start','sodipodi') :str(0), - # inkex.addNS('end','sodipodi') :str(2*math.pi), - # inkex.addNS('open','sodipodi') :'true', #all ellipse sectors we will draw are open - # inkex.addNS('type','sodipodi') :'arc', - # 'transform' :'' } - #inkex.etree.SubElement(parent, inkex.addNS('path','svg'), ell_attribs ) return circle def dimpleStr(tabVector,vectorX,vectorY,dirX,dirY,dirxN,diryN,ddir,isTab): diff --git a/extensions/fablabchemnitz/boxes.py/meta.json b/extensions/fablabchemnitz/boxes.py/meta.json new file mode 100644 index 0000000..4df469e --- /dev/null +++ b/extensions/fablabchemnitz/boxes.py/meta.json @@ -0,0 +1,20 @@ +[ + { + "name": "", + "id": "info.festi.boxes.py.", + "path": "boxes.py", + "dependent_extensions": null, + "original_name": "", + "original_id": "info.festi.boxes.py.", + "license": "GNU GPL v3", + "license_url": "https://github.com/florianfesti/boxes/blob/master/LICENSE.txt", + "comment": "", + "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/boxes.py", + "fork_url": "https://github.com/florianfesti/boxes", + "documentation_url": "https://stadtfabrikanten.org/display/IFM/Boxes.py", + "inkscape_gallery_url": null, + "main_authors": [ + "github.com/eridur-de" + ] + } +] diff --git a/extensions/fablabchemnitz/destructive_clip/destructive_clip.py b/extensions/fablabchemnitz/destructive_clip/destructive_clip.py index 554e996..4ffd559 100644 --- a/extensions/fablabchemnitz/destructive_clip/destructive_clip.py +++ b/extensions/fablabchemnitz/destructive_clip/destructive_clip.py @@ -27,7 +27,6 @@ import inkex import sys from inkex.paths import Path - class DestructiveClip(inkex.EffectExtension): def __init__(self): diff --git a/extensions/fablabchemnitz/exponential_distort/exponential_distort.py b/extensions/fablabchemnitz/exponential_distort/exponential_distort.py index 6272423..1de9b7e 100644 --- a/extensions/fablabchemnitz/exponential_distort/exponential_distort.py +++ b/extensions/fablabchemnitz/exponential_distort/exponential_distort.py @@ -62,7 +62,6 @@ class ExponentialDistort(inkex.EffectExtension): return x def computeBBox(self, pts): - """ 'improved' version of simplepath.computeBBox, this one includes b-spline handles.""" xmin = None xmax = None ymin = None diff --git a/extensions/fablabchemnitz/mutual_cut_line/mutual_cut_line.py b/extensions/fablabchemnitz/mutual_cut_line/mutual_cut_line.py index faba348..e5d8640 100644 --- a/extensions/fablabchemnitz/mutual_cut_line/mutual_cut_line.py +++ b/extensions/fablabchemnitz/mutual_cut_line/mutual_cut_line.py @@ -7,7 +7,6 @@ Only the first segment of a multi-segment line will be used. ''' import inkex from inkex.paths import Path -import simplepath from math import * from lxml import etree diff --git a/extensions/fablabchemnitz/optimize_sequence_travel_distance/optimize_sequence_travel_distance.py b/extensions/fablabchemnitz/optimize_sequence_travel_distance/optimize_sequence_travel_distance.py index 422417d..a047d9d 100644 --- a/extensions/fablabchemnitz/optimize_sequence_travel_distance/optimize_sequence_travel_distance.py +++ b/extensions/fablabchemnitz/optimize_sequence_travel_distance/optimize_sequence_travel_distance.py @@ -36,7 +36,6 @@ import sys from lxml import etree import inkex import simpletransform -import simplestyle import plot_utils """ diff --git a/extensions/fablabchemnitz/optimize_sequence_travel_distance/simpletransform.py b/extensions/fablabchemnitz/optimize_sequence_travel_distance/simpletransform.py index e615fc1..26de69c 100644 --- a/extensions/fablabchemnitz/optimize_sequence_travel_distance/simpletransform.py +++ b/extensions/fablabchemnitz/optimize_sequence_travel_distance/simpletransform.py @@ -20,8 +20,12 @@ barraud@math.univ-lille1.fr This code defines several functions to make handling of transform attribute easier. ''' -import inkex, cubicsuperpath, bezmisc, simplestyle -import copy, math, re +import inkex +import cubicsuperpath +import bezmisc +import copy +import math +import re def parseTransform(transf,mat=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]): if transf=="" or transf==None: diff --git a/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Path.py b/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Path.py index 18d29a0..8eeb2dd 100755 --- a/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Path.py +++ b/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Path.py @@ -5,28 +5,9 @@ Defines a path and what it is supposed to be (mountain, valley, edge) """ -import inkex # Required -import simplestyle # will be needed here for styles support - -# compatibility hack -try: - from lxml import etree - inkex.etree = etree -except: - pass - +import inkex from math import sin, cos, pi, sqrt - -# compatibility hack for formatStyle -def format_style(style): - try: - return str(inkex.Style(style)) # new - except: - return simplestyle.formatStyle(style) # old -# def format_style(style): - # return simplestyle.formatStyle(style) - - +from lxml import etree class Path: """ Class that defines an svg stroke to be drawn in Inkscape @@ -166,7 +147,7 @@ class Path: - Draws strokes defined on "path_tree" to "group" - Inputs: -- path_tree [nested list] of Path instances - -- group [inkex.etree.SubElement] + -- group [etree.SubElement] -- styles_dict [dict] containing all styles for path_tree """ @staticmethod @@ -178,7 +159,7 @@ class Path: if len(subpath) == 1: subgroup = group else: - subgroup = inkex.etree.SubElement(group, 'g') + subgroup = etree.SubElement(group, 'g') Path.draw_paths_recursively(subpath, subgroup, styles_dict) else: # ~ if subpath.style != 'n': @@ -192,16 +173,16 @@ class Path: if subpath.closed: path = path + 'L{},{} Z'.format(*points[0]) - attribs = {'style': format_style(styles_dict[subpath.style]), + attribs = {'style': str(inkex.Style(styles_dict[subpath.style])), 'd': path, 'opacity': str(subpath.fold_angle/180)} - inkex.etree.SubElement(group, inkex.addNS('path', 'svg'), attribs) + etree.SubElement(group, inkex.addNS('path', 'svg'), attribs) else: - attribs = {'style': format_style(styles_dict[subpath.style]), + attribs = {'style': str(inkex.Style(styles_dict[subpath.style])), 'cx': str(subpath.points[0][0]), 'cy': str(subpath.points[0][1]), 'r': str(subpath.radius), 'opacity': str(subpath.fold_angle/180)} - inkex.etree.SubElement(group, inkex.addNS('circle', 'svg'), attribs) + etree.SubElement(group, inkex.addNS('circle', 'svg'), attribs) @classmethod def get_average_point(cls, paths): diff --git a/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Pattern.py b/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Pattern.py index fafdffc..49df32a 100755 --- a/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Pattern.py +++ b/extensions/fablabchemnitz/origami_patterns/OrigamiPatterns/Pattern.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # -*- coding: utf-8 -*- """ Helper functions @@ -6,10 +6,11 @@ Helper functions """ import os from abc import abstractmethod +from Path import Path +import inkex +from lxml import etree -from Path import Path, inkex, simplestyle - -class Pattern(inkex.Effect): +class Pattern(inkex.EffectExtension): """ Class that inherits inkex.Effect and further specializes it for different Patterns generation @@ -21,7 +22,7 @@ class Pattern(inkex.Effect): 'v' : valley_style, 'e' : edge_style} - topgroup: inkex.etree.SubElement + topgroup: etree.SubElement Top Inkscape group element path_tree: nested list @@ -89,13 +90,6 @@ class Pattern(inkex.Effect): self.float = "float" self.bool = "inkbool" - # Two ways to get debug info: - # OR just use inkex.debug(string) instead... - try: - self.tty = open("/dev/tty", 'w') - except: - self.tty = open(os.devnull, 'w') # '/dev/null' for POSIX, 'nul' for Windows. - self.add_argument('-u', '--units', type=self.str, default='mm') # bypass most style options for OrigamiSimulator @@ -225,7 +219,7 @@ class Pattern(inkex.Effect): # add the group to the document's current layer if type(self.path_tree) == list and len(self.path_tree) != 1: - self.topgroup = inkex.etree.SubElement(self.get_layer(), 'g', g_attribs) + self.topgroup = etree.SubElement(self.get_layer(), 'g', g_attribs) else: self.topgroup = self.get_layer() @@ -242,12 +236,7 @@ class Pattern(inkex.Effect): # compatibility hack, "affect()" is replaced by "run()" def draw(self): - try: - self.run() # new - except: - self.affect() # old - # close(self.tty) - self.tty.close() + self.run() # new # compatibility hack def get_layer(self): @@ -346,11 +335,11 @@ class Pattern(inkex.Effect): 'fill': '#F6921E', 'font-family': 'Bitstream Vera Sans,sans-serif', 'text-anchor': 'middle', 'text-align': 'center'} line_attribs = {inkex.addNS('label','inkscape'): 'Annotation', - 'style': simplestyle.formatStyle(line_style), + 'style': inkex.Style(line_style), 'x': str(position[0]), 'y': str((position[1] + text_height) * 1.2) } - line = inkex.etree.SubElement(node, inkex.addNS('text','svg'), line_attribs) + line = etree.SubElement(node, inkex.addNS('text','svg'), line_attribs) line.text = text @@ -370,9 +359,3 @@ class Pattern(inkex.Effect): return inkex.unittouu(str(1.0) + self.options.units) except AttributeError: return self.unittouu(str(1.0) + self.options.units) - - - - - - diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu.inx index 664e149..99c7a4c 100644 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu.inx @@ -58,8 +58,8 @@ all - - + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu_traditional.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu_traditional.inx index 28db195..d07caeb 100644 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu_traditional.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_boxes_masu_traditional.inx @@ -54,8 +54,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_bendy.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_bendy.inx index 73b7231..8061a13 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_bendy.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_bendy.inx @@ -10,13 +10,13 @@ - + 6 3 - + 25.0 0.75 - + @@ -37,13 +37,13 @@ false - + 5.0 false false 3.0 3.0 - + 3.0 false 3.0 @@ -100,8 +100,8 @@ all - - + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_kresling.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_kresling.inx index 26a983f..99e1a7b 100644 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_kresling.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_kresling.inx @@ -8,10 +8,10 @@ - + 3 6 - + 10.0 @@ -30,7 +30,7 @@ true - + @@ -42,7 +42,7 @@ false - + false @@ -52,7 +52,7 @@ 5.0 3.0 3.0 - + false @@ -111,8 +111,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_template.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_template.inx index 31c06e8..ffd7ade 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_template.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_cylindrical_template.inx @@ -1,15 +1,15 @@ - * Cylindrical template effect + Cylindrical template effect org.inkscape.Origami_patterns.cylindrical_template - + 10.0 6 3 - + 10.0 0 @@ -24,7 +24,7 @@ false - + false @@ -34,7 +34,7 @@ 5.0 3.0 3.0 - + false @@ -84,8 +84,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_misc_support_ring.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_misc_support_ring.inx index 854d460..016c5c0 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_misc_support_ring.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_misc_support_ring.inx @@ -1,6 +1,6 @@ - * Support ring + Support ring org.inkscape.Origami_patterns.support_ring @@ -8,19 +8,19 @@ 10.0 false true - + 3.0 3.0 1.0 1.0 - + true 0.5 - + @@ -42,8 +42,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_bendy.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_bendy.inx index d6ace9e..3eea079 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_bendy.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_bendy.inx @@ -10,13 +10,13 @@ - + 6 3 - + 25.0 0.75 - + @@ -37,13 +37,13 @@ false - + 5.0 false false 3.0 3.0 - + 3.0 false 3.0 @@ -96,8 +96,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_kresling.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_kresling.inx index 9ecaa07..88937f3 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_kresling.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_old_kresling.inx @@ -8,10 +8,10 @@ - + 3 6 - + 10.0 @@ -29,7 +29,7 @@ - + @@ -43,7 +43,7 @@ false 100 - + true @@ -84,8 +84,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_circular.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_circular.inx index 196882f..15ddc74 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_circular.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_circular.inx @@ -14,7 +14,7 @@ 0.4 15 - + true 20 @@ -67,8 +67,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_hypar.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_hypar.inx index 250d605..76bffea 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_hypar.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_pleat_hypar.inx @@ -71,8 +71,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_template.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_template.inx index 1c2b0c2..2dd6d8b 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_template.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_template.inx @@ -61,8 +61,10 @@ all - - + + + + diff --git a/extensions/fablabchemnitz/origami_patterns/origami_patterns_waterbomb.inx b/extensions/fablabchemnitz/origami_patterns/origami_patterns_waterbomb.inx index 46f5337..7a28678 100755 --- a/extensions/fablabchemnitz/origami_patterns/origami_patterns_waterbomb.inx +++ b/extensions/fablabchemnitz/origami_patterns/origami_patterns_waterbomb.inx @@ -13,10 +13,10 @@ false - + 8 16 - + 10.0 @@ -68,7 +68,9 @@ The Magic ball is a different design that inverts both the upper half of the fir all - + + + - \ No newline at end of file diff --git a/extensions/fablabchemnitz/stroke_font_creator/gen_stroke_font_data.py b/extensions/fablabchemnitz/stroke_font_creator/gen_stroke_font_data.py index 1fbaf0a..73d2c3d 100644 --- a/extensions/fablabchemnitz/stroke_font_creator/gen_stroke_font_data.py +++ b/extensions/fablabchemnitz/stroke_font_creator/gen_stroke_font_data.py @@ -68,28 +68,6 @@ def transformedParsedPath(elem): pp = getParsedPath(elem.get('d')) return pp - # Following bloc takes care of the special condition where guides are transformed - # TODO: Make it working for 1.0 - - # ~ try: - # ~ transf = elem.get('transform') - # ~ mat = parseTransform(transf) - - # ~ #pp format [['M',[x1,y1]],['L',[x2,y2]]] - # ~ for dElem in pp: - # ~ for i in range(1, len(dElem)): - # ~ param = dElem[i] - # ~ t1 = [[param[x], param[x+1]] for x in range(0, len(param), 2)] - # ~ for t1Elem in t1: - # ~ simpletransform.applyTransformToPoint(mat, t1Elem) - # ~ dElem[i] = [x for l in t1 for x in l] - # ~ elem.set('d', simplepath.formatPath(pp)) - # ~ except: - # ~ #Don't break - # ~ pass - - # ~ return pp - def updateFontData(strokeFontData, glyphPathElems, hGuides, lvGuides, rvGuides, rightOffsetType): for elem in glyphPathElems: char = elem.get(CommonDefs.idAttribName) diff --git a/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx b/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx index 8940d0d..f1568fd 100644 --- a/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx +++ b/extensions/fablabchemnitz/stroke_font_creator/render_stroke_font_text.inx @@ -38,60 +38,3 @@ - - - 20 - 1 - 1 - 1.5 - true - 5 - - - - - - - - - - - - - - - - - - 1 - - - - - - - all - - - - - - - - \ No newline at end of file diff --git a/extensions/fablabchemnitz/stroke_font_creator/stroke_font_common.py b/extensions/fablabchemnitz/stroke_font_creator/stroke_font_common.py index 9cd251f..a8d2b84 100644 --- a/extensions/fablabchemnitz/stroke_font_creator/stroke_font_common.py +++ b/extensions/fablabchemnitz/stroke_font_creator/stroke_font_common.py @@ -24,33 +24,16 @@ import sys, os, fileinput, re, locale from inkex import errormsg, addNS, NSS from xml.dom.minidom import parse, Document from math import ceil - -# TODO: Find inkscape version -try: - from lxml import etree - from inkex import Style, Boolean - from inkex.paths import Path, CubicSuperPath, Transform - from inkex import bezier - ver = 1.0 -except: - from inkex import etree - import simplestyle, cubicsuperpath, simplepath, simpletransform - from cubicsuperpath import CubicSuperPath - ver = 0.92 - try: - from simpletransform import computePointInNode - oldVersion = False - except: - oldVersion = True # older than 0.92 +from lxml import etree +from inkex import Style, Boolean +from inkex.paths import Path, CubicSuperPath, Transform +from inkex import bezier # sys path already includes the module folder from stroke_font_manager import CharData, getFontNames, xAscent, \ xDescent, xCapHeight, xXHeight, xSpaceROff, xFontId, xSize class CommonDefs: - inkVer = ver - pyVer = sys.version_info.major - # inx filed that have the font list to be synchronized inxFilesWithDynFont = ['render_stroke_font_text.inx', 'edit_stroke_font.inx'] @@ -68,10 +51,6 @@ class CommonDefs: if(encoding == 'cp0' or encoding is None): encoding = locale.getpreferredencoding() - -######### Function variants for 1.0 and 0.92 - Start ########## - -# Used only in 0.92 def getPartsFromCubicSuper(csp): parts = [] for subpath in csp: @@ -86,131 +65,70 @@ def getPartsFromCubicSuper(csp): return parts def formatStyle(styleStr): - if(CommonDefs.inkVer == 1.0): - return str(Style(styleStr)) - else: - return simplestyle.formatStyle(styleStr) + return str(Style(styleStr)) + def getCubicSuperPath(d = None): - if(CommonDefs.inkVer == 1.0): - if(d == None): return CubicSuperPath([]) - return CubicSuperPath(Path(d).to_superpath()) - else: - if(d == None): return [] - return CubicSuperPath(simplepath.parsePath(d)) - + if(d == None): return CubicSuperPath([]) + return CubicSuperPath(Path(d).to_superpath()) def getCubicLength(csp): - if(CommonDefs.inkVer == 1.0): - return bezier.csplength(csp)[1] - else: - parts = getPartsFromCubicSuper(cspath) - curveLen = 0 - for i, part in enumerate(parts): - for j, seg in enumerate(part): - curveLen += bezmisc.bezierlengthSimpson((seg[0], seg[1], seg[2], seg[3]), \ - tolerance = tolerance) - return curveLen + return bezier.csplength(csp)[1] + def getCubicBoundingBox(csp): - if(CommonDefs.inkVer == 1.0): - bbox = csp.to_path().bounding_box() - return bbox.left, bbox.right, bbox.top, bbox.bottom - else: - return simpletransform.refinedBBox(csp) + bbox = csp.to_path().bounding_box() + return bbox.left, bbox.right, bbox.top, bbox.bottom def formatSuperPath(csp): - if(CommonDefs.inkVer == 1.0): - return csp.__str__() - else: - return cubicsuperpath.formatPath(csp) + return csp.__str__() + def getParsedPath(d): - if(CommonDefs.inkVer == 1.0): - # Copied from Path.to_arrays for compatibility - return [[seg.letter, list(seg.args)] for seg in Path(d).to_absolute()] - else: - return simplepath.parsePath(d) + return [[seg.letter, list(seg.args)] for seg in Path(d).to_absolute()] def applyTransform(mat, csp): - if(CommonDefs.inkVer == 1.0): - csp.transform(mat) - else: - simpletransform.applyTransformToPath(mat, csp) + csp.transform(mat) + def getTranslatedPath(d, posX, posY): - if(CommonDefs.inkVer == 1.0): - path = Path(d) - path.translate(posX, posY, inplace = True) - return path.to_superpath().__str__() - else: - path = simplepath.parsePath(d) - simplepath.translatePath(path, posX, posY) - return simplepath.formatPath(path) + path = Path(d) + path.translate(posX, posY, inplace = True) + return path.to_superpath().__str__() def getTransformMat(matAttr): - if(CommonDefs.inkVer == 1.0): - return Transform(matAttr) - else: - return simpletransform.parseTransform(matAttr) + return Transform(matAttr) def getCurrentLayer(effect): - if(CommonDefs.inkVer == 1.0): - return effect.svg.get_current_layer() - else: - return effect.current_layer + return effect.svg.get_current_layer() + def getViewCenter(effect): - if(CommonDefs.inkVer == 1.0): - return effect.svg.namedview.center - else: - return effect.view_center + return effect.svg.namedview.center def computePtInNode(vc, layer): - if(CommonDefs.inkVer == 1.0): - # ~ return (-Transform(layer.transform * mat)).apply_to_point(vc) - return (-layer.transform).apply_to_point(vc) - else: - if(oldVersion): - return list(vc) - else: - return computePointInNode(list(vc), layer) + return (-layer.transform).apply_to_point(vc) def getSelectedElements(effect): - if(CommonDefs.inkVer == 1.0): - return effect.svg.selected - else: - return effect.selected + return effect.svg.selected + def getEtree(): return etree def getAddFnTypes(effect): - if(CommonDefs.inkVer == 1.0): - addFn = effect.arg_parser.add_argument - typeFloat = float - typeInt = int - typeString = str - typeBool = Boolean - else: - addFn = effect.OptionParser.add_option - typeFloat = 'float' - typeInt = 'int' - typeString = 'string' - typeBool = 'inkbool' + addFn = effect.arg_parser.add_argument + typeFloat = float + typeInt = int + typeString = str + typeBool = Boolean return addFn, typeFloat, typeInt, typeString, typeBool def runEffect(effect): - if(CommonDefs.inkVer == 1.0): effect.run() - else: effect.affect() + effect.run() -######### Function variants for 1.0 and 0.92 - End ########## - def getDecodedChars(chars): - if(CommonDefs.pyVer == 2): - return chars.decode(CommonDefs.encoding) - else: #if? - return chars + return chars def indentStr(cnt): ostr = '' @@ -238,21 +156,14 @@ def syncFontList(extPath): for line in fileinput.input(xf, inplace = True): if sectMarker in line: if(sectMarkerLine != None): - if(CommonDefs.pyVer == 3): - # For some reasons python2 giving syntax error without eval - eval("print(getXMLItemsStr(sectMarkerLine, sectMarker, fontNames), end = '')") - else: - print(getXMLItemsStr(sectMarkerLine, sectMarker, fontNames)), + eval("print(getXMLItemsStr(sectMarkerLine, sectMarker, fontNames), end = '')") sectMarkerLine = None else: sectMarkerLine = line else: if(sectMarkerLine == None): - if(CommonDefs.pyVer == 3): - eval("print(line, end = '')") - else: - print(line), + eval("print(line, end = '')") except Exception as e: errormsg('Error updating font list...\n' + str(e)) @@ -316,16 +227,14 @@ def createTempl(callback, effect, extraInfo, rowCnt, glyphCnt, \ currLayers = svg.xpath('//svg:g', namespaces = NSS) for layer in currLayers: # Note: getparent() - parentLayer = layer.getparent() if(CommonDefs.inkVer == 1.0) \ - else effect.getParentNode(layer) + parentLayer = layer.getparent() if(parentLayer != None): parentLayer.remove(layer) currExtraElems = svg.xpath('//svg:' + CommonDefs.fontOtherInfo, namespaces = NSS) for elem in currExtraElems: - parentElem = elem.getparent() if(CommonDefs.inkVer == 1.0) \ - else effect.getParentNode(elem) + parentElem = elem.getparent() parentElem.remove(elem) extraInfoElem = etree.SubElement(svg, CommonDefs.fontOtherInfo) @@ -352,7 +261,7 @@ def createTempl(callback, effect, extraInfo, rowCnt, glyphCnt, \ editLayer.set(addNS('label', 'inkscape'), 'Glyphs') editLayer.set(addNS('groupmode', 'inkscape'), 'layer') editLayer.set('id', 'glyph')#TODO: How to make this dynamic? - view = svg.namedview if CommonDefs.inkVer == 1.0 else effect.getNamedView() + view = svg.namedview view.set(addNS('current-layer', 'inkscape'), editLayer.get('id')) for row in range(0, rowCnt): diff --git a/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/prepare.py b/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/prepare.py index 10d3d2b..34b3250 100644 --- a/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/prepare.py +++ b/extensions/fablabchemnitz/svg2shenzhen/svg2shenzhen/prepare.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 import warnings import sys @@ -9,8 +9,6 @@ import subprocess import tempfile import shutil import copy - -from simplestyle import * from copy import deepcopy from io import BytesIO from lxml import etree