Material: Fixed py3/import issues

This commit is contained in:
Yorik van Havre
2018-12-29 14:40:25 -02:00
parent 195c530c00
commit 91a61d4813
2 changed files with 11 additions and 9 deletions

View File

@@ -24,8 +24,6 @@
from __future__ import print_function
import FreeCAD
import FreeCADGui
from Units import Unit
from Units import Quantity
from Material import getMaterialAttributeStructure
import os
from PySide import QtCore, QtGui
@@ -234,10 +232,11 @@ class MaterialEditor:
self.getMaterialResources()
self.cards = {}
for p in self.resources:
for f in os.listdir(p):
b, e = os.path.splitext(f)
if e.upper() == ".FCMAT":
self.cards[b] = p + os.sep + f
if os.path.exists(p):
for f in os.listdir(p):
b, e = os.path.splitext(f)
if e.upper() == ".FCMAT":
self.cards[b] = p + os.sep + f
# self.outputCards()
if self.cards:
self.widget.ComboMaterial.clear()
@@ -568,9 +567,9 @@ def matProperWidget(parent=None, Type="String", Units=None, Value=None,
widget = ui.createWidget("Gui::InputField")
if Units:
vv = string2tuple(Units)
unit = Unit(vv[0], vv[1], vv[2], vv[3],
unit = FreeCAD.Units.Unit(vv[0], vv[1], vv[2], vv[3],
vv[4], vv[5], vv[6], vv[7])
quantity = Quantity(1, unit)
quantity = FreeCAD.Units.Quantity(1, unit)
widget.setProperty('unit', quantity.getUserPreferred()[2])
elif Type == "Integer":

View File

@@ -95,7 +95,10 @@ def read(filename):
if not line[0] in ";#[":
k = line.split("=")
if len(k) == 2:
d[k[0].strip()] = k[1].strip().decode('utf-8')
v = k[1].strip()
if hasattr(v,"decode"):
v = v.decode('utf-8')
d[k[0].strip()] = v
l += 1
return d