- PEP8 changes and PyCharm suggestions

This commit is contained in:
Marius Stanciu
2020-11-12 20:47:43 +02:00
committed by Marius Stanciu
parent 9abe11ff42
commit dea7ce3028
63 changed files with 527 additions and 659 deletions

View File

@@ -10,7 +10,6 @@
# File modified by: Marius Stanciu #
# ##########################################################
from copy import deepcopy
from io import StringIO
from datetime import datetime
@@ -22,7 +21,7 @@ from matplotlib.backend_bases import KeyEvent as mpl_key_event
from camlib import CNCjob
from shapely.ops import unary_union
from shapely.geometry import Point, MultiPoint, Polygon, LineString, box
from shapely.geometry import Point, MultiPoint, box
import shapely.affinity as affinity
try:
from shapely.ops import voronoi_diagram
@@ -1910,7 +1909,6 @@ class CNCJobObject(FlatCAMObj, CNCjob):
"""
Handler activated by a button clicked when exporting GCode.
:param args:
:return:
"""
self.app.defaults.report_usage("cncjob_on_exportgcode_button")
@@ -1942,8 +1940,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.export_gcode_handler(filename, is_gcode=save_gcode)
def export_gcode_handler(self, filename, is_gcode=True, rename_object=True):
preamble = ''
postamble = ''
# preamble = ''
# postamble = ''
filename = str(filename)
if filename == '':

View File

@@ -249,8 +249,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
# add the data dictionary for each tool with the default values
self.tools[tool_no]['data'] = deepcopy(new_options)
drill_cnt = 0 # variable to store the nr of drills per tool
slot_cnt = 0 # variable to store the nr of slots per tool
# drill_cnt = 0 # variable to store the nr of drills per tool
# slot_cnt = 0 # variable to store the nr of slots per tool
# Find no of drills for the current tool
try:
@@ -907,7 +907,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
geo_obj.options['Tools_in_use'] = tool_table_items
geo_obj.options['type'] = 'Excellon Geometry'
geo_obj.options["cnctooldia"] = str(tooldia)
geo_obj.options["multidepth"] = self.app.defaults["geometry_multidepth"]
geo_obj.options["multidepth"] = app_obj.defaults["geometry_multidepth"]
geo_obj.solid_geometry = []
# in case that the tool used has the same diameter with the hole, and since the maximum resolution
@@ -1007,7 +1007,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
geo_obj.options['Tools_in_use'] = tool_table_items
geo_obj.options['type'] = 'Excellon Geometry'
geo_obj.options["cnctooldia"] = str(tooldia)
geo_obj.options["multidepth"] = self.app.defaults["geometry_multidepth"]
geo_obj.options["multidepth"] = app_obj.defaults["geometry_multidepth"]
geo_obj.solid_geometry = []
# in case that the tool used has the same diameter with the hole, and since the maximum resolution

View File

@@ -583,7 +583,7 @@ class GeometryObject(FlatCAMObj, Geometry):
_("Copy"), self.on_tool_copy,
icon=QtGui.QIcon(self.app.resource_location + "/copy16.png"))
self.ui.geo_tools_table.addContextMenu(
_("Delete"), lambda: self.on_tool_delete(all_tools=None),
_("Delete"), lambda: self.on_tool_delete(clicked_signal=None, all_tools=None),
icon=QtGui.QIcon(self.app.resource_location + "/trash16.png"))
# Show/Hide Advanced Options

View File

@@ -434,7 +434,7 @@ class GerberObject(FlatCAMObj, Gerber):
self.app.app_obj.new_object("geometry", name, geo_init)
def isolate(self, iso_type=None, geometry=None, dia=None, passes=None, overlap=None, outname=None, combine=None,
milling_type=None, follow=None, plot=True):
milling_type=None, plot=True):
"""
Creates an isolation routing geometry object in the project.
@@ -446,13 +446,12 @@ class GerberObject(FlatCAMObj, Gerber):
:param outname: Base name of the output object
:param combine: Boolean: if to combine passes in one resulting object in case of multiple passes
:param milling_type: type of milling: conventional or climbing
:param follow: Boolean: if to generate a 'follow' geometry
:param plot: Boolean: if to plot the resulting geometry object
:return: None
"""
if geometry is None:
work_geo = self.follow_geometry if follow is True else self.solid_geometry
work_geo = self.solid_geometry
else:
work_geo = geometry
@@ -555,7 +554,7 @@ class GerberObject(FlatCAMObj, Gerber):
# if milling type is climb then the move is counter-clockwise around features
mill_dir = 1 if milling_type == 'cl' else 0
geom = self.generate_envelope(iso_offset, mill_dir, geometry=work_geo, env_iso_type=iso_t,
follow=follow, nr_passes=nr_pass)
nr_passes=nr_pass)
if geom == 'fail':
if plot:
@@ -631,8 +630,7 @@ class GerberObject(FlatCAMObj, Gerber):
# if milling type is climb then the move is counter-clockwise around features
mill_dir = 1 if milling_type == 'cl' else 0
geom = self.generate_envelope(offset, mill_dir, geometry=work_geo, env_iso_type=iso_t,
follow=follow, nr_passes=i)
geom = self.generate_envelope(offset, mill_dir, geometry=work_geo, env_iso_type=iso_t, nr_passes=i)
if geom == 'fail':
if plot:
@@ -726,7 +724,7 @@ class GerberObject(FlatCAMObj, Gerber):
self.app.app_obj.new_object("geometry", iso_name, iso_init, plot=plot)
def generate_envelope(self, offset, invert, geometry=None, env_iso_type=2, follow=None, nr_passes=0):
def generate_envelope(self, offset, invert, geometry=None, env_iso_type=2, nr_passes=0):
# isolation_geometry produces an envelope that is going on the left of the geometry
# (the copper features). To leave the least amount of burrs on the features
# the tool needs to travel on the right side of the features (this is called conventional milling)
@@ -734,14 +732,11 @@ class GerberObject(FlatCAMObj, Gerber):
# the other passes overlap preceding ones and cut the left over copper. It is better for them
# to cut on the right side of the left over copper i.e on the left side of the features.
if follow:
geom = self.isolation_geometry(offset, geometry=geometry, follow=follow)
else:
try:
geom = self.isolation_geometry(offset, geometry=geometry, iso_type=env_iso_type, passes=nr_passes)
except Exception as e:
log.debug('GerberObject.isolate().generate_envelope() --> %s' % str(e))
return 'fail'
try:
geom = self.isolation_geometry(offset, geometry=geometry, iso_type=env_iso_type, passes=nr_passes)
except Exception as e:
log.debug('GerberObject.isolate().generate_envelope() --> %s' % str(e))
return 'fail'
if invert:
try:
@@ -783,7 +778,6 @@ class GerberObject(FlatCAMObj, Gerber):
follow_obj.options["cnctooldia"] = str(self.app.defaults["tools_iso_tooldia"])
follow_obj.solid_geometry = self.follow_geometry
# TODO: Do something if this is None. Offer changing name?
try:
self.app.app_obj.new_object("geometry", follow_name, follow_init)
except Exception as e: