131 lines
5.0 KiB
Diff
131 lines
5.0 KiB
Diff
|
From d3ed2703736d9157b2cdadd4b5a95324aacc6191 Mon Sep 17 00:00:00 2001
|
||
|
From: Thomas Holder <thomas@thomas-holder.de>
|
||
|
Date: Tue, 12 Mar 2019 16:29:56 +0100
|
||
|
Subject: [PATCH] extensions 2to3: follow-up
|
||
|
|
||
|
---
|
||
|
share/extensions/color_desaturate.py | 2 +-
|
||
|
share/extensions/dxf_input.py | 2 +-
|
||
|
share/extensions/dxf_outlines.py | 2 +-
|
||
|
share/extensions/ink2canvas/svg.py | 6 +++++-
|
||
|
share/extensions/voronoi.py | 12 +++++++++---
|
||
|
5 files changed, 17 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/share/extensions/color_desaturate.py b/share/extensions/color_desaturate.py
|
||
|
index a2350a4d32..978e199a29 100755
|
||
|
--- a/share/extensions/color_desaturate.py
|
||
|
+++ b/share/extensions/color_desaturate.py
|
||
|
@@ -3,7 +3,7 @@ import coloreffect
|
||
|
|
||
|
class C(coloreffect.ColorEffect):
|
||
|
def colmod(self,r,g,b):
|
||
|
- l = (max(r,g,b)+min(r,g,b))/2
|
||
|
+ l = (max(r,g,b)+min(r,g,b)) // 2
|
||
|
ig=int(round(l))
|
||
|
return '%02x%02x%02x' % (ig,ig,ig)
|
||
|
|
||
|
diff --git a/share/extensions/dxf_input.py b/share/extensions/dxf_input.py
|
||
|
index 3e15c0b8fd..8754e7cb63 100755
|
||
|
--- a/share/extensions/dxf_input.py
|
||
|
+++ b/share/extensions/dxf_input.py
|
||
|
@@ -109,7 +109,7 @@ def export_SPLINE():
|
||
|
vals[groups['20']].insert(i-1, (1.0 - a1)*vals[groups['20']][i-2] + a1*vals[groups['20']][i-1])
|
||
|
ctrls = len(vals[groups['10']])
|
||
|
path = 'M %f,%f' % (vals[groups['10']][0], vals[groups['20']][0])
|
||
|
- for i in range (0, (ctrls - 1)/3):
|
||
|
+ for i in range (0, (ctrls - 1) // 3):
|
||
|
path += ' C %f,%f %f,%f %f,%f' % (vals[groups['10']][3*i + 1], vals[groups['20']][3*i + 1], vals[groups['10']][3*i + 2], vals[groups['20']][3*i + 2], vals[groups['10']][3*i + 3], vals[groups['20']][3*i + 3])
|
||
|
if vals[groups['70']][0] & 1: # closed path
|
||
|
path += ' z'
|
||
|
diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py
|
||
|
index e07681bbba..53c1a523e6 100755
|
||
|
--- a/share/extensions/dxf_outlines.py
|
||
|
+++ b/share/extensions/dxf_outlines.py
|
||
|
@@ -103,7 +103,7 @@ class MyEffect(inkex.Effect):
|
||
|
self.poly = [[0.0,0.0]] # LWPOLYLINE data
|
||
|
def output(self):
|
||
|
stdout = sys.stdout if sys.version_info[0] < 3 else sys.stdout.buffer
|
||
|
- stdout.write(b''.join(self.dxf))
|
||
|
+ stdout.write(b''.join(self.dxf) + b'\n')
|
||
|
def dxf_add(self, str):
|
||
|
self.dxf.append(str.encode(self.options.char_encode))
|
||
|
def dxf_line(self,csp):
|
||
|
diff --git a/share/extensions/ink2canvas/svg.py b/share/extensions/ink2canvas/svg.py
|
||
|
index f4dca8279d..8d1402b7b0 100644
|
||
|
--- a/share/extensions/ink2canvas/svg.py
|
||
|
+++ b/share/extensions/ink2canvas/svg.py
|
||
|
@@ -16,6 +16,10 @@ along with this program; if not, write to the Free Software
|
||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
'''
|
||
|
|
||
|
+import sys
|
||
|
+if sys.version_info[0] > 2:
|
||
|
+ unicode = lambda s: s.decode() if isinstance(s, bytes) else str(s)
|
||
|
+
|
||
|
import inkex
|
||
|
import simplestyle
|
||
|
from simplepath import parsePath
|
||
|
@@ -326,7 +330,7 @@ class Polygon(Path):
|
||
|
points = map(lambda x: x.split(","), points)
|
||
|
comm = []
|
||
|
for pt in points: # creating path command similar
|
||
|
- pt = map(float, pt)
|
||
|
+ pt = list(map(float, pt))
|
||
|
comm.append(["L", pt])
|
||
|
comm[0][0] = "M" # first command must be a 'M' => moveTo
|
||
|
return comm
|
||
|
diff --git a/share/extensions/voronoi.py b/share/extensions/voronoi.py
|
||
|
index af83007f1a..d3e9b124df 100644
|
||
|
--- a/share/extensions/voronoi.py
|
||
|
+++ b/share/extensions/voronoi.py
|
||
|
@@ -189,7 +189,7 @@ def voronoi(siteList,context):
|
||
|
if not priorityQ.isEmpty():
|
||
|
minpt = priorityQ.getMinPt()
|
||
|
|
||
|
- if (newsite and (priorityQ.isEmpty() or cmp(newsite,minpt) < 0)):
|
||
|
+ if (newsite and (priorityQ.isEmpty() or newsite < minpt)):
|
||
|
# newsite is smallest - this is a site event
|
||
|
context.outSite(newsite)
|
||
|
|
||
|
@@ -341,6 +341,9 @@ class Site(object):
|
||
|
else:
|
||
|
return 0
|
||
|
|
||
|
+ def __lt__(self, other):
|
||
|
+ return self.__cmp__(other) < 0
|
||
|
+
|
||
|
def distance(self,other):
|
||
|
dx = self.x - other.x
|
||
|
dy = self.y - other.y
|
||
|
@@ -442,6 +445,9 @@ class Halfedge(object):
|
||
|
else:
|
||
|
return 0
|
||
|
|
||
|
+ def __lt__(self, other):
|
||
|
+ return self.__cmp__(other) < 0
|
||
|
+
|
||
|
def leftreg(self,default):
|
||
|
if not self.edge:
|
||
|
return default
|
||
|
@@ -519,7 +525,7 @@ class Halfedge(object):
|
||
|
|
||
|
xint = (e1.c*e2.b - e2.c*e1.b) / d
|
||
|
yint = (e2.c*e1.a - e1.c*e2.a) / d
|
||
|
- if(cmp(e1.reg[1],e2.reg[1]) < 0):
|
||
|
+ if e1.reg[1] < e2.reg[1]:
|
||
|
he = self
|
||
|
e = e1
|
||
|
else:
|
||
|
@@ -637,7 +643,7 @@ class PriorityQueue(object):
|
||
|
he.ystar = site.y + offset
|
||
|
last = self.hash[self.getBucket(he)]
|
||
|
next = last.qnext
|
||
|
- while((next is not None) and cmp(he,next) > 0):
|
||
|
+ while((next is not None) and he > next):
|
||
|
last = next
|
||
|
next = last.qnext
|
||
|
he.qnext = last.qnext
|
||
|
--
|
||
|
2.21.0
|
||
|
|