[Arch] remove obsolete decode code (#9316)

* Update ArchCommands.py

* Update ArchPanel.py

* Update ArchReference.py

* Update ArchWall.py

* Update import3DS.py

* Update importDAE.py

* Update importIFClegacy.py

* Update importOBJ.py

* Update importSHP.py

* Update importSHP.py

Reverted

* Update importSH3D.py
This commit is contained in:
Roy-043
2023-04-19 15:58:06 +02:00
committed by GitHub
parent 78bdc34996
commit 3aebe166b4
9 changed files with 18 additions and 93 deletions

View File

@@ -29,7 +29,6 @@ if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtGui,QtCore
from draftutils.translate import translate
from draftutils.utils import utf8_decode
else:
# \cond
def translate(ctxt,txt):
@@ -862,14 +861,14 @@ def survey(callback=False):
t = u.getUserPreferred()[0]
t = t.replace("^3","³")
anno.LabelText = "v " + t
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Volume: " + utf8_decode(t) + "\n")
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Volume: " + t + "\n")
FreeCAD.SurveyObserver.totalVolume += u.Value
elif o.Object.Shape.Faces:
u = FreeCAD.Units.Quantity(o.Object.Shape.Area,FreeCAD.Units.Area)
t = u.getUserPreferred()[0]
t = t.replace("^2","²")
anno.LabelText = "a " + t
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Area: " + utf8_decode(t) + "\n")
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Area: " + t + "\n")
FreeCAD.SurveyObserver.totalArea += u.Value
if hasattr(FreeCAD,"SurveyDialog"):
FreeCAD.SurveyDialog.update(2,t)
@@ -878,7 +877,7 @@ def survey(callback=False):
t = u.getUserPreferred()[0]
t = t.encode("utf8")
anno.LabelText = "l " + t
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Length: " + utf8_decode(t) + "\n")
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: Whole, Length: " + t + "\n")
FreeCAD.SurveyObserver.totalLength += u.Value
if hasattr(FreeCAD,"SurveyDialog"):
FreeCAD.SurveyDialog.update(1,t)
@@ -905,7 +904,7 @@ def survey(callback=False):
t = u.getUserPreferred()[0]
t = t.replace("^2","²")
anno.LabelText = "a " + t
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Area: "+ utf8_decode(t) + "\n")
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Area: "+ t + "\n")
FreeCAD.SurveyObserver.totalArea += u.Value
if hasattr(FreeCAD,"SurveyDialog"):
FreeCAD.SurveyDialog.update(2,t)
@@ -913,7 +912,7 @@ def survey(callback=False):
u= FreeCAD.Units.Quantity(e.Length,FreeCAD.Units.Length)
t = u.getUserPreferred()[0]
anno.LabelText = "l " + t
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Length: " + utf8_decode(t) + "\n")
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Length: " + t + "\n")
FreeCAD.SurveyObserver.totalLength += u.Value
if hasattr(FreeCAD,"SurveyDialog"):
FreeCAD.SurveyDialog.update(1,t)
@@ -921,7 +920,7 @@ def survey(callback=False):
u = FreeCAD.Units.Quantity(e.Z,FreeCAD.Units.Length)
t = u.getUserPreferred()[0]
anno.LabelText = "z " + t
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Zcoord: " + utf8_decode(t) + "\n")
FreeCAD.Console.PrintMessage("Object: " + n + ", Element: " + el + ", Zcoord: " + t + "\n")
if FreeCAD.GuiUp and t:
if showUnit:
QtGui.QApplication.clipboard().setText(t)
@@ -1087,7 +1086,7 @@ class SurveyTaskPanel:
def update(self,column,txt):
item = QtGui.QTreeWidgetItem(self.tree)
self.tree.setCurrentItem(item)
item.setText(column,utf8_decode(txt))
item.setText(column,txt)
def setDescr(self,item,col):
self.descr.setText(item.text(0))
@@ -1539,7 +1538,7 @@ class _CommandCheck:
else:
FreeCADGui.Selection.clearSelection()
for i in result:
FreeCAD.Console.PrintWarning("Object "+i[0].Name+" ("+i[0].Label+") "+ utf8_decode(i[1]))
FreeCAD.Console.PrintWarning("Object "+i[0].Name+" ("+i[0].Label+") "+i[1])
FreeCADGui.Selection.addSelection(i[0])

View File

@@ -36,7 +36,7 @@ if FreeCAD.GuiUp:
import draftguitools.gui_trackers as DraftTrackers
else:
# \cond
def translate(ctxt,txt,utf8_decode=False):
def translate(ctxt,txt):
return txt
def QT_TRANSLATE_NOOP(ctxt,txt):
return txt

View File

@@ -35,7 +35,7 @@ if FreeCAD.GuiUp:
from PySide.QtCore import QT_TRANSLATE_NOOP
else:
# \cond
def translate(ctxt,txt, utf8_decode=False):
def translate(ctxt,txt):
return txt
def QT_TRANSLATE_NOOP(ctxt,txt):
return txt
@@ -159,7 +159,6 @@ class ArchReference:
f = zdoc.open(self.parts[obj.Part][1])
shapedata = f.read()
f.close()
shapedata = shapedata.decode("utf8")
shape = self.cleanShape(shapedata,obj,self.parts[obj.Part][2])
obj.Shape = shape
if not pl.isIdentity():
@@ -261,7 +260,6 @@ class ArchReference:
materials = {}
writemode = False
for line in docf:
line = line.decode("utf8")
if "<Object name=" in line:
n = re.findall('name=\"(.*?)\"',line)
if n:
@@ -317,7 +315,6 @@ class ArchReference:
writemode1 = False
writemode2 = False
for line in docf:
line = line.decode("utf8")
if ("<ViewProvider name=" in line) and (part in line):
writemode1 = True
elif writemode1 and ("<Property name=\"DiffuseColor\"" in line):
@@ -622,7 +619,6 @@ class ViewProviderArchReference:
writemode1 = False
writemode2 = False
for line in docf:
line = line.decode("utf8")
if ("<Object name=" in line) and (part in line):
writemode1 = True
elif writemode1 and ("<Property name=\"SavedInventor\"" in line):
@@ -639,7 +635,6 @@ class ViewProviderArchReference:
return None
f = zdoc.open(ivfile)
buf = f.read()
buf = buf.decode("utf8")
f.close()
buf = buf.replace("lineWidth 2","lineWidth "+str(int(obj.ViewObject.LineWidth)))
return buf

View File

@@ -39,7 +39,7 @@ if FreeCAD.GuiUp:
import draftguitools.gui_trackers as DraftTrackers
else:
# \cond
def translate(ctxt,txt, utf8_decode=False):
def translate(ctxt,txt):
return txt
def QT_TRANSLATE_NOOP(ctxt,txt):
return txt

View File

@@ -52,7 +52,7 @@ def open(filename):
return
docname = (os.path.splitext(os.path.basename(filename))[0]).encode("utf8")
doc = FreeCAD.newDocument(docname)
doc.Label = decode(docname)
doc.Label = docname
FreeCAD.ActiveDocument = doc
read(filename)
return doc
@@ -71,19 +71,6 @@ def insert(filename,docname):
return doc
def decode(name):
"decodes encoded strings"
try:
decodedName = (name.decode("utf8"))
except UnicodeDecodeError:
try:
decodedName = (name.decode("latin1"))
except UnicodeDecodeError:
FreeCAD.Console.PrintError(translate("Arch","Error: Couldn't determine character encoding"))
decodedName = name
return decodedName
def read(filename):
dom = dom3ds.read_3ds_file(filename,tight=False)
@@ -106,4 +93,3 @@ def read(filename):
obj.Placement = placement
else:
print("Skipping object without vertices array: ",d_nobj.obj)

View File

@@ -92,7 +92,7 @@ def open(filename):
return
docname = (os.path.splitext(os.path.basename(filename))[0]).encode("utf8")
doc = FreeCAD.newDocument(docname)
doc.Label = decode(docname)
doc.Label = docname
FreeCAD.ActiveDocument = doc
read(filename)
return doc
@@ -113,21 +113,6 @@ def insert(filename,docname):
return doc
def decode(name):
"decodes encoded strings"
try:
decodedName = (name.decode("utf8"))
except UnicodeDecodeError:
try:
decodedName = (name.decode("latin1"))
except UnicodeDecodeError:
FreeCAD.Console.PrintError(translate("Arch","Error: Couldn't determine character encoding"))
decodedName = name
return decodedName
def read(filename):
"reads a DAE file"

View File

@@ -61,7 +61,7 @@ def open(filename,skip=None):
"called when freecad opens a file"
docname = os.path.splitext(os.path.basename(filename))[0]
doc = FreeCAD.newDocument(docname)
doc.Label = decode(docname)
doc.Label = docname
FreeCAD.ActiveDocument = doc
getConfig()
read(filename,skip)
@@ -810,18 +810,6 @@ def getVector(entity):
# below is only used by the internal parser #########################################
def decode(name):
"decodes encoded strings"
try:
decodedName = (name.decode("utf8"))
except UnicodeDecodeError:
try:
decodedName = (name.decode("latin1"))
except UnicodeDecodeError:
FreeCAD.Console.PrintError(translate("Arch", "Error: Couldn't determine character encoding")+"\n")
decodedName = name
return decodedName
def getSchema():
"retrieves the express schema"
custom = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetString("CustomIfcSchema","")

View File

@@ -54,9 +54,6 @@ p = Draft.precision()
if open.__module__ in ['__builtin__','io']:
pythonopen = open
def decode(txt):
return txt
def findVert(aVertex,aList):
"finds aVertex in aList, returns index"
for i in range(len(aList)):
@@ -253,7 +250,7 @@ def export(exportList,filename,colors=None):
for f in flist:
outfile.write("f" + f + "\n")
outfile.close()
FreeCAD.Console.PrintMessage(translate("Arch","Successfully written") + " " + decode(filename) + "\n")
FreeCAD.Console.PrintMessage(translate("Arch","Successfully written") + " " + filename + "\n")
if materials:
outfile = pythonopen(filenamemtl,"w")
outfile.write("# FreeCAD v" + ver[0] + "." + ver[1] + " build" + ver[2] + " Arch module\n")
@@ -277,21 +274,9 @@ def export(exportList,filename,colors=None):
done.append(mat.Name)
outfile.write("# Material Count: " + str(len(materials)))
outfile.close()
FreeCAD.Console.PrintMessage(translate("Arch","Successfully written") + ' ' + decode(filenamemtl) + "\n")
FreeCAD.Console.PrintMessage(translate("Arch","Successfully written") + ' ' + filenamemtl + "\n")
#def decode(name):
# "decodes encoded strings"
# try:
# decodedName = (name.decode("utf8"))
# except UnicodeDecodeError:
# try:
# decodedName = (name.decode("latin1"))
# except UnicodeDecodeError:
# FreeCAD.Console.PrintError(translate("Arch","Error: Couldn't determine character encoding"))
# decodedName = name
# return decodedName
def open(filename):
"called when freecad wants to open a file"
docname = (os.path.splitext(os.path.basename(filename))[0])
@@ -371,7 +356,7 @@ def insert(filename,docname):
material = line[7:]
if activeobject:
makeMesh(doc,activeobject,verts,facets,material,colortable)
FreeCAD.Console.PrintMessage(translate("Arch","Successfully imported") + ' ' + decode(filename) + "\n")
FreeCAD.Console.PrintMessage(translate("Arch","Successfully imported") + ' ' + filename + "\n")
return doc
def makeMesh(doc,activeobject,verts,facets,material,colortable):

View File

@@ -51,7 +51,7 @@ def open(filename):
"called when freecad wants to open a file"
docname = (os.path.splitext(os.path.basename(filename))[0]).encode("utf8")
doc = FreeCAD.newDocument(docname)
doc.Label = decode(docname)
doc.Label = docname
FreeCAD.ActiveDocument = doc
read(filename)
return doc
@@ -68,19 +68,6 @@ def insert(filename,docname):
return doc
def decode(name):
"decodes encoded strings"
try:
decodedName = (name.decode("utf8"))
except UnicodeDecodeError:
try:
decodedName = (name.decode("latin1"))
except UnicodeDecodeError:
FreeCAD.Console.PrintError(translate("Arch","Error: Couldn't determine character encoding"))
decodedName = name
return decodedName
def read(filename):
"reads the file and creates objects in the active document"