- some PEP8 corrections

This commit is contained in:
Marius Stanciu
2019-07-15 01:16:02 +03:00
parent 43cb92e1d8
commit 7c0a8b73e3
9 changed files with 220 additions and 222 deletions

View File

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
=================================================
15.07.2019
- some PEP8 corrections
13.07.2019
- fixed a possible issue in Gerber Object class

View File

@@ -43,7 +43,7 @@ class ToolCalculator(FlatCAMTool):
self.layout.addWidget(title_label)
# #####################
# ## Units Calculator # ##
# ## Units Calculator #
# #####################
self.unists_spacer_label = QtWidgets.QLabel(" ")
@@ -75,11 +75,9 @@ class ToolCalculator(FlatCAMTool):
grid_units_layout.addWidget(self.mm_entry, 1, 0)
grid_units_layout.addWidget(self.inch_entry, 1, 1)
########################## ##
# ##############################
# ## V-shape Tool Calculator ###
########################## ##
# ##############################
self.v_shape_spacer_label = QtWidgets.QLabel(" ")
self.layout.addWidget(self.v_shape_spacer_label)
@@ -121,7 +119,6 @@ class ToolCalculator(FlatCAMTool):
"In the CNCJob section it is called >Tool dia<."))
# self.effectiveToolDia_entry.setEnabled(False)
form_layout.addRow(self.tipDia_label, self.tipDia_entry)
form_layout.addRow(self.tipAngle_label, self.tipAngle_entry)
form_layout.addRow(self.cutDepth_label, self.cutDepth_entry)
@@ -138,10 +135,9 @@ class ToolCalculator(FlatCAMTool):
form_layout.addRow(self.empty_label, self.calculate_vshape_button)
################################## ##
# ## ElectroPlating Tool Calculator # ##
################################## ##
# ####################################
# ## ElectroPlating Tool Calculator ##
# ####################################
self.plate_spacer_label = QtWidgets.QLabel(" ")
self.layout.addWidget(self.plate_spacer_label)
@@ -177,7 +173,6 @@ class ToolCalculator(FlatCAMTool):
self.cdensity_label.setToolTip(_("Current density to pass through the board. \n"
"In Amps per Square Feet ASF."))
self.growth_label = QtWidgets.QLabel(_("Copper Growth:"))
self.growth_entry = FCEntry()
# self.growth_entry.setFixedWidth(70)
@@ -223,6 +218,8 @@ class ToolCalculator(FlatCAMTool):
self.layout.addStretch()
self.units = ''
# ## Signals
self.cutDepth_entry.textChanged.connect(self.on_calculate_tool_dia)
self.cutDepth_entry.editingFinished.connect(self.on_calculate_tool_dia)

View File

@@ -643,7 +643,6 @@ class CutOut(FlatCAMTool):
geo_obj.solid_geometry = deepcopy(solid_geo)
geo_obj.options['cnctooldia'] = str(dia)
outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init)

View File

@@ -6,9 +6,9 @@ from PyQt5 import QtCore
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -188,7 +188,6 @@ class DblSidedTool(FlatCAMTool):
self.box_combo.hide()
self.box_combo_type.hide()
# ## Alignment holes
self.ah_label = QtWidgets.QLabel("<b>%s</b>" % _('Alignment Drill Coordinates:'))
self.ah_label.setToolTip(
@@ -372,7 +371,8 @@ class DblSidedTool(FlatCAMTool):
# holes = self.alignment_holes.get_value()
holes = eval('[{}]'.format(self.alignment_holes.text()))
if not holes:
self.app.inform.emit(_("[WARNING_NOTCL] There are no Alignment Drill Coordinates to use. Add them and retry."))
self.app.inform.emit(_("[WARNING_NOTCL] There are no Alignment Drill Coordinates to use. "
"Add them and retry."))
return
drills = []
@@ -553,8 +553,4 @@ class DblSidedTool(FlatCAMTool):
self.box_combo.setCurrentIndex(0)
self.box_combo_type.setCurrentIndex(0)
self.drill_values = ""

View File

@@ -13,9 +13,9 @@ from PyQt5 import QtGui, QtCore, QtWidgets
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -221,13 +221,13 @@ class Film(FlatCAMTool):
def on_film_creation(self):
try:
name = self.tf_object_combo.currentText()
except:
except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Film and retry."))
return
try:
boxname = self.tf_box_combo.currentText()
except:
except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Box and retry."))
return

View File

@@ -13,9 +13,9 @@ from PyQt5 import QtGui, QtWidgets
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -191,19 +191,19 @@ class ToolImage(FlatCAMTool):
mask = []
self.app.log.debug("on_file_importimage()")
filter = "Image Files(*.BMP *.PNG *.JPG *.JPEG);;" \
_filter = "Image Files(*.BMP *.PNG *.JPG *.JPEG);;" \
"Bitmap File (*.BMP);;" \
"PNG File (*.PNG);;" \
"Jpeg File (*.JPG);;" \
"All Files (*.*)"
try:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Import IMAGE"),
directory=self.app.get_last_folder(), filter=filter)
directory=self.app.get_last_folder(), filter=_filter)
except TypeError:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Import IMAGE"), filter=filter)
filename = str(filename)
type = self.tf_type_obj_combo.get_value().lower()
type_obj = self.tf_type_obj_combo.get_value().lower()
dpi = self.dpi_entry.get_value()
mode = self.image_type.get_value()
mask = [self.mask_bw_entry.get_value(), self.mask_r_entry.get_value(), self.mask_g_entry.get_value(),
@@ -213,5 +213,5 @@ class ToolImage(FlatCAMTool):
self.app.inform.emit(_("Open cancelled."))
else:
self.app.worker_task.emit({'fcn': self.app.import_image,
'params': [filename, type, dpi, mode, mask]})
'params': [filename, type_obj, dpi, mode, mask]})
# self.import_svg(filename, "geometry")

View File

@@ -14,9 +14,9 @@ from math import sqrt
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -40,7 +40,6 @@ class Measurement(FlatCAMTool):
form_layout = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout)
self.units_label = QtWidgets.QLabel(_("Units:"))
self.units_label.setToolTip(_("Those are the units in which the distance is measured."))
self.units_value = QtWidgets.QLabel("%s" % str({'mm': "METRIC (mm)", 'in': "INCH (in)"}[self.units]))
@@ -73,12 +72,10 @@ class Measurement(FlatCAMTool):
self.distance_x_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.distance_x_entry.setToolTip(_("This is the distance measured over the X axis."))
self.distance_y_entry = FCEntry()
self.distance_y_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.distance_y_entry.setToolTip(_("This is the distance measured over the Y axis."))
self.total_distance_entry = FCEntry()
self.total_distance_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.total_distance_entry.setToolTip(_("This is the point to point Euclidian distance."))
@@ -110,6 +107,8 @@ class Measurement(FlatCAMTool):
self.rel_point2 = None
self.active = False
self.clicked_meas = None
self.meas_line = None
self.original_call_source = 'app'
@@ -312,7 +311,7 @@ class Measurement(FlatCAMTool):
# update utility geometry
if len(self.points) == 1:
self.utility_geometry(pos=pos)
except:
except Exception as e:
self.app.ui.position_label.setText("")
self.app.ui.rel_position_label.setText("")

View File

@@ -14,9 +14,9 @@ from copy import copy
import gettext
import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -97,7 +97,7 @@ class ToolMove(FlatCAMTool):
pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
if self.app.grid_status() is True:
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas
@@ -117,7 +117,7 @@ class ToolMove(FlatCAMTool):
self.delete_shape()
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
if self.app.grid_status() is True:
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas
@@ -143,7 +143,7 @@ class ToolMove(FlatCAMTool):
try:
sel_obj.replotApertures.emit()
except:
except Exception as e:
pass
# Update the object bounding box options
@@ -181,7 +181,7 @@ class ToolMove(FlatCAMTool):
pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
if self.app.grid_status() is True:
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else:
pos = pos_canvas

View File

@@ -14,9 +14,9 @@ import time
import gettext
import FlatCAMTranslation as fcTranslate
from shapely.geometry import base
import builtins
fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -344,8 +344,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
try:
dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
except:
log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> TOOLS -> NCC Tools.")
except Exception as e:
log.error("At least one tool diameter needed. "
"Verify in Edit -> Preferences -> TOOLS -> NCC Tools. %s" % str(e))
return
self.tooluid = 0
@@ -393,10 +394,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
for tooluid_key, tooluid_value in self.ncc_tools.items():
if float('%.4f' % tooluid_value['tooldia']) == tool_sorted:
tool_id += 1
id = QtWidgets.QTableWidgetItem('%d' % int(tool_id))
id.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
id_ = QtWidgets.QTableWidgetItem('%d' % int(tool_id))
id_.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
row_no = tool_id - 1
self.tools_table.setItem(row_no, 0, id) # Tool name/id
self.tools_table.setItem(row_no, 0, id_) # Tool name/id
# Make sure that the drill diameter when in MM is with no more than 2 decimals
# There are no drill bits in MM with more than 3 decimals diameter
@@ -486,7 +487,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
return
if tool_dia == 0:
self.app.inform.emit(_("[WARNING_NOTCL] Please enter a tool diameter with non-zero value, in Float format."))
self.app.inform.emit(_("[WARNING_NOTCL] Please enter a tool diameter with non-zero value, "
"in Float format."))
return
# construct a list of all 'tooluid' in the self.tools
@@ -568,7 +570,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
break
restore_dia_item = self.tools_table.item(row, 1)
restore_dia_item.setText(str(old_tool_dia))
self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. New diameter value is already in the Tool Table."))
self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. "
"New diameter value is already in the Tool Table."))
self.build_ui()
def on_tool_delete(self, rows_to_delete=None, all=None):
@@ -662,13 +665,14 @@ class NonCopperClear(FlatCAMTool, Gerber):
# Get source object.
try:
self.ncc_obj = self.app.collection.get_by_name(self.obj_name)
except:
except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name)
return "Could not retrieve object: %s" % self.obj_name
# Prepare non-copper polygons
try:
bounding_box = self.ncc_obj.solid_geometry.envelope.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre)
bounding_box = self.ncc_obj.solid_geometry.envelope.buffer(distance=margin,
join_style=base.JOIN_STYLE.mitre)
except AttributeError:
self.app.inform.emit(_("[ERROR_NOTCL] No Gerber file available."))
return
@@ -679,7 +683,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
empty = MultiPolygon([empty])
# clear non copper using standard algorithm
if clearing_method == False:
if clearing_method is False:
self.clear_non_copper(
empty=empty,
over=over,
@@ -736,7 +740,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
area = empty.buffer(-offset)
try:
area = area.difference(cleared)
except:
except Exception as e:
continue
# Transform area to MultiPolygon
@@ -758,8 +762,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
overlap=over, contour=contour, connect=connect)
if cp:
cleared_geo += list(cp.get_objects())
except:
log.warning("Polygon can not be cleared.")
except Exception as e:
log.warning("Polygon can not be cleared. %s" % str(e))
app_obj.poly_not_cleared = True
continue
@@ -973,4 +977,3 @@ class NonCopperClear(FlatCAMTool, Gerber):
def reset_fields(self):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))