From ad88b6af7614da63120ab412b6d58d0be3f13160 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 23 Apr 2019 09:13:16 +0200 Subject: [PATCH] Material, editor and main module, code formating --- src/Mod/Material/Material.py | 8 +++++--- src/Mod/Material/MaterialEditor.py | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Mod/Material/Material.py b/src/Mod/Material/Material.py index aff7229402..d62548ca39 100644 --- a/src/Mod/Material/Material.py +++ b/src/Mod/Material/Material.py @@ -116,7 +116,8 @@ def getMaterialAttributeStructure(withSpaces=None): '''''' # material properties - # see the following resources in the FreeCAD wiki for more information about the material specific properties: + # see the following resources in the FreeCAD wiki for more information + # about the material specific properties: # https://www.freecadweb.org/wiki/Material_data_model # https://www.freecadweb.org/wiki/Material @@ -127,7 +128,8 @@ def getMaterialAttributeStructure(withSpaces=None): tree = ElementTree.parse(infile) if withSpaces: - # on attributes, add a space before a capital letter, will be used for better display in the ui + # on attributes, add a space before a capital letter + # will be used for better display in the ui import re root = tree.getroot() for group in root.getchildren(): @@ -143,7 +145,7 @@ def read_cards_from_path(cards_path): from os.path import isfile, join, basename, splitext from importFCMat import read only_files = [f for f in listdir(cards_path) if isfile(join(cards_path, f))] - mat_files = [f for f in only_files if basename(splitext(f)[1]) == '.FCMat' or basename(splitext(f)[1]) == '.fcmat'] + mat_files = [f for f in only_files if basename(splitext(f)[1]).upper() == '.FCMAT'] # print(mat_files) mat_cards = [] for f in sorted(mat_files): diff --git a/src/Mod/Material/MaterialEditor.py b/src/Mod/Material/MaterialEditor.py index 0876f3cc5e..b9cde2a69a 100644 --- a/src/Mod/Material/MaterialEditor.py +++ b/src/Mod/Material/MaterialEditor.py @@ -197,7 +197,9 @@ class MaterialEditor: self.updateContents(d) def getMaterialResources(self): - self.fem_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Material/Resources") + self.fem_prefs = FreeCAD.ParamGet( + "User parameter:BaseApp/Preferences/Mod/Material/Resources" + ) use_built_in_materials = self.fem_prefs.GetBool("UseBuiltInMaterials", True) use_mat_from_config_dir = self.fem_prefs.GetBool("UseMaterialsFromConfigDir", True) use_mat_from_custom_dir = self.fem_prefs.GetBool("UseMaterialsFromCustomDir", True) @@ -207,7 +209,10 @@ class MaterialEditor: # FreeCAD returns paths with / at the end, thus not os.sep is needed on first + self.resources = [] if use_built_in_materials: - self.resources.append(FreeCAD.getResourceDir() + "Mod" + os.sep + "Material" + os.sep + "StandardMaterial") + res_dir = FreeCAD.getResourceDir() + self.resources.append( + res_dir + "Mod" + os.sep + "Material" + os.sep + "StandardMaterial" + ) if use_mat_from_config_dir: self.resources.append(FreeCAD.ConfigGet("UserAppData") + "Material") if use_mat_from_custom_dir: