- converted from Python2 code to Python3 code

- in camlib.py, CNCJob class -> generate_from_excellon_by_tool() was
failing in the line to sort the tools due of been unable to compare
between dict's. I replaced that section.
This commit is contained in:
Marius Stanciu
2018-05-26 04:43:40 +03:00
parent bb3b07455c
commit a4bbb98bf1
76 changed files with 394 additions and 389 deletions

View File

@@ -1,9 +1,9 @@
from __future__ import division
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
import cStringIO
import io
from matplotlib.backends.backend_agg import FigureCanvasAgg
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg
from matplotlib.figure import Figure

View File

@@ -8,7 +8,7 @@ class MyObj():
pass
def __del__(self):
print "##### Destroyed ######"
print("##### Destroyed ######")
def parse():

View File

@@ -26,12 +26,12 @@ for geo in geoms:
current_pt = (0, 0)
pt, geo = s.nearest(current_pt)
while geo is not None:
print pt, geo
print "OBJECTS BEFORE:", s.objects
print((pt, geo))
print(("OBJECTS BEFORE:", s.objects))
#geo.coords = list(geo.coords[::-1])
s.remove(geo)
print "OBJECTS AFTER:", s.objects
print(("OBJECTS AFTER:", s.objects))
current_pt = geo.coords[-1]
pt, geo = s.nearest(current_pt)

View File

@@ -13,12 +13,12 @@ rt = rtindex.Index(properties=p)
# If interleaved is True, the coordinates must be in
# the form [xmin, ymin, ..., kmin, xmax, ymax, ..., kmax].
print rt.interleaved
print((rt.interleaved))
[rt.add(0, pt2rect(pt)) for pt in pts]
print [r.bbox for r in list(rt.nearest((0, 0), 10, True))]
print([r.bbox for r in list(rt.nearest((0, 0), 10, True))])
for pt in pts:
rt.delete(0, pt2rect(pt))
print pt2rect(pt), [r.bbox for r in list(rt.nearest((0, 0), 10, True))]
print((pt2rect(pt), [r.bbox for r in list(rt.nearest((0, 0), 10, True))]))

View File

@@ -36,18 +36,18 @@ class ExcellonFlowTestCase(unittest.TestCase):
def test_flow(self):
# Names of available objects.
names = self.fc.collection.get_names()
print names
print(names)
#--------------------------------------
# Total of 1 objects.
#--------------------------------------
self.assertEquals(len(names), 1,
self.assertEqual(len(names), 1,
"Expected 1 object, found %d" % len(names))
#--------------------------------------
# Object's name matches the file name.
#--------------------------------------
self.assertEquals(names[0], self.filename,
self.assertEqual(names[0], self.filename,
"Expected name == %s, got %s" % (self.filename, names[0]))
#---------------------------------------
@@ -65,14 +65,14 @@ class ExcellonFlowTestCase(unittest.TestCase):
# TODO: Open GUI with double-click on object.
# Opens the Object's GUI, populates it.
excellon_obj.build_ui()
for option, value in excellon_obj.options.iteritems():
for option, value in list(excellon_obj.options.items()):
try:
form_field = excellon_obj.form_fields[option]
except KeyError:
print ("**********************************************************\n"
print(("**********************************************************\n"
"* WARNING: Option '{}' has no form field\n"
"**********************************************************"
"".format(option))
"".format(option)))
continue
self.assertEqual(value, form_field.get_value(),
"Option '{}' == {} but form has {}".format(
@@ -87,7 +87,7 @@ class ExcellonFlowTestCase(unittest.TestCase):
form_field = excellon_obj.form_fields['feedrate']
value = form_field.get_value()
form_field.set_value(value * 1.1) # Increase by 10%
print "'feedrate' == {}".format(value)
print(("'feedrate' == {}".format(value)))
#--------------------------------------------------
# Create GCode using all tools.
@@ -119,7 +119,7 @@ class ExcellonFlowTestCase(unittest.TestCase):
self.assertEqual(value, form_value,
"Form value for '{}' == {} was not read into options"
"which has {}".format('feedrate', form_value, value))
print "'feedrate' == {}".format(value)
print(("'feedrate' == {}".format(value)))
#---------------------------------------------
# Check that only 1 object has been created.
@@ -160,4 +160,4 @@ class ExcellonFlowTestCase(unittest.TestCase):
self.assertTrue(os.path.isfile(output_filename))
os.remove(output_filename)
print names
print(names)

View File

@@ -36,18 +36,18 @@ class GerberFlowTestCase(unittest.TestCase):
def test_flow(self):
# Names of available objects.
names = self.fc.collection.get_names()
print names
print(names)
#--------------------------------------
# Total of 1 objects.
#--------------------------------------
self.assertEquals(len(names), 1,
self.assertEqual(len(names), 1,
"Expected 1 object, found %d" % len(names))
#--------------------------------------
# Object's name matches the file name.
#--------------------------------------
self.assertEquals(names[0], self.filename,
self.assertEqual(names[0], self.filename,
"Expected name == %s, got %s" % (self.filename, names[0]))
#---------------------------------------
@@ -65,14 +65,14 @@ class GerberFlowTestCase(unittest.TestCase):
# TODO: Open GUI with double-click on object.
# Opens the Object's GUI, populates it.
gerber_obj.build_ui()
for option, value in gerber_obj.options.iteritems():
for option, value in list(gerber_obj.options.items()):
try:
form_field = gerber_obj.form_fields[option]
except KeyError:
print ("**********************************************************\n"
print(("**********************************************************\n"
"* WARNING: Option '{}' has no form field\n"
"**********************************************************"
"".format(option))
"".format(option)))
continue
self.assertEqual(value, form_field.get_value(),
"Option '{}' == {} but form has {}".format(
@@ -87,7 +87,7 @@ class GerberFlowTestCase(unittest.TestCase):
form_field = gerber_obj.form_fields['isotooldia']
value = form_field.get_value()
form_field.set_value(value * 1.1) # Increase by 10%
print "'isotooldia' == {}".format(value)
print(("'isotooldia' == {}".format(value)))
#--------------------------------------------------
# Create isolation routing using default values
@@ -110,7 +110,7 @@ class GerberFlowTestCase(unittest.TestCase):
self.assertEqual(value, form_value,
"Form value for '{}' == {} was not read into options"
"which has {}".format('isotooldia', form_value, value))
print "'isotooldia' == {}".format(value)
print(("'isotooldia' == {}".format(value)))
#---------------------------------------------
# Check that only 1 object has been created.
@@ -187,4 +187,4 @@ class GerberFlowTestCase(unittest.TestCase):
self.assertTrue(os.path.isfile(output_filename))
os.remove(output_filename)
print names
print(names)

View File

@@ -75,66 +75,66 @@ class PaintConnectTest(PaintTestCase):
self.boundary = Polygon([[0, 0], [0, 5], [5, 5], [5, 0]])
def test_jump(self):
print "Test: WALK Expected"
print("Test: WALK Expected")
paths = [
LineString([[0.5, 2], [2, 4.5]]),
LineString([[2, 0.5], [4.5, 2]])
]
for p in paths:
print p
print(p)
tooldia = 1.0
print "--"
print("--")
result = Geometry.paint_connect(mkstorage(deepcopy(paths)), self.boundary, tooldia)
result = list(result.get_objects())
for r in result:
print r
print(r)
self.assertEqual(len(result), 1)
# self.plot_summary_A(paths, tooldia, result, "WALK expected.")
def test_no_jump1(self):
print "Test: FLY Expected"
print("Test: FLY Expected")
paths = [
LineString([[0, 2], [2, 5]]),
LineString([[2, 0], [5, 2]])
]
for p in paths:
print p
print(p)
tooldia = 1.0
print "--"
print("--")
result = Geometry.paint_connect(mkstorage(deepcopy(paths)), self.boundary, tooldia)
result = list(result.get_objects())
for r in result:
print r
print(r)
self.assertEqual(len(result), len(paths))
# self.plot_summary_A(paths, tooldia, result, "FLY Expected")
def test_no_jump2(self):
print "Test: FLY Expected"
print("Test: FLY Expected")
paths = [
LineString([[0.5, 2], [2, 4.5]]),
LineString([[2, 0.5], [4.5, 2]])
]
for p in paths:
print p
print(p)
tooldia = 1.1
print "--"
print("--")
result = Geometry.paint_connect(mkstorage(deepcopy(paths)), self.boundary, tooldia)
result = list(result.get_objects())
for r in result:
print r
print(r)
self.assertEqual(len(result), len(paths))
@@ -153,22 +153,22 @@ class PaintConnectTest2(PaintTestCase):
)
def test_no_jump3(self):
print "TEST: No jump expected"
print("TEST: No jump expected")
paths = [
LineString([[0.5, 1], [1.5, 3]]),
LineString([[4, 1], [4, 4]])
]
for p in paths:
print p
print(p)
tooldia = 1.0
print "--"
print("--")
result = Geometry.paint_connect(mkstorage(deepcopy(paths)), self.boundary, tooldia)
result = list(result.get_objects())
for r in result:
print r
print(r)
self.assertEqual(len(result), len(paths))
@@ -182,26 +182,26 @@ class PaintConnectTest3(PaintTestCase):
def setUp(self):
self.boundary = Polygon([[0, 0], [0, 5], [5, 5], [5, 0]])
print "TEST w/ LinearRings"
print("TEST w/ LinearRings")
def test_jump2(self):
print "Test: WALK Expected"
print("Test: WALK Expected")
paths = [
LineString([[0.5, 2], [2, 4.5]]),
LineString([[2, 0.5], [4.5, 2]]),
self.boundary.buffer(-0.5).exterior
]
for p in paths:
print p
print(p)
tooldia = 1.0
print "--"
print("--")
result = Geometry.paint_connect(mkstorage(deepcopy(paths)), self.boundary, tooldia)
result = list(result.get_objects())
for r in result:
print r
print(r)
self.assertEqual(len(result), 1)

View File

@@ -20,7 +20,7 @@ def mkstorage(paths):
class PathConnectTest1(unittest.TestCase):
def setUp(self):
print "PathConnectTest1.setUp()"
print("PathConnectTest1.setUp()")
pass
def test_simple_connect(self):
@@ -68,8 +68,8 @@ class PathConnectTest1(unittest.TestCase):
[2 + offset_x, 1 + offset_y]])))
def test_ring_interfere_connect(self):
print
print "TEST STARTING ..."
print()
print("TEST STARTING ...")
paths = [
LineString([[0, 0], [1, 1]]),

View File

@@ -30,9 +30,9 @@ class PolyPaintTestCase(unittest.TestCase):
def test_poly_paint_svg_all(self):
print "*********************************"
print "* svg_all *"
print "*********************************"
print("*********************************")
print("* svg_all *")
print("*********************************")
# Clear workspace
self.fc.on_file_new()
@@ -69,9 +69,9 @@ class PolyPaintTestCase(unittest.TestCase):
def test_poly_paint_svg_click(self):
print "*********************************"
print "* svg_click *"
print "*********************************"
print("*********************************")
print("* svg_click *")
print("*********************************")
# Clear workspace
self.fc.on_file_new()
@@ -109,9 +109,9 @@ class PolyPaintTestCase(unittest.TestCase):
def test_poly_paint_noncopper_all(self):
print "*********************************"
print "* noncopper_all *"
print "*********************************"
print("*********************************")
print("* noncopper_all *")
print("*********************************")
# Clear workspace
self.fc.on_file_new()
@@ -165,9 +165,9 @@ class PolyPaintTestCase(unittest.TestCase):
def test_poly_paint_noncopper_click(self):
print "*********************************"
print "* noncopper_click *"
print "*********************************"
print("*********************************")
print("* noncopper_click *")
print("*********************************")
# Clear workspace
self.fc.on_file_new()

View File

@@ -29,18 +29,18 @@ class SVGFlowTestCase(unittest.TestCase):
self.fc.import_svg('tests/svg/' + self.filename)
names = self.fc.collection.get_names()
print names
print(names)
#--------------------------------------
# Total of 1 objects.
#--------------------------------------
self.assertEquals(len(names), 1,
self.assertEqual(len(names), 1,
"Expected 1 object, found %d" % len(names))
#--------------------------------------
# Object's name matches the file name.
#--------------------------------------
self.assertEquals(names[0], self.filename,
self.assertEqual(names[0], self.filename,
"Expected name == %s, got %s" % (self.filename, names[0]))
#---------------------------------------
@@ -58,14 +58,14 @@ class SVGFlowTestCase(unittest.TestCase):
# TODO: Open GUI with double-click on object.
# Opens the Object's GUI, populates it.
geo_obj.build_ui()
for option, value in geo_obj.options.iteritems():
for option, value in list(geo_obj.options.items()):
try:
form_field = geo_obj.form_fields[option]
except KeyError:
print ("**********************************************************\n"
print(("**********************************************************\n"
"* WARNING: Option '{}' has no form field\n"
"**********************************************************"
"".format(option))
"".format(option)))
continue
self.assertEqual(value, form_field.get_value(),
"Option '{}' == {} but form has {}".format(
@@ -126,4 +126,4 @@ class SVGFlowTestCase(unittest.TestCase):
self.assertTrue(os.path.isfile(output_filename))
os.remove(output_filename)
print names
print(names)

View File

@@ -2,17 +2,17 @@ import pkgutil
import sys
# allowed command tests (please append them alphabetically ordered)
from test_TclCommandAddPolygon import *
from test_TclCommandAddPolyline import *
from test_TclCommandCncjob import *
from test_TclCommandDrillcncjob import *
from test_TclCommandExportGcode import *
from test_TclCommandExteriors import *
from test_TclCommandImportSvg import *
from test_TclCommandInteriors import *
from test_TclCommandIsolate import *
from test_TclCommandNew import *
from test_TclCommandNewGeometry import *
from test_TclCommandOpenExcellon import *
from test_TclCommandOpenGerber import *
from test_TclCommandPaintPolygon import *
from .test_TclCommandAddPolygon import *
from .test_TclCommandAddPolyline import *
from .test_TclCommandCncjob import *
from .test_TclCommandDrillcncjob import *
from .test_TclCommandExportGcode import *
from .test_TclCommandExteriors import *
from .test_TclCommandImportSvg import *
from .test_TclCommandInteriors import *
from .test_TclCommandIsolate import *
from .test_TclCommandNew import *
from .test_TclCommandNewGeometry import *
from .test_TclCommandOpenExcellon import *
from .test_TclCommandOpenGerber import *
from .test_TclCommandPaintPolygon import *

View File

@@ -1,5 +1,5 @@
from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry, FlatCAMObj
from test_TclCommandIsolate import *
from .test_TclCommandIsolate import *
def test_cncjob(self):
"""

View File

@@ -1,5 +1,5 @@
from FlatCAMObj import FlatCAMObj
from test_TclCommandOpenExcellon import *
from .test_TclCommandOpenExcellon import *
def test_drillcncjob(self):

View File

@@ -1,8 +1,8 @@
import os
import tempfile
from test_TclCommandCncjob import *
from test_TclCommandDrillcncjob import *
from .test_TclCommandCncjob import *
from .test_TclCommandDrillcncjob import *
def test_export_gcodecncjob(self):

View File

@@ -82,7 +82,7 @@ class TclShellTest(unittest.TestCase):
# Units must be IN
#----------------------------------------
units = self.fc.exec_command_test('get_sys units')
self.assertEquals(units, "IN")
self.assertEqual(units, "IN")
# MM
self.fc.exec_command_test('set_sys units MM')
@@ -92,7 +92,7 @@ class TclShellTest(unittest.TestCase):
# Units must be MM
#----------------------------------------
units = self.fc.exec_command_test('get_sys units')
self.assertEquals(units, "MM")
self.assertEqual(units, "MM")
def test_gerber_flow(self):
"""