Skip to content
Permalink
Browse files

Material: code formating, flake8

  • Loading branch information...
berndhahnebach authored and wwmayer committed Jan 4, 2019
1 parent b3de953 commit bc31a9afcd6914458f37d34796cbe2812776de35
Showing with 20 additions and 18 deletions.
  1. +1 −0 src/Mod/Material/Material.py
  2. +13 −12 src/Mod/Material/MaterialEditor.py
  3. +6 −6 src/Mod/Material/importFCMat.py
@@ -94,6 +94,7 @@ def exportFCMat(fileName, matDict):
configfile.write(Preamble)
Config.write(configfile)


def getMaterialAttributeStructure(withSpaces=None):

''''''
@@ -53,9 +53,9 @@ def __init__(self, obj=None, prop=None, material=None):
self.groups = []

# load the UI file from the same directory as this script
self.widget =\
FreeCADGui.PySideUic.loadUi(os.path.dirname(__file__) +
os.sep + "materials-editor.ui")
self.widget = FreeCADGui.PySideUic.loadUi(
os.path.dirname(__file__) + os.sep + "materials-editor.ui"
)

# additional UI fixes and tweaks
widget = self.widget
@@ -269,21 +269,21 @@ def reject(self):
def expandKey(self, key):
"adds spaces before caps in a KeyName"
nk = ""
for l in key:
if l.isupper():
for ln in key:
if ln.isupper():
if nk:
# this allows for series of caps, such as ProductURL
if not nk[-1].isupper():
nk += " "
nk += l
nk += ln
return nk

def collapseKey(self, key):
"removes the spaces in a Key Name"
nk = ""
for l in key:
if l != " ":
nk += l
for ln in key:
if ln != " ":
nk += ln
return nk

def addCustomProperty(self, key=None, value=None):
@@ -434,7 +434,7 @@ def savefile(self):
it = group.child(item.row(), 1)
name = it.text()
if sys.version_info.major < 3:
if isinstance(name,unicode):
if isinstance(name, unicode):
name = name.encode("utf8")
if not name:
name = "Material"
@@ -567,8 +567,9 @@ def matProperWidget(parent=None, Type="String", Units=None, Value=None,
widget = ui.createWidget("Gui::InputField")
if Units:
vv = string2tuple(Units)
unit = FreeCAD.Units.Unit(vv[0], vv[1], vv[2], vv[3],
vv[4], vv[5], vv[6], vv[7])
unit = FreeCAD.Units.Unit(
vv[0], vv[1], vv[2], vv[3], vv[4], vv[5], vv[6], vv[7]
)
quantity = FreeCAD.Units.Quantity(1, unit)
widget.setProperty('unit', quantity.getUserPreferred()[2])

@@ -35,7 +35,7 @@


# to distinguish python built-in open function from the one declared below
if open.__module__ in ['__builtin__','io']:
if open.__module__ in ['__builtin__', 'io']:
pythonopen = open


@@ -85,21 +85,21 @@ def read(filename):
filename = filename.encode(sys.getfilesystemencoding())
f = pythonopen(filename)
d = {}
l = 0
ln = 0
for line in f:
if l == 0:
if ln == 0:
d["CardName"] = line.split(";")[1].strip()
elif l == 1:
elif ln == 1:
d["AuthorAndLicense"] = line.split(";")[1].strip()
else:
if not line[0] in ";#[":
k = line.split("=")
if len(k) == 2:
v = k[1].strip()
if hasattr(v,"decode"):
if hasattr(v, "decode"):
v = v.decode('utf-8')
d[k[0].strip()] = v
l += 1
ln += 1
return d


0 comments on commit bc31a9a

Please sign in to comment.
You can’t perform that action at this time.