- minor changes to increase compatibility with Python 3.8

This commit is contained in:
Marius Stanciu 2020-04-01 18:45:20 +03:00 committed by Marius
parent d326524fe3
commit 3d39916b5f
17 changed files with 72 additions and 67 deletions

View File

@ -5317,8 +5317,8 @@ class App(QtCore.QObject):
# try to quit the QThread that run ArgsThread class
try:
self.th.quit()
except Exception:
pass
except Exception as e:
log.debug("App.final_save() --> %s" % str(e))
# try to quit the Socket opened by ArgsThread class
try:
@ -5327,7 +5327,11 @@ class App(QtCore.QObject):
log.debug("App.quit_application() --> %s" % str(err))
# quit app by signalling for self.kill_app() method
self.close_app_signal.emit()
# self.close_app_signal.emit()
QtWidgets.qApp.quit()
# When the main event loop is not started yet in which case the qApp.quit() will do nothing
# we use the following command
sys.exit(0)
def kill_app(self):
QtWidgets.qApp.quit()
@ -10178,7 +10182,7 @@ class App(QtCore.QObject):
filenames, _f = QtWidgets.QFileDialog.getOpenFileNames(caption=_("Import SVG"),
filter=_filter_)
if type_of_obj is not "geometry" and type_of_obj is not "gerber":
if type_of_obj != "geometry" and type_of_obj != "gerber":
type_of_obj = "geometry"
filenames = [str(filename) for filename in filenames]
@ -10211,7 +10215,7 @@ class App(QtCore.QObject):
filenames, _f = QtWidgets.QFileDialog.getOpenFileNames(caption=_("Import DXF"),
filter=_filter_)
if type_of_obj is not "geometry" and type_of_obj is not "gerber":
if type_of_obj != "geometry" and type_of_obj != "gerber":
type_of_obj = "geometry"
filenames = [str(filename) for filename in filenames]

View File

@ -261,7 +261,7 @@ class BookmarkManager(QtWidgets.QWidget):
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Title entry is empty."))
return 'fail'
if 'link' is kwargs:
if 'link' in kwargs:
link = kwargs['link']
else:
link = self.link_entry.get_value()
@ -1325,7 +1325,7 @@ class ToolsDB(QtWidgets.QWidget):
default_data['toolchangez'] = self.table_widget.cellWidget(row, col).get_value()
elif column_header_text == _('Start Z'):
default_data['startz'] = float(self.table_widget.item(row, col).text()) \
if self.table_widget.item(row, col).text() is not '' else None
if self.table_widget.item(row, col).text() != '' else None
elif column_header_text == _('End Z'):
default_data['endz'] = self.table_widget.cellWidget(row, col).get_value()

View File

@ -567,7 +567,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
FlatCAMGerber.merge(grb, grb_final)
else: # If not list, just append
for option in grb.options:
if option is not 'name':
if option != 'name':
try:
grb_final.options[option] = grb.options[option]
except KeyError:
@ -2507,7 +2507,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
for exc in flattened_list:
# copy options of the current excellon obj to the final excellon obj
for option in exc.options:
if option is not 'name':
if option != 'name':
try:
exc_final.options[option] = exc.options[option]
except Exception:
@ -6440,7 +6440,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
for geo_obj in geo_list:
for option in geo_obj.options:
if option is not 'name':
if option != 'name':
try:
new_options[option] = deepcopy(geo_obj.options[option])
except Exception as e:

View File

@ -518,7 +518,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.endInsertRows()
# Expand group
if group.child_count() is 1:
if group.child_count() == 1:
self.view.setExpanded(group_index, True)
self.app.should_we_save = True

View File

@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
1.04.2020
- updated the SVG parser to take into consideration the 'Close' svg element and paths that are made from a single line (we may need to switch to svgpathtools module)
- minor changes to increase compatibility with Python 3.8
30.03.2020

View File

@ -3393,7 +3393,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.app.log.debug("on_tool_select('%s')" % tool)
if self.last_tool_selected is None and current_tool is not 'drill_select':
if self.last_tool_selected is None and current_tool != 'drill_select':
# self.draw_app.select_tool('drill_select')
self.complete = True
current_tool = 'drill_select'

View File

@ -1327,11 +1327,11 @@ class TransformEditorTool(FlatCAMTool):
# execute mirroring
for sha in shape_list:
if axis is 'X':
if axis == 'X':
sha.mirror('X', (px, py))
self.app.inform.emit('[success] %s...' %
_('Flip on the Y axis done'))
elif axis is 'Y':
elif axis == 'Y':
sha.mirror('Y', (px, py))
self.app.inform.emit('[success] %s' %
_('Flip on the X axis done'))
@ -1368,9 +1368,9 @@ class TransformEditorTool(FlatCAMTool):
yminimal = min(yminlist)
for sha in shape_list:
if axis is 'X':
if axis == 'X':
sha.skew(num, 0, point=(xminimal, yminimal))
elif axis is 'Y':
elif axis == 'Y':
sha.skew(0, num, point=(xminimal, yminimal))
self.draw_app.replot()
@ -1449,9 +1449,9 @@ class TransformEditorTool(FlatCAMTool):
with self.app.proc_container.new(_("Applying Offset")):
try:
for sha in shape_list:
if axis is 'X':
if axis == 'X':
sha.offset((num, 0))
elif axis is 'Y':
elif axis == 'Y':
sha.offset((0, num))
self.draw_app.replot()

View File

@ -4254,7 +4254,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
self.app.log.debug("on_tool_select('%s')" % tool)
if self.last_aperture_selected is None and current_tool is not 'select':
if self.last_aperture_selected is None and current_tool != 'select':
# self.draw_app.select_tool('select')
self.complete = True
current_tool = 'select'
@ -5867,7 +5867,7 @@ class TransformEditorTool(FlatCAMTool):
# execute mirroring
for sel_el_shape in elem_list:
sel_el = sel_el_shape.geo
if axis is 'X':
if axis == 'X':
if 'solid' in sel_el:
sel_el['solid'] = affinity.scale(sel_el['solid'], xfact=1, yfact=-1, origin=(px, py))
if 'follow' in sel_el:
@ -5876,7 +5876,7 @@ class TransformEditorTool(FlatCAMTool):
sel_el['clear'] = affinity.scale(sel_el['clear'], xfact=1, yfact=-1, origin=(px, py))
self.app.inform.emit('[success] %s...' %
_('Flip on the Y axis done'))
elif axis is 'Y':
elif axis == 'Y':
if 'solid' in sel_el:
sel_el['solid'] = affinity.scale(sel_el['solid'], xfact=-1, yfact=1, origin=(px, py))
if 'follow' in sel_el:
@ -5924,14 +5924,14 @@ class TransformEditorTool(FlatCAMTool):
for sel_el_shape in elem_list:
sel_el = sel_el_shape.geo
if axis is 'X':
if axis == 'X':
if 'solid' in sel_el:
sel_el['solid'] = affinity.skew(sel_el['solid'], num, 0, origin=(xminimal, yminimal))
if 'follow' in sel_el:
sel_el['follow'] = affinity.skew(sel_el['follow'], num, 0, origin=(xminimal, yminimal))
if 'clear' in sel_el:
sel_el['clear'] = affinity.skew(sel_el['clear'], num, 0, origin=(xminimal, yminimal))
elif axis is 'Y':
elif axis == 'Y':
if 'solid' in sel_el:
sel_el['solid'] = affinity.skew(sel_el['solid'], 0, num, origin=(xminimal, yminimal))
if 'follow' in sel_el:
@ -6031,14 +6031,14 @@ class TransformEditorTool(FlatCAMTool):
try:
for sel_el_shape in elem_list:
sel_el = sel_el_shape.geo
if axis is 'X':
if axis == 'X':
if 'solid' in sel_el:
sel_el['solid'] = affinity.translate(sel_el['solid'], num, 0)
if 'follow' in sel_el:
sel_el['follow'] = affinity.translate(sel_el['follow'], num, 0)
if 'clear' in sel_el:
sel_el['clear'] = affinity.translate(sel_el['clear'], num, 0)
elif axis is 'Y':
elif axis == 'Y':
if 'solid' in sel_el:
sel_el['solid'] = affinity.translate(sel_el['solid'], 0, num)
if 'follow' in sel_el:

View File

@ -376,7 +376,7 @@ class FloatEntry(QtWidgets.QLineEdit):
evaled = eval(raw)
return float(evaled)
except Exception as e:
if raw is not '':
if raw != '':
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
return None
@ -422,7 +422,7 @@ class FloatEntry2(QtWidgets.QLineEdit):
evaled = eval(raw)
return float(evaled)
except Exception as e:
if raw is not '':
if raw != '':
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
return None
@ -602,7 +602,7 @@ class EvalEntry(QtWidgets.QLineEdit):
try:
evaled = eval(raw)
except Exception as e:
if raw is not '':
if raw != '':
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
return None
return evaled
@ -642,7 +642,7 @@ class EvalEntry2(QtWidgets.QLineEdit):
try:
evaled = eval(raw)
except Exception as e:
if raw is not '':
if raw != '':
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
return None
return evaled

View File

@ -967,7 +967,7 @@ class Excellon(Geometry):
for drill in self.drills:
# poly = drill['point'].buffer(self.tools[drill['tool']]["C"]/2.0)
if drill['tool'] is '':
if drill['tool'] == '':
self.app.inform.emit('[WARNING] %s' %
_("Excellon.create_geometry() -> a drill location was skipped "
"due of not having a tool associated.\n"

View File

@ -718,7 +718,7 @@ class Gerber(Geometry):
# so it can be processed by FlatCAM.
# But first test to see if the aperture type is "aperture macro". In that case
# we should not test for "size" key as it does not exist in this case.
if self.apertures[current_aperture]["type"] is not "AM":
if self.apertures[current_aperture]["type"] != "AM":
if self.apertures[current_aperture]["size"] == 0:
self.apertures[current_aperture]["size"] = 1e-12
# log.debug(self.apertures[current_aperture])

View File

@ -606,7 +606,7 @@ class DblSidedTool(FlatCAMTool):
xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
dia = float(self.drill_dia.get_value())
if dia is '':
if dia == '':
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("No value or wrong format in Drill Dia entry. Add it and retry."))
return

View File

@ -504,7 +504,7 @@ class Panelize(FlatCAMTool):
obj_fin.solid_geometry = []
for option in panel_obj.options:
if option is not 'name':
if option != 'name':
try:
obj_fin.options[option] = panel_obj.options[option]
except KeyError:

View File

@ -349,7 +349,7 @@ class Properties(FlatCAMTool):
# Options items
for option in obj.options:
if option is 'name':
if option == 'name':
continue
self.treeWidget.addChild(options, [str(option), str(obj.options[option])], True)

View File

@ -1130,14 +1130,14 @@ class RulesCheck(FlatCAMTool):
if self.trace_size_cb.get_value():
copper_list = []
copper_name_1 = self.copper_t_object.currentText()
if copper_name_1 is not '' and self.copper_t_cb.get_value():
if copper_name_1 != '' and self.copper_t_cb.get_value():
elem_dict = {}
elem_dict['name'] = deepcopy(copper_name_1)
elem_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_name_1).apertures)
copper_list.append(elem_dict)
copper_name_2 = self.copper_b_object.currentText()
if copper_name_2 is not '' and self.copper_b_cb.get_value():
if copper_name_2 !='' and self.copper_b_cb.get_value():
elem_dict = {}
elem_dict['name'] = deepcopy(copper_name_2)
elem_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_name_2).apertures)
@ -1162,7 +1162,7 @@ class RulesCheck(FlatCAMTool):
copper_t_obj = self.copper_t_object.currentText()
copper_t_dict = {}
if copper_t_obj is not '':
if copper_t_obj != '':
copper_t_dict['name'] = deepcopy(copper_t_obj)
copper_t_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_t_obj).apertures)
@ -1173,7 +1173,7 @@ class RulesCheck(FlatCAMTool):
if self.copper_b_cb.get_value():
copper_b_obj = self.copper_b_object.currentText()
copper_b_dict = {}
if copper_b_obj is not '':
if copper_b_obj != '':
copper_b_dict['name'] = deepcopy(copper_b_obj)
copper_b_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_b_obj).apertures)
@ -1195,17 +1195,17 @@ class RulesCheck(FlatCAMTool):
outline_dict = {}
copper_top = self.copper_t_object.currentText()
if copper_top is not '' and self.copper_t_cb.get_value():
if copper_top != '' and self.copper_t_cb.get_value():
top_dict['name'] = deepcopy(copper_top)
top_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_top).apertures)
copper_bottom = self.copper_b_object.currentText()
if copper_bottom is not '' and self.copper_b_cb.get_value():
if copper_bottom != '' and self.copper_b_cb.get_value():
bottom_dict['name'] = deepcopy(copper_bottom)
bottom_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_bottom).apertures)
copper_outline = self.outline_object.currentText()
if copper_outline is not '' and self.out_cb.get_value():
if copper_outline != '' and self.out_cb.get_value():
outline_dict['name'] = deepcopy(copper_outline)
outline_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_outline).apertures)
@ -1257,7 +1257,7 @@ class RulesCheck(FlatCAMTool):
if self.ss_t_cb.get_value():
silk_obj = self.ss_t_object.currentText()
if silk_obj is not '':
if silk_obj != '':
silk_dict['name'] = deepcopy(silk_obj)
silk_dict['apertures'] = deepcopy(self.app.collection.get_by_name(silk_obj).apertures)
@ -1267,7 +1267,7 @@ class RulesCheck(FlatCAMTool):
_("TOP -> Silk to Silk clearance"))))
if self.ss_b_cb.get_value():
silk_obj = self.ss_b_object.currentText()
if silk_obj is not '':
if silk_obj != '':
silk_dict['name'] = deepcopy(silk_obj)
silk_dict['apertures'] = deepcopy(self.app.collection.get_by_name(silk_obj).apertures)
@ -1295,25 +1295,25 @@ class RulesCheck(FlatCAMTool):
bottom_sm = False
silk_top = self.ss_t_object.currentText()
if silk_top is not '' and self.ss_t_cb.get_value():
if silk_top != '' and self.ss_t_cb.get_value():
silk_t_dict['name'] = deepcopy(silk_top)
silk_t_dict['apertures'] = deepcopy(self.app.collection.get_by_name(silk_top).apertures)
top_ss = True
silk_bottom = self.ss_b_object.currentText()
if silk_bottom is not '' and self.ss_b_cb.get_value():
if silk_bottom != '' and self.ss_b_cb.get_value():
silk_b_dict['name'] = deepcopy(silk_bottom)
silk_b_dict['apertures'] = deepcopy(self.app.collection.get_by_name(silk_bottom).apertures)
bottom_ss = True
sm_top = self.sm_t_object.currentText()
if sm_top is not '' and self.sm_t_cb.get_value():
if sm_top != '' and self.sm_t_cb.get_value():
sm_t_dict['name'] = deepcopy(sm_top)
sm_t_dict['apertures'] = deepcopy(self.app.collection.get_by_name(sm_top).apertures)
top_sm = True
sm_bottom = self.sm_b_object.currentText()
if sm_bottom is not '' and self.sm_b_cb.get_value():
if sm_bottom != '' and self.sm_b_cb.get_value():
sm_b_dict['name'] = deepcopy(sm_bottom)
sm_b_dict['apertures'] = deepcopy(self.app.collection.get_by_name(sm_bottom).apertures)
bottom_sm = True
@ -1358,17 +1358,17 @@ class RulesCheck(FlatCAMTool):
outline_dict = {}
silk_top = self.ss_t_object.currentText()
if silk_top is not '' and self.ss_t_cb.get_value():
if silk_top != '' and self.ss_t_cb.get_value():
top_dict['name'] = deepcopy(silk_top)
top_dict['apertures'] = deepcopy(self.app.collection.get_by_name(silk_top).apertures)
silk_bottom = self.ss_b_object.currentText()
if silk_bottom is not '' and self.ss_b_cb.get_value():
if silk_bottom != '' and self.ss_b_cb.get_value():
bottom_dict['name'] = deepcopy(silk_bottom)
bottom_dict['apertures'] = deepcopy(self.app.collection.get_by_name(silk_bottom).apertures)
copper_outline = self.outline_object.currentText()
if copper_outline is not '' and self.out_cb.get_value():
if copper_outline != '' and self.out_cb.get_value():
outline_dict['name'] = deepcopy(copper_outline)
outline_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_outline).apertures)
@ -1421,7 +1421,7 @@ class RulesCheck(FlatCAMTool):
if self.sm_t_cb.get_value():
solder_obj = self.sm_t_object.currentText()
if solder_obj is not '':
if solder_obj != '':
sm_dict['name'] = deepcopy(solder_obj)
sm_dict['apertures'] = deepcopy(self.app.collection.get_by_name(solder_obj).apertures)
@ -1431,7 +1431,7 @@ class RulesCheck(FlatCAMTool):
_("TOP -> Minimum Solder Mask Sliver"))))
if self.sm_b_cb.get_value():
solder_obj = self.sm_b_object.currentText()
if solder_obj is not '':
if solder_obj != '':
sm_dict['name'] = deepcopy(solder_obj)
sm_dict['apertures'] = deepcopy(self.app.collection.get_by_name(solder_obj).apertures)
@ -1454,23 +1454,23 @@ class RulesCheck(FlatCAMTool):
exc_2_dict = {}
copper_top = self.copper_t_object.currentText()
if copper_top is not '' and self.copper_t_cb.get_value():
if copper_top != '' and self.copper_t_cb.get_value():
top_dict['name'] = deepcopy(copper_top)
top_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_top).apertures)
copper_bottom = self.copper_b_object.currentText()
if copper_bottom is not '' and self.copper_b_cb.get_value():
if copper_bottom != '' and self.copper_b_cb.get_value():
bottom_dict['name'] = deepcopy(copper_bottom)
bottom_dict['apertures'] = deepcopy(self.app.collection.get_by_name(copper_bottom).apertures)
excellon_1 = self.e1_object.currentText()
if excellon_1 is not '' and self.e1_cb.get_value():
if excellon_1 != '' and self.e1_cb.get_value():
exc_1_dict['name'] = deepcopy(excellon_1)
exc_1_dict['tools'] = deepcopy(
self.app.collection.get_by_name(excellon_1).tools)
excellon_2 = self.e2_object.currentText()
if excellon_2 is not '' and self.e2_cb.get_value():
if excellon_2 != '' and self.e2_cb.get_value():
exc_2_dict['name'] = deepcopy(excellon_2)
exc_2_dict['tools'] = deepcopy(
self.app.collection.get_by_name(excellon_2).tools)
@ -1515,14 +1515,14 @@ class RulesCheck(FlatCAMTool):
if self.clearance_d2d_cb.get_value():
exc_list = []
exc_name_1 = self.e1_object.currentText()
if exc_name_1 is not '' and self.e1_cb.get_value():
if exc_name_1 != '' and self.e1_cb.get_value():
elem_dict = {}
elem_dict['name'] = deepcopy(exc_name_1)
elem_dict['tools'] = deepcopy(self.app.collection.get_by_name(exc_name_1).tools)
exc_list.append(elem_dict)
exc_name_2 = self.e2_object.currentText()
if exc_name_2 is not '' and self.e2_cb.get_value():
if exc_name_2 != '' and self.e2_cb.get_value():
elem_dict = {}
elem_dict['name'] = deepcopy(exc_name_2)
elem_dict['tools'] = deepcopy(self.app.collection.get_by_name(exc_name_2).tools)
@ -1535,14 +1535,14 @@ class RulesCheck(FlatCAMTool):
if self.drill_size_cb.get_value():
exc_list = []
exc_name_1 = self.e1_object.currentText()
if exc_name_1 is not '' and self.e1_cb.get_value():
if exc_name_1 != '' and self.e1_cb.get_value():
elem_dict = {}
elem_dict['name'] = deepcopy(exc_name_1)
elem_dict['tools'] = deepcopy(self.app.collection.get_by_name(exc_name_1).tools)
exc_list.append(elem_dict)
exc_name_2 = self.e2_object.currentText()
if exc_name_2 is not '' and self.e2_cb.get_value():
if exc_name_2 != '' and self.e2_cb.get_value():
elem_dict = {}
elem_dict['name'] = deepcopy(exc_name_2)
elem_dict['tools'] = deepcopy(self.app.collection.get_by_name(exc_name_2).tools)

View File

@ -760,7 +760,7 @@ class ToolTransform(FlatCAMTool):
if isinstance(sel_obj, FlatCAMCNCjob):
self.app.inform.emit(_("CNCJob objects can't be mirrored/flipped."))
else:
if axis is 'X':
if axis == 'X':
sel_obj.mirror('X', (px, py))
# add information to the object that it was changed and how much
# the axis is reversed because of the reference
@ -770,7 +770,7 @@ class ToolTransform(FlatCAMTool):
sel_obj.options['mirror_y'] = True
self.app.inform.emit('[success] %s...' %
_('Flip on the Y axis done'))
elif axis is 'Y':
elif axis == 'Y':
sel_obj.mirror('Y', (px, py))
# add information to the object that it was changed and how much
# the axis is reversed because of the reference
@ -820,11 +820,11 @@ class ToolTransform(FlatCAMTool):
if isinstance(sel_obj, FlatCAMCNCjob):
self.app.inform.emit(_("CNCJob objects can't be skewed."))
else:
if axis is 'X':
if axis == 'X':
sel_obj.skew(num, 0, point=(xminimal, yminimal))
# add information to the object that it was changed and how much
sel_obj.options['skew_x'] = num
elif axis is 'Y':
elif axis == 'Y':
sel_obj.skew(0, num, point=(xminimal, yminimal))
# add information to the object that it was changed and how much
sel_obj.options['skew_y'] = num
@ -906,11 +906,11 @@ class ToolTransform(FlatCAMTool):
if isinstance(sel_obj, FlatCAMCNCjob):
self.app.inform.emit(_("CNCJob objects can't be offset."))
else:
if axis is 'X':
if axis == 'X':
sel_obj.offset((num, 0))
# add information to the object that it was changed and how much
sel_obj.options['offset_x'] = num
elif axis is 'Y':
elif axis == 'Y':
sel_obj.offset((0, num))
# add information to the object that it was changed and how much
sel_obj.options['offset_y'] = num

View File

@ -185,7 +185,7 @@ class TclCommandPanelize(TclCommand):
obj_fin.solid_geometry = []
for option in obj.options:
if option is not 'name':
if option != 'name':
try:
obj_fin.options[option] = obj.options[option]
except Exception as e: