PathOp PEP8 Formatting Fixes

This commit is contained in:
Daniel Wood
2020-05-09 09:02:16 +01:00
parent 73f3585e57
commit 3a65a764e3

View File

@@ -43,13 +43,13 @@ __url__ = "http://www.freecadweb.org"
__doc__ = "Base class and properties implementation for all Path operations."
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule()
# Qt translation handling
def translate(context, text, disambig=None):
return QtCore.QCoreApplication.translate(context, text, disambig)
FeatureTool = 0x0001 # ToolController
FeatureDepths = 0x0002 # FinalDepth, StartDepth
FeatureHeights = 0x0004 # ClearanceHeight, SafeHeight
@@ -89,7 +89,7 @@ class ObjectOp(object):
FeatureBaseFaces ... Base geometry support for faces
FeatureBasePanels ... Base geometry support for Arch.Panels
FeatureLocations ... Base location support
FeatureCoolant ... Support for operation coolant
FeatureCoolant ... Support for operation coolant
The base class handles all base API and forwards calls to subclasses with
an op prefix. For instance, an op is not expected to overwrite onChanged(),
@@ -140,7 +140,7 @@ class ObjectOp(object):
if FeatureCoolant & features:
obj.addProperty("App::PropertyString", "CoolantMode", "Path", QtCore.QT_TRANSLATE_NOOP("PathOp", "Coolant mode for this operation"))
if FeatureDepths & features:
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Starting Depth of Tool- first cut depth in Z"))
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("PathOp", "Final Depth of Tool- lowest value in Z"))
@@ -194,7 +194,7 @@ class ObjectOp(object):
for op in ['OpStartDepth', 'OpFinalDepth', 'OpToolDiameter', 'CycleTime']:
if hasattr(obj, op):
obj.setEditorMode(op, 1) # read-only
obj.setEditorMode(op, 1) # read-only
if FeatureDepths & features:
if FeatureNoFinalDepth & features:
@@ -255,12 +255,12 @@ class ObjectOp(object):
def initOperation(self, obj):
'''initOperation(obj) ... implement to create additional properties.
Should be overwritten by subclasses.'''
pass # pylint: disable=unnecessary-pass
pass # pylint: disable=unnecessary-pass
def opOnDocumentRestored(self, obj):
'''opOnDocumentRestored(obj) ... implement if an op needs special handling like migrating the data model.
Should be overwritten by subclasses.'''
pass # pylint: disable=unnecessary-pass
pass # pylint: disable=unnecessary-pass
def opOnChanged(self, obj, prop):
'''opOnChanged(obj, prop) ... overwrite to process property changes.
@@ -269,24 +269,24 @@ class ObjectOp(object):
distinguish between assigning a different value and assigning the same
value again.
Can safely be overwritten by subclasses.'''
pass # pylint: disable=unnecessary-pass
pass # pylint: disable=unnecessary-pass
def opSetDefaultValues(self, obj, job):
'''opSetDefaultValues(obj, job) ... overwrite to set initial default values.
Called after the receiver has been fully created with all properties.
Can safely be overwritten by subclasses.'''
pass # pylint: disable=unnecessary-pass
pass # pylint: disable=unnecessary-pass
def opUpdateDepths(self, obj):
'''opUpdateDepths(obj) ... overwrite to implement special depths calculation.
Can safely be overwritten by subclass.'''
pass # pylint: disable=unnecessary-pass
pass # pylint: disable=unnecessary-pass
def opExecute(self, obj):
'''opExecute(obj) ... called whenever the receiver needs to be recalculated.
See documentation of execute() for a list of base functionality provided.
Should be overwritten by subclasses.'''
pass # pylint: disable=unnecessary-pass
pass # pylint: disable=unnecessary-pass
def opRejectAddBase(self, obj, base, sub):
'''opRejectAddBase(base, sub) ... if op returns True the addition of the feature is prevented.
@@ -297,12 +297,11 @@ class ObjectOp(object):
def onChanged(self, obj, prop):
'''onChanged(obj, prop) ... base implementation of the FC notification framework.
Do not overwrite, overwrite opOnChanged() instead.'''
if not 'Restore' in obj.State and prop in ['Base', 'StartDepth', 'FinalDepth']:
if 'Restore' not in obj.State and prop in ['Base', 'StartDepth', 'FinalDepth']:
self.updateDepths(obj, True)
self.opOnChanged(obj, prop)
def applyExpression(self, obj, prop, expr):
'''applyExpression(obj, prop, expr) ... set expression expr on obj.prop if expr is set'''
if expr:
@@ -483,7 +482,6 @@ class ObjectOp(object):
obj.Path = path
return
if not self._setBaseAndStock(obj):
return
@@ -505,7 +503,7 @@ class ObjectOp(object):
if not tool or float(tool.Diameter) == 0:
FreeCAD.Console.PrintError("No Tool found or diameter is zero. We need a tool to build a Path.")
return
self.radius = float(tool.Diameter) /2
self.radius = float(tool.Diameter) / 2
self.tool = tool
obj.OpToolDiameter = tool.Diameter
@@ -519,7 +517,7 @@ class ObjectOp(object):
if obj.Comment:
self.commandlist.append(Path.Command("(%s)" % obj.Comment))
result = self.opExecute(obj) # pylint: disable=assignment-from-no-return
result = self.opExecute(obj) # pylint: disable=assignment-from-no-return
if FeatureHeights & self.opFeatures(obj):
# Let's finish by rapid to clearance...just for safety
@@ -551,13 +549,13 @@ class ObjectOp(object):
if hRapidrate == 0 or vRapidrate == 0:
FreeCAD.Console.PrintWarning("Add Tool Controller Rapid Speeds on the SetupSheet for more accurate cycle times.\n")
## get the cycle time in seconds
# Get the cycle time in seconds
seconds = obj.Path.getCycleTime(hFeedrate, vFeedrate, hRapidrate, vRapidrate)
if not seconds:
return translate('PathGui', 'Cycletime Error')
## convert the cycle time to a HH:MM:SS format
# Convert the cycle time to a HH:MM:SS format
cycleTime = time.strftime("%H:%M:%S", time.gmtime(seconds))
return cycleTime
@@ -578,11 +576,11 @@ class ObjectOp(object):
for p, el in baselist:
if p == base and sub in el:
PathLog.notice((translate("Path", "Base object %s.%s already in the list")+"\n") % (base.Label, sub))
PathLog.notice((translate("Path", "Base object %s.%s already in the list") + "\n") % (base.Label, sub))
return
if not self.opRejectAddBase(obj, base, sub):
baselist.append((base, sub))
obj.Base = baselist
else:
PathLog.notice((translate("Path", "Base object %s.%s rejected by operation")+"\n") % (base.Label, sub))
PathLog.notice((translate("Path", "Base object %s.%s rejected by operation") + "\n") % (base.Label, sub))