try a python script in runner
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
# coding=utf-8This directory contains compatibility layers for all the `simple` modules, such as `simplepath` and `simplestyle`
|
||||
|
||||
This directory IS NOT a module path, to denote this we are using a dash in the name and there is no '__init__.py'
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# coding=utf-8
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# pylint: disable=invalid-name,unused-argument
|
||||
"""Deprecated bezmisc API"""
|
||||
|
||||
from inkex.deprecated import deprecate
|
||||
from inkex import bezier
|
||||
|
||||
bezierparameterize = deprecate(bezier.bezierparameterize)
|
||||
linebezierintersect = deprecate(bezier.linebezierintersect)
|
||||
bezierpointatt = deprecate(bezier.bezierpointatt)
|
||||
bezierslopeatt = deprecate(bezier.bezierslopeatt)
|
||||
beziertatslope = deprecate(bezier.beziertatslope)
|
||||
tpoint = deprecate(bezier.tpoint)
|
||||
beziersplitatt = deprecate(bezier.beziersplitatt)
|
||||
pointdistance = deprecate(bezier.pointdistance)
|
||||
Gravesen_addifclose = deprecate(bezier.addifclose)
|
||||
balf = deprecate(bezier.balf)
|
||||
bezierlengthSimpson = deprecate(bezier.bezierlength)
|
||||
beziertatlength = deprecate(bezier.beziertatlength)
|
||||
bezierlength = bezierlengthSimpson
|
||||
|
||||
|
||||
@deprecate
|
||||
def Simpson(func, a, b, n_limit, tolerance):
|
||||
"""bezier.simpson(a, b, n_limit, tolerance, balf_arguments)"""
|
||||
raise AttributeError(
|
||||
"""Because bezmisc.Simpson used global variables, it's not possible to
|
||||
call the replacement code automatically. In fact it's unlikely you were
|
||||
using the code or functionality you think you were since it's a highly
|
||||
broken way of writing python."""
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
# coding=utf-8
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# pylint: disable=invalid-name
|
||||
"""Deprecated cspsubdiv API"""
|
||||
|
||||
from inkex.deprecated import deprecate
|
||||
from inkex import bezier
|
||||
|
||||
maxdist = deprecate(bezier.maxdist)
|
||||
cspsubdiv = deprecate(bezier.cspsubdiv)
|
||||
subdiv = deprecate(bezier.subdiv)
|
||||
@@ -1,52 +0,0 @@
|
||||
# coding=utf-8
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# pylint: disable=invalid-name
|
||||
"""Deprecated cubic super path API"""
|
||||
|
||||
from inkex.deprecated import deprecate
|
||||
from inkex import paths
|
||||
|
||||
|
||||
@deprecate
|
||||
def ArcToPath(p1, params):
|
||||
return paths.arc_to_path(p1, params)
|
||||
|
||||
|
||||
@deprecate
|
||||
def CubicSuperPath(simplepath):
|
||||
return paths.Path(simplepath).to_superpath()
|
||||
|
||||
|
||||
@deprecate
|
||||
def unCubicSuperPath(csp):
|
||||
return paths.CubicSuperPath(csp).to_path().to_arrays()
|
||||
|
||||
|
||||
@deprecate
|
||||
def parsePath(d):
|
||||
return paths.CubicSuperPath(paths.Path(d))
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatPath(p):
|
||||
return str(paths.Path(unCubicSuperPath(p)))
|
||||
|
||||
|
||||
matprod = deprecate(paths.matprod)
|
||||
rotmat = deprecate(paths.rotmat)
|
||||
applymat = deprecate(paths.applymat)
|
||||
norm = deprecate(paths.norm)
|
||||
@@ -1,92 +0,0 @@
|
||||
# coding=utf-8
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# pylint: disable=invalid-name,missing-docstring
|
||||
"""Deprecated ffgeom API"""
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
from inkex.deprecated import deprecate
|
||||
from inkex.transforms import DirectedLineSegment as NewSeg
|
||||
|
||||
try:
|
||||
NaN = float("NaN")
|
||||
except ValueError:
|
||||
PosInf = 1e300000
|
||||
NaN = PosInf / PosInf
|
||||
|
||||
|
||||
class Point(namedtuple("Point", "x y")):
|
||||
__slots__ = ()
|
||||
|
||||
def __getitem__(self, key):
|
||||
if isinstance(key, str):
|
||||
key = "xy".index(key)
|
||||
return super(Point, self).__getitem__(key)
|
||||
|
||||
|
||||
class Segment(NewSeg):
|
||||
@deprecate
|
||||
def __init__(self, e0, e1):
|
||||
"""inkex.transforms.DirectedLineSegment((x1, y1), (x2, y2))"""
|
||||
if isinstance(e0, dict):
|
||||
e0 = (e0["x"], e0["y"])
|
||||
if isinstance(e1, dict):
|
||||
e1 = (e1["x"], e1["y"])
|
||||
super(Segment, self).__init__(e0, e1)
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key:
|
||||
return {"x": self.x.maximum, "y": self.y.maximum}
|
||||
return {"x": self.x.minimum, "y": self.y.minimum}
|
||||
|
||||
delta_x = lambda self: self.width
|
||||
delta_y = lambda self: self.height
|
||||
run = delta_x
|
||||
rise = delta_y
|
||||
|
||||
def distanceToPoint(self, p):
|
||||
return self.distance_to_point(p["x"], p["y"])
|
||||
|
||||
def perpDistanceToPoint(self, p):
|
||||
return self.perp_distance(p["x"], p["y"])
|
||||
|
||||
def angle(self):
|
||||
return super(Segment, self).angle
|
||||
|
||||
def length(self):
|
||||
return super(Segment, self).length
|
||||
|
||||
def pointAtLength(self, length):
|
||||
return self.point_at_length(length)
|
||||
|
||||
def pointAtRatio(self, ratio):
|
||||
return self.point_at_ratio(ratio)
|
||||
|
||||
def createParallel(self, p):
|
||||
self.parallel(p["x"], p["y"])
|
||||
|
||||
|
||||
@deprecate
|
||||
def intersectSegments(s1, s2):
|
||||
"""transforms.Segment(s1).intersect(s2)"""
|
||||
return Point(*s1.intersect(s2))
|
||||
|
||||
|
||||
@deprecate
|
||||
def dot(s1, s2):
|
||||
"""transforms.Segment(s1).dot(s2)"""
|
||||
return s1.dot(s2)
|
||||
@@ -1,80 +0,0 @@
|
||||
# coding=utf-8
|
||||
#
|
||||
# Copyright (C) 2008 Stephen Silver
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
#
|
||||
"""
|
||||
Deprecated module for running SVG-generating commands in Inkscape extensions
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from inkex.deprecated import deprecate
|
||||
|
||||
|
||||
def run(command_format, prog_name):
|
||||
"""inkex.commands.call(...)"""
|
||||
svgfile = tempfile.mktemp(".svg")
|
||||
command = command_format % svgfile
|
||||
msg = None
|
||||
# ps2pdf may attempt to write to the current directory, which may not
|
||||
# be writeable, so we switch to the temp directory first.
|
||||
try:
|
||||
os.chdir(tempfile.gettempdir())
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
try:
|
||||
proc = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
|
||||
return_code = proc.wait()
|
||||
out = proc.stdout.read()
|
||||
err = proc.stderr.read()
|
||||
|
||||
if msg is None:
|
||||
if return_code:
|
||||
msg = "{} failed:\n{}\n{}\n".format(prog_name, out, err)
|
||||
elif err:
|
||||
sys.stderr.write(
|
||||
"{} executed but logged the following error:\n{}\n{}\n".format(
|
||||
prog_name, out, err
|
||||
)
|
||||
)
|
||||
except Exception as inst:
|
||||
msg = "Error attempting to run {}: {}".format(prog_name, str(inst))
|
||||
|
||||
# If successful, copy the output file to stdout.
|
||||
if msg is None:
|
||||
if os.name == "nt": # make stdout work in binary on Windows
|
||||
import msvcrt
|
||||
|
||||
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
|
||||
try:
|
||||
with open(svgfile, "rb") as fhl:
|
||||
sys.stdout.write(fhl.read().decode(sys.stdout.encoding))
|
||||
except IOError as inst:
|
||||
msg = "Error reading temporary file: {}".format(str(inst))
|
||||
|
||||
try:
|
||||
# Clean up.
|
||||
os.remove(svgfile)
|
||||
except (IOError, OSError):
|
||||
pass
|
||||
|
||||
# Output error message (if any) and exit.
|
||||
return msg
|
||||
@@ -1,68 +0,0 @@
|
||||
# coding=utf-8
|
||||
# COPYRIGHT
|
||||
#
|
||||
# pylint: disable=invalid-name
|
||||
#
|
||||
"""
|
||||
Depreicated simplepath replacements with documentation
|
||||
"""
|
||||
|
||||
import math
|
||||
from inkex.deprecated import deprecate, DeprecatedDict
|
||||
from inkex.transforms import Transform
|
||||
from inkex.paths import Path
|
||||
|
||||
pathdefs = DeprecatedDict(
|
||||
{
|
||||
"M": ["L", 2, [float, float], ["x", "y"]],
|
||||
"L": ["L", 2, [float, float], ["x", "y"]],
|
||||
"H": ["H", 1, [float], ["x"]],
|
||||
"V": ["V", 1, [float], ["y"]],
|
||||
"C": [
|
||||
"C",
|
||||
6,
|
||||
[float, float, float, float, float, float],
|
||||
["x", "y", "x", "y", "x", "y"],
|
||||
],
|
||||
"S": ["S", 4, [float, float, float, float], ["x", "y", "x", "y"]],
|
||||
"Q": ["Q", 4, [float, float, float, float], ["x", "y", "x", "y"]],
|
||||
"T": ["T", 2, [float, float], ["x", "y"]],
|
||||
"A": [
|
||||
"A",
|
||||
7,
|
||||
[float, float, float, int, int, float, float],
|
||||
["r", "r", "a", 0, "s", "x", "y"],
|
||||
],
|
||||
"Z": ["L", 0, [], []],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@deprecate
|
||||
def parsePath(d):
|
||||
"""element.path.to_arrays()"""
|
||||
return Path(d).to_arrays()
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatPath(a):
|
||||
"""str(element.path) or str(Path(array))"""
|
||||
return str(Path(a))
|
||||
|
||||
|
||||
@deprecate
|
||||
def translatePath(p, x, y):
|
||||
"""Path(array).translate(x, y)"""
|
||||
p[:] = Path(p).translate(x, y).to_arrays()
|
||||
|
||||
|
||||
@deprecate
|
||||
def scalePath(p, x, y):
|
||||
"""Path(array).scale(x, y)"""
|
||||
p[:] = Path(p).scale(x, y).to_arrays()
|
||||
|
||||
|
||||
@deprecate
|
||||
def rotatePath(p, a, cx=0, cy=0):
|
||||
"""Path(array).rotate(angle_degrees, (center_x, center_y))"""
|
||||
p[:] = Path(p).rotate(math.degrees(a), (cx, cy)).to_arrays()
|
||||
@@ -1,55 +0,0 @@
|
||||
# coding=utf-8
|
||||
# COPYRIGHT
|
||||
"""DOCSTRING"""
|
||||
|
||||
import inkex
|
||||
from inkex.colors.spaces.named import _COLORS as svgcolors
|
||||
from inkex.deprecated import deprecate
|
||||
|
||||
|
||||
@deprecate
|
||||
def parseStyle(s):
|
||||
"""dict(inkex.Style.parse_str(s))"""
|
||||
return dict(inkex.Style.parse_str(s))
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatStyle(a):
|
||||
"""str(inkex.Style(a))"""
|
||||
return str(inkex.Style(a))
|
||||
|
||||
|
||||
@deprecate
|
||||
def isColor(c):
|
||||
"""inkex.colors.is_color(c)"""
|
||||
return inkex.colors.is_color(c)
|
||||
|
||||
|
||||
@deprecate
|
||||
def parseColor(c):
|
||||
"""inkex.Color(c).to_rgb()"""
|
||||
return tuple(inkex.Color(c).to_rgb())
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatColoria(a):
|
||||
"""str(inkex.Color(a))"""
|
||||
return str(inkex.ColorRGB(a))
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatColorfa(a):
|
||||
"""str(inkex.Color(a))"""
|
||||
return str(inkex.ColorRGB([b * 255 for b in a]))
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatColor3i(r, g, b):
|
||||
"""str(inkex.Color((r, g, b)))"""
|
||||
return str(inkex.ColorRGB((r, g, b)))
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatColor3f(r, g, b):
|
||||
"""str(inkex.Color((r, g, b)))"""
|
||||
return str(inkex.ColorRGB((r * 255, g * 255, b * 255)))
|
||||
@@ -1,122 +0,0 @@
|
||||
# coding=utf-8
|
||||
#
|
||||
# pylint: disable=invalid-name
|
||||
#
|
||||
"""
|
||||
Depreicated simpletransform replacements with documentation
|
||||
"""
|
||||
|
||||
import warnings
|
||||
|
||||
from inkex.deprecated import deprecate
|
||||
from inkex.transforms import Transform, BoundingBox, cubic_extrema
|
||||
from inkex.paths import Path
|
||||
|
||||
import inkex, cubicsuperpath
|
||||
|
||||
|
||||
def _lists(mat):
|
||||
return [list(row) for row in mat]
|
||||
|
||||
|
||||
@deprecate
|
||||
def parseTransform(transf, mat=None):
|
||||
"""Transform(str).matrix"""
|
||||
t = Transform(transf)
|
||||
if mat is not None:
|
||||
t = Transform(mat) @ t
|
||||
return _lists(t.matrix)
|
||||
|
||||
|
||||
@deprecate
|
||||
def formatTransform(mat):
|
||||
"""str(Transform(mat))"""
|
||||
if len(mat) == 3:
|
||||
warnings.warn("3x3 matrices not suported")
|
||||
mat = mat[:2]
|
||||
return str(Transform(mat))
|
||||
|
||||
|
||||
@deprecate
|
||||
def invertTransform(mat):
|
||||
"""-Transform(mat)"""
|
||||
return _lists((-Transform(mat)).matrix)
|
||||
|
||||
|
||||
@deprecate
|
||||
def composeTransform(mat1, mat2):
|
||||
"""Transform(M1) * Transform(M2)"""
|
||||
return _lists((Transform(mat1) @ Transform(mat2)).matrix)
|
||||
|
||||
|
||||
@deprecate
|
||||
def composeParents(node, mat):
|
||||
"""elem.composed_transform() or elem.transform * Transform(mat)"""
|
||||
return (node.transform @ Transform(mat)).matrix
|
||||
|
||||
|
||||
@deprecate
|
||||
def applyTransformToNode(mat, node):
|
||||
"""elem.transform = Transform(mat) * elem.transform"""
|
||||
node.transform = Transform(mat) @ node.transform
|
||||
|
||||
|
||||
@deprecate
|
||||
def applyTransformToPoint(mat, pt):
|
||||
"""Transform(mat).apply_to_point(pt)"""
|
||||
pt2 = Transform(mat).apply_to_point(pt)
|
||||
# Apply in place as original method was modifying arrays in place.
|
||||
# but don't do this in your code! This is not good code design.
|
||||
pt[0] = pt2[0]
|
||||
pt[1] = pt2[1]
|
||||
|
||||
|
||||
@deprecate
|
||||
def applyTransformToPath(mat, path):
|
||||
"""Path(path).transform(mat)"""
|
||||
return Path(path).transform(Transform(mat)).to_arrays()
|
||||
|
||||
|
||||
@deprecate
|
||||
def fuseTransform(node):
|
||||
"""node.apply_transform()"""
|
||||
return node.apply_transform()
|
||||
|
||||
|
||||
@deprecate
|
||||
def boxunion(b1, b2):
|
||||
"""list(BoundingBox(b1) + BoundingBox(b2))"""
|
||||
bbox = BoundingBox(b1[:2], b1[2:]) + BoundingBox(b2[:2], b2[2:])
|
||||
return bbox.x.minimum, bbox.x.maximum, bbox.y.minimum, bbox.y.maximum
|
||||
|
||||
|
||||
@deprecate
|
||||
def roughBBox(path):
|
||||
"""list(Path(path)).bounding_box())"""
|
||||
bbox = Path(path).bounding_box()
|
||||
return bbox.x.minimum, bbox.x.maximum, bbox.y.minimum, bbox.y.maximum
|
||||
|
||||
|
||||
@deprecate
|
||||
def refinedBBox(path):
|
||||
"""list(Path(path)).bounding_box())"""
|
||||
bbox = Path(path).bounding_box()
|
||||
return bbox.x.minimum, bbox.x.maximum, bbox.y.minimum, bbox.y.maximum
|
||||
|
||||
|
||||
@deprecate
|
||||
def cubicExtrema(y0, y1, y2, y3):
|
||||
"""from inkex.transforms import cubic_extrema"""
|
||||
return cubic_extrema(y0, y1, y2, y3)
|
||||
|
||||
|
||||
@deprecate
|
||||
def computeBBox(aList, mat=[[1, 0, 0], [0, 1, 0]]):
|
||||
"""sum([node.bounding_box() for node in aList])"""
|
||||
return sum([node.bounding_box() for node in aList], None)
|
||||
|
||||
|
||||
@deprecate
|
||||
def computePointInNode(pt, node, mat=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]):
|
||||
"""(-Transform(node.transform * mat)).apply_to_point(pt)"""
|
||||
return (-Transform(node.transform * mat)).apply_to_point(pt)
|
||||
Reference in New Issue
Block a user