Commit 13d4f99f authored by Thomas Holder's avatar Thomas Holder

extensions 2to3: print

parent cac83ec8
......@@ -268,7 +268,7 @@ if __name__ == '__main__':
print s, st
'''
for curve in curves:
print beziertatlength(curve,0.5)
print(beziertatlength(curve,0.5))
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
......@@ -21,13 +21,15 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'''
from __future__ import print_function
import struct
def process_file(filename):
try:
f = open(filename, 'rb')
except IOError as e:
print >> sys.stderr, 'Unable to open %s: %s' % (filename, e)
print('Unable to open %s: %s' % (filename, e), file=sys.stderr)
return
with f:
......@@ -73,10 +75,10 @@ def process_file(filename):
points = ' '.join(','.join(map(str, e)) for e in coords)
svg_element = '<polyline points="%s" dm:timestamp="%s" />' % (points, timestamp)
else:
print >> sys.stderr, 'Unsupported tag: %s\n' % tag
print('Unsupported tag: %s\n' % tag, file=sys.stderr)
# Emit the footer to finish it off
print '\n</svg>\n'
print('\n</svg>\n')
def read_point(f, ymax):
......@@ -90,7 +92,7 @@ def read_point(f, ymax):
def emit_header(f):
id, version, width, height, page_type = struct.unpack('<32sBHHBxx', f.read(40))
print '''
print('''
<svg viewBox="0 0 %(width)s %(height)s" fill="none" stroke="black" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
......@@ -107,14 +109,14 @@ def emit_header(f):
</dm:page>
</metadata>
<rect width="%(width)s" height="%(height)s" fill="aliceblue"/>
''' % locals()
''' % locals())
return height
def emit_element(message):
if message:
print '%s\n' % message
print('%s\n' % message)
if __name__ == '__main__':
......@@ -123,6 +125,6 @@ if __name__ == '__main__':
if len(sys.argv) == 2:
process_file(sys.argv[1])
else:
print >> sys.stderr, 'Usage: %s <dhw-file>' % sys.argv[0]
print('Usage: %s <dhw-file>' % sys.argv[0], file=sys.stderr)
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
......@@ -373,34 +373,34 @@ class DPISwitcher(inkex.Effect):
sys.stdout = sys.stderr
svg = self.document.getroot()
if self.options.action == '"page_info"':
print ":::SVG document related info:::"
print "version: " + str(svg.get(inkex.addNS('version',u'inkscape')))
print(":::SVG document related info:::")
print("version: " + str(svg.get(inkex.addNS('version',u'inkscape'))))
width = svg.get('width')
if width:
print "width: " + width
print("width: " + width)
height = svg.get('height')
if height:
print "height: " + height
print("height: " + height)
viewBox = svg.get('viewBox')
if viewBox:
print "viewBox: " + viewBox
print("viewBox: " + viewBox)
namedview = svg.find(inkex.addNS('namedview', 'sodipodi'))
docunits= namedview.get(inkex.addNS('document-units', 'inkscape'))
if docunits:
print "document-units: " + docunits
print("document-units: " + docunits)
units = namedview.get('units')
if units:
print "units: " + units
print("units: " + units)
xpathStr = '//sodipodi:guide'
guides = svg.xpath(xpathStr, namespaces=inkex.NSS)
xpathStr = '//inkscape:grid'
if guides:
numberGuides = len(guides)
print "Document has " + str(numberGuides) + " guides"
print("Document has " + str(numberGuides) + " guides")
grids = svg.xpath(xpathStr, namespaces=inkex.NSS)
i = 1
for grid in grids:
print "Grid number " + str(i) + ": Units: " + grid.get("units")
print("Grid number " + str(i) + ": Units: " + grid.get("units"))
i = i+1
else:
if self.options.switcher == "0":
......
......@@ -99,7 +99,7 @@ class MyEffect(inkex.Effect):
self.d = array([0], float) # knot vector
self.poly = [[0.0,0.0]] # LWPOLYLINE data
def output(self):
print ''.join(self.dxf)
print(''.join(self.dxf))
def dxf_add(self, str):
self.dxf.append(str.encode(self.options.char_encode))
def dxf_line(self,csp):
......
......@@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
from __future__ import print_function
import inkex, os, tempfile, sys, xml.dom.minidom
def parse_pkgs(pkgstring):
......@@ -119,7 +121,7 @@ class EQTEXSVG(inkex.Effect):
os.rmdir(base_dir)
if self.options.formula == "":
print >>sys.stderr, "empty LaTeX input. Nothing to be done"
print("empty LaTeX input. Nothing to be done", file=sys.stderr)
return
add_header = parse_pkgs(self.options.packages)
......@@ -129,9 +131,9 @@ class EQTEXSVG(inkex.Effect):
try:
os.stat(dvi_file)
except OSError:
print >>sys.stderr, "invalid LaTeX input:"
print >>sys.stderr, self.options.formula
print >>sys.stderr, "temporary files were left in:", base_dir
print("invalid LaTeX input:", file=sys.stderr)
print(self.options.formula, file=sys.stderr)
print("temporary files were left in:", base_dir, file=sys.stderr)
sys.exit(1)
os.system('dvips -q -f -E -D 600 -y 5000 -o "%s" "%s"' % (ps_file, dvi_file))
......
......@@ -47,10 +47,10 @@ stream = open(sys.argv[-1:][0],'r')
dom = parse(stream)
stream.close()
walk(dom)
print 'GIMP Palette\nName: %s\n#' % (dom.getElementsByTagName('svg')[0].getAttribute(DOCNAME).split('.')[0])
print('GIMP Palette\nName: %s\n#' % (dom.getElementsByTagName('svg')[0].getAttribute(DOCNAME).split('.')[0]))
for k,v in sorted(colors.items()):
print k+v
print(k+v)
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
......@@ -70,7 +70,7 @@ class HpglOutput(inkex.Effect):
def output(self):
# print to file
if self.hpgl != '':
print self.hpgl
print(self.hpgl)
if __name__ == '__main__':
# start extension
......
......@@ -59,6 +59,7 @@ Note: Paths that have curves & arcs on some sides of the bounding box won't
"""
from __future__ import division
from __future__ import print_function
import sys
# *** numpy causes issue #4 on Mac OS 10.6.2. I use it for
......@@ -471,7 +472,7 @@ class PixelSnapEffect(inkex.Effect):
try:
self.pixel_snap(e, transform)
except TransformError as e:
print >>sys.stderr, e
print(e, file=sys.stderr)
return
if not elemtype(elem, ('path', 'rect', 'image')):
......@@ -481,7 +482,7 @@ class PixelSnapEffect(inkex.Effect):
try:
self.snap_stroke(elem, parent_transform)
except TransformError as e:
print >>sys.stderr, e
print(e, file=sys.stderr)
if elemtype(elem, 'path'):
self.snap_path_scale(elem, parent_transform)
......@@ -499,7 +500,7 @@ class PixelSnapEffect(inkex.Effect):
try:
self.pixel_snap(elem)
except TransformError as e:
print >>sys.stderr, e
print(e, file=sys.stderr)
if __name__ == '__main__':
......
......@@ -78,12 +78,12 @@ def test_barcode():
('Upca', '12345678911'),
('Upce', '123456'),
):
print "RENDER TEST: %s" % kind
print("RENDER TEST: %s" % kind)
bargen = getBarcode(kind, text=text)
if bargen is not None:
barcode = bargen.generate()
if barcode is not None:
print inkex.etree.tostring(barcode, pretty_print=True)
print(inkex.etree.tostring(barcode, pretty_print=True))
if __name__ == '__main__':
......
#!/usr/bin/env python
from __future__ import print_function
import math, sys
import inkex
from simpletransform import computePointInNode
......@@ -1008,7 +1010,7 @@ class QRBitBuffer:
def get(self, index):
bufIndex = math.floor(index / 8)
val = ( (self.buffer[bufIndex] >> (7 - index % 8) ) & 1) == 1
print "get ", val
print("get ", val)
return ( (self.buffer[bufIndex] >> (7 - index % 8) ) & 1) == 1
def put(self, num, length):
for i in range(length):
......
......@@ -29,8 +29,10 @@
#
#############################################################################
from __future__ import print_function
def usage():
print """
print("""
voronoi - compute Voronoi diagram or Delaunay triangulation
voronoi [-t -p -d] [filename]
......@@ -67,7 +69,7 @@ On unsorted data uniformly distributed in the unit square, voronoi uses about
AUTHOR
Steve J. Fortune (1987) A Sweepline Algorithm for Voronoi Diagrams,
Algorithmica 2, 153-174.
"""
""")
#############################################################################
#
......@@ -123,39 +125,39 @@ class Context(object):
def outSite(self,s):
if(self.debug):
print "site (%d) at %f %f" % (s.sitenum, s.x, s.y)
print("site (%d) at %f %f" % (s.sitenum, s.x, s.y))
elif(self.triangulate):
pass
elif(self.plot):
self.circle (s.x, s.y, cradius)
elif(self.doPrint):
print "s %f %f" % (s.x, s.y)
print("s %f %f" % (s.x, s.y))
def outVertex(self,s):
self.vertices.append((s.x,s.y))
if(self.debug):
print "vertex(%d) at %f %f" % (s.sitenum, s.x, s.y)
print("vertex(%d) at %f %f" % (s.sitenum, s.x, s.y))
elif(self.triangulate):
pass
elif(self.doPrint and not self.plot):
print "v %f %f" % (s.x,s.y)
print("v %f %f" % (s.x,s.y))
def outTriple(self,s1,s2,s3):
self.triangles.append((s1.sitenum, s2.sitenum, s3.sitenum))
if(self.debug):
print "circle through left=%d right=%d bottom=%d" % (s1.sitenum, s2.sitenum, s3.sitenum)
print("circle through left=%d right=%d bottom=%d" % (s1.sitenum, s2.sitenum, s3.sitenum))
elif(self.triangulate and self.doPrint and not self.plot):
print "%d %d %d" % (s1.sitenum, s2.sitenum, s3.sitenum)
print("%d %d %d" % (s1.sitenum, s2.sitenum, s3.sitenum))
def outBisector(self,edge):
self.lines.append((edge.a, edge.b, edge.c))
if(self.debug):
print "line(%d) %gx+%gy=%g, bisecting %d %d" % (edge.edgenum, edge.a, edge.b, edge.c, edge.reg[0].sitenum, edge.reg[1].sitenum)
print("line(%d) %gx+%gy=%g, bisecting %d %d" % (edge.edgenum, edge.a, edge.b, edge.c, edge.reg[0].sitenum, edge.reg[1].sitenum))
elif(self.triangulate):
if(self.plot):
self.line(edge.reg[0].x, edge.reg[0].y, edge.reg[1].x, edge.reg[1].y)
elif(self.doPrint and not self.plot):
print "l %f %f %f" % (edge.a, edge.b, edge.c)
print("l %f %f %f" % (edge.a, edge.b, edge.c))
def outEdge(self,edge):
sitenumL = -1
......@@ -169,9 +171,9 @@ class Context(object):
if self.plot:
self.clip_line(edge)
elif(self.doPrint):
print "e %d" % edge.edgenum,
print " %d " % sitenumL,
print "%d" % sitenumR
print("e %d" % edge.edgenum, end=' ')
print(" %d " % sitenumL, end=' ')
print("%d" % sitenumR)
#------------------------------------------------------------------
def voronoi(siteList,context):
......@@ -325,7 +327,7 @@ class Site(object):
self.sitenum = sitenum
def dump(self):
print "Site #%d (%g, %g)" % (self.sitenum,self.x,self.y)
print("Site #%d (%g, %g)" % (self.sitenum,self.x,self.y))
def __cmp__(self,other):
if self.y < other.y:
......@@ -360,9 +362,9 @@ class Edge(object):
self.edgenum = 0
def dump(self):
print "(#%d a=%g, b=%g, c=%g)" % (self.edgenum,self.a,self.b,self.c)
print "ep",self.ep
print "reg",self.reg
print("(#%d a=%g, b=%g, c=%g)" % (self.edgenum,self.a,self.b,self.c))
print("ep",self.ep)
print("reg",self.reg)
def setEndpoint(self, lrFlag, site):
self.ep[lrFlag] = site
......@@ -417,15 +419,15 @@ class Halfedge(object):
self.ystar = BIG_FLOAT
def dump(self):
print "Halfedge--------------------------"
print "left: ", self.left
print "right: ", self.right
print "edge: ", self.edge
print "pm: ", self.pm
print "vertex: ",
print("Halfedge--------------------------")
print("left: ", self.left)
print("right: ", self.right)
print("edge: ", self.edge)
print("pm: ", self.pm)
print("vertex: ", end=' ')
if self.vertex: self.vertex.dump()
else: print "None"
print "ystar: ", self.ystar
else: print("None")
print("ystar: ", self.ystar)
def __cmp__(self,other):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment