FEM: utils, use snake case for new methods
This commit is contained in:
@@ -62,8 +62,8 @@ def run_analysis(doc, base_name, filepath=""):
|
||||
doc.saveAs(save_fc_file)
|
||||
|
||||
# get analysis workig dir
|
||||
from femtools.femutils import getBesideDir as getpath
|
||||
working_dir = getpath(solver)
|
||||
from femtools.femutils import get_beside_dir
|
||||
working_dir = get_beside_dir(solver)
|
||||
|
||||
# run analysis
|
||||
from femsolver.run import run_fem_solver
|
||||
|
||||
@@ -127,7 +127,7 @@ def _isPathValid(m, path):
|
||||
if setting == settings.BESIDE:
|
||||
if t == settings.BESIDE:
|
||||
base = os.path.split(m.directory.rstrip("/"))[0]
|
||||
return base == femutils.getBesideBase(m.solver)
|
||||
return base == femutils.get_beside_base(m.solver)
|
||||
return False
|
||||
if setting == settings.TEMPORARY:
|
||||
return t == settings.TEMPORARY
|
||||
@@ -135,7 +135,7 @@ def _isPathValid(m, path):
|
||||
if t == settings.CUSTOM:
|
||||
firstBase = os.path.split(m.directory.rstrip("/"))[0]
|
||||
customBase = os.path.split(firstBase)[0]
|
||||
return customBase == femutils.getCustomBase(m.solver)
|
||||
return customBase == femutils.get_custom_base(m.solver)
|
||||
return False
|
||||
|
||||
|
||||
@@ -145,13 +145,13 @@ def _createMachine(solver, path, testmode):
|
||||
if path is not None:
|
||||
_dirTypes[path] = None
|
||||
elif setting == settings.BESIDE:
|
||||
path = femutils.getBesideDir(solver)
|
||||
path = femutils.get_beside_dir(solver)
|
||||
_dirTypes[path] = settings.BESIDE
|
||||
elif setting == settings.TEMPORARY:
|
||||
path = femutils.getTempDir(solver)
|
||||
path = femutils.get_temp_dir(solver)
|
||||
_dirTypes[path] = settings.TEMPORARY
|
||||
elif setting == settings.CUSTOM:
|
||||
path = femutils.getCustomDir(solver)
|
||||
path = femutils.get_custom_dir(solver)
|
||||
_dirTypes[path] = settings.CUSTOM
|
||||
m = solver.Proxy.createMachine(solver, path, testmode)
|
||||
oldMachine = _machines.get(solver)
|
||||
|
||||
@@ -684,8 +684,8 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
"Dir \'{}\' doesn't exist or cannot be created.\n"
|
||||
.format(self.working_dir)
|
||||
)
|
||||
from femtools.femutils import getTempDir
|
||||
self.working_dir = getTempDir(self.solver)
|
||||
from femtools.femutils import get_temp_dir
|
||||
self.working_dir = get_temp_dir(self.solver)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Dir \'{}\' will be used instead.\n"
|
||||
.format(self.working_dir)
|
||||
|
||||
@@ -148,23 +148,23 @@ def get_pref_working_dir(solver_obj):
|
||||
# be aware beside could get an error if the document has not been saved
|
||||
dir_setting = settings.get_dir_setting()
|
||||
if dir_setting == settings.TEMPORARY:
|
||||
setting_working_dir = getTempDir(solver_obj)
|
||||
setting_working_dir = get_temp_dir(solver_obj)
|
||||
elif dir_setting == settings.BESIDE:
|
||||
setting_working_dir = getBesideDir(solver_obj)
|
||||
setting_working_dir = get_beside_dir(solver_obj)
|
||||
elif dir_setting == settings.CUSTOM:
|
||||
setting_working_dir = getCustomDir(solver_obj)
|
||||
setting_working_dir = get_custom_dir(solver_obj)
|
||||
else:
|
||||
setting_working_dir = ""
|
||||
return setting_working_dir
|
||||
|
||||
|
||||
def getTempDir(obj):
|
||||
def get_temp_dir(obj):
|
||||
from tempfile import mkdtemp
|
||||
return mkdtemp(prefix="fcfemsolv_")
|
||||
|
||||
|
||||
def getBesideDir(obj):
|
||||
base = getBesideBase(obj)
|
||||
def get_beside_dir(obj):
|
||||
base = get_beside_base(obj)
|
||||
specificPath = os.path.join(base, obj.Label)
|
||||
specificPath = getUniquePath(specificPath)
|
||||
if not os.path.isdir(specificPath):
|
||||
@@ -172,8 +172,8 @@ def getBesideDir(obj):
|
||||
return specificPath
|
||||
|
||||
|
||||
def getCustomDir(obj):
|
||||
base = getCustomBase(obj)
|
||||
def get_custom_dir(obj):
|
||||
base = get_custom_base(obj)
|
||||
specificPath = os.path.join(
|
||||
base, obj.Document.Name, obj.Label)
|
||||
specificPath = getUniquePath(specificPath)
|
||||
@@ -182,7 +182,7 @@ def getCustomDir(obj):
|
||||
return specificPath
|
||||
|
||||
|
||||
def getBesideBase(obj):
|
||||
def get_beside_base(obj):
|
||||
fcstdPath = obj.Document.FileName
|
||||
if fcstdPath == "":
|
||||
error_message = (
|
||||
@@ -201,7 +201,7 @@ def getBesideBase(obj):
|
||||
return os.path.splitext(fcstdPath)[0]
|
||||
|
||||
|
||||
def getCustomBase(solver):
|
||||
def get_custom_base(solver):
|
||||
path = settings.get_custom_dir()
|
||||
if not os.path.isdir(path):
|
||||
error_message = "Selected working directory doesn't exist."
|
||||
|
||||
Reference in New Issue
Block a user