Get rid of some lintian complaints from github Python linter.

While working on https://github.com/FreeCAD/FreeCAD/pull/9867 I noticed my patch
showed up with a lot of linting issues in code I did not touch, to a point
where the view was very cluttered by lintian issues.  Here is my
try to reduce the number of issues discovered by the linter.  Some
issues are left, as I fail to see how to sensibly reduce the number of
parameters or local variable used.
This commit is contained in:
Petter Reinholdtsen
2023-07-06 17:51:04 +02:00
parent 85ff637c7c
commit 074749ba25

View File

@@ -20,7 +20,8 @@
# * *
# ***************************************************************************
"""Post Process command that will make use of the Output File and Post Processor entries in PathJob """
"""Post Process command that will make use of the Output File and Post
Processor entries in PathJob """
import FreeCAD
@@ -28,7 +29,7 @@ import FreeCADGui
import Path
import Path.Base.Util as PathUtil
import Path.Main.Job as PathJob
import PathScripts.PathUtils as PathUtils
from PathScripts import PathUtils
import os
import re
@@ -152,6 +153,8 @@ def processFileNameSubstitutions(
def resolveFileName(job, subpartname, sequencenumber):
"""Generate the file name to use as output."""
Path.Log.track(subpartname, sequencenumber)
validPathSubstitutions = ["D", "d", "M", "j"]
@@ -163,8 +166,9 @@ def resolveFileName(job, subpartname, sequencenumber):
# Override with document default if it exists
if job.PostProcessorOutputFile:
matchstring = job.PostProcessorOutputFile
candidateOutputPath, candidateFilename = os.path.split(matchstring)
candidateOutputPath, candidateFilename = os.path.split(
job.PostProcessorOutputFile
)
if candidateOutputPath:
outputpath = candidateOutputPath
@@ -172,7 +176,7 @@ def resolveFileName(job, subpartname, sequencenumber):
if candidateFilename:
filename, ext = os.path.splitext(candidateFilename)
# Strip any invalid substitutions from the ouputpath
# Strip any invalid substitutions from the outputpath
for match in re.findall("%(.)", outputpath):
if match not in validPathSubstitutions:
outputpath = outputpath.replace(f"%{match}", "")
@@ -229,9 +233,9 @@ def resolveFileName(job, subpartname, sequencenumber):
n = 1
if nr.isdigit():
n = int(nr)
while os.path.isfile("%s%03d%s" % (fn, n, ext)):
while os.path.isfile(f"{fn}{n:03d}{ext}"):
n = n + 1
fullPath = "%s%03d%s" % (fn, n, ext)
fullPath = f"{fn}{n:03d}{ext}"
if openDialog:
foo = QtGui.QFileDialog.getSaveFileName(