[Arch] remove unneeded checks for Python 3
since we only support Python >=3, these checks can go
This commit is contained in:
@@ -24,7 +24,6 @@ import FreeCAD
|
||||
import Draft
|
||||
import ArchCommands
|
||||
import DraftVecUtils
|
||||
import sys
|
||||
import ArchIFC
|
||||
import tempfile
|
||||
import os
|
||||
@@ -40,8 +39,7 @@ else:
|
||||
def QT_TRANSLATE_NOOP(ctxt,txt):
|
||||
return txt
|
||||
# \endcond
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
unicode = str
|
||||
|
||||
## @package ArchBuildingPart
|
||||
# \ingroup ARCH
|
||||
@@ -758,10 +756,7 @@ class ViewProviderBuildingPart:
|
||||
elif prop == "FontName":
|
||||
if hasattr(vobj,"FontName") and hasattr(self,"fon"):
|
||||
if vobj.FontName:
|
||||
if sys.version_info.major < 3:
|
||||
self.fon.name = vobj.FontName.encode("utf8")
|
||||
else:
|
||||
self.fon.name = vobj.FontName
|
||||
self.fon.name = vobj.FontName
|
||||
elif prop in ["FontSize","DisplayOffset","OriginOffset"]:
|
||||
if hasattr(vobj,"FontSize") and hasattr(vobj,"DisplayOffset") and hasattr(vobj,"OriginOffset") and hasattr(self,"fon"):
|
||||
fs = vobj.FontSize.Value
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import sys
|
||||
import FreeCAD,Draft,ArchComponent,DraftVecUtils
|
||||
from FreeCAD import Vector
|
||||
if FreeCAD.GuiUp:
|
||||
@@ -60,8 +59,6 @@ def string_replace(text, pattern, replacement):
|
||||
u'abc mm \xc2\xb3'
|
||||
```
|
||||
"""
|
||||
if sys.version_info.major < 3:
|
||||
text = text.encode("utf8")
|
||||
return text.replace(pattern, replacement)
|
||||
|
||||
|
||||
@@ -937,8 +934,6 @@ def survey(callback=False):
|
||||
if FreeCAD.SurveyObserver.totalLength:
|
||||
u = FreeCAD.Units.Quantity(FreeCAD.SurveyObserver.totalLength,FreeCAD.Units.Length)
|
||||
t = u.getUserPreferred()[0]
|
||||
if sys.version_info.major < 3:
|
||||
t = t.encode("utf8")
|
||||
msg += " Length: " + t
|
||||
if FreeCAD.SurveyObserver.totalArea:
|
||||
u = FreeCAD.Units.Quantity(FreeCAD.SurveyObserver.totalArea,FreeCAD.Units.Area)
|
||||
@@ -1045,8 +1040,6 @@ class SurveyTaskPanel:
|
||||
if hasattr(FreeCAD,"SurveyObserver"):
|
||||
u = FreeCAD.Units.Quantity(FreeCAD.SurveyObserver.totalLength,FreeCAD.Units.Length)
|
||||
t = u.getUserPreferred()[0]
|
||||
if sys.version_info.major < 3:
|
||||
t = t.encode("utf8")
|
||||
if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("surveyUnits",True):
|
||||
QtGui.QApplication.clipboard().setText(t)
|
||||
else:
|
||||
@@ -1110,10 +1103,7 @@ class SurveyTaskPanel:
|
||||
if rows:
|
||||
filename = QtGui.QFileDialog.getSaveFileName(QtGui.QApplication.activeWindow(), translate("Arch","Export CSV File"), None, "CSV file (*.csv)");
|
||||
if filename:
|
||||
if sys.version_info.major < 3:
|
||||
mode = 'wb'
|
||||
else:
|
||||
mode = 'w'
|
||||
mode = 'w'
|
||||
with open(filename[0].encode("utf8"), mode) as csvfile:
|
||||
csvfile = csv.writer(csvfile,delimiter="\t")
|
||||
suml = 0
|
||||
@@ -1330,15 +1320,11 @@ def getExtrusionData(shape,sortmethod="area"):
|
||||
def printMessage( message ):
|
||||
FreeCAD.Console.PrintMessage( message )
|
||||
if FreeCAD.GuiUp :
|
||||
if sys.version_info.major < 3:
|
||||
message = message.decode("utf8")
|
||||
QtGui.QMessageBox.information( None , "" , message )
|
||||
|
||||
def printWarning( message ):
|
||||
FreeCAD.Console.PrintMessage( message )
|
||||
if FreeCAD.GuiUp :
|
||||
if sys.version_info.major < 3:
|
||||
message = message.decode("utf8")
|
||||
QtGui.QMessageBox.warning( None , "" , message )
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ __title__ = "FreeCAD Arch Component"
|
||||
__author__ = "Yorik van Havre"
|
||||
__url__ = "https://www.freecadweb.org"
|
||||
|
||||
import FreeCAD,Draft,ArchCommands,sys,ArchIFC
|
||||
import FreeCAD,Draft,ArchCommands,ArchIFC
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtGui,QtCore
|
||||
@@ -2085,11 +2085,7 @@ class ComponentTaskPanel:
|
||||
if not ptype.startswith("Ifc"):
|
||||
ptype = self.ptypes[self.plabels.index(ptype)]
|
||||
pvalue = self.ifcModel.item(row,0).child(childrow,2).text()
|
||||
if sys.version_info.major >= 3:
|
||||
ifcdict[prop] = pset+";;"+ptype+";;"+pvalue
|
||||
else:
|
||||
# keys cannot be unicode
|
||||
ifcdict[prop.encode("utf8")] = pset+";;"+ptype+";;"+pvalue
|
||||
ifcdict[prop] = pset+";;"+ptype+";;"+pvalue
|
||||
ifcData = self.obj.IfcData
|
||||
ifcData["IfcUID"] = self.ifcEditor.labelUUID.text()
|
||||
ifcData["FlagForceBrep"] = str(self.ifcEditor.checkBrep.isChecked())
|
||||
|
||||
@@ -28,7 +28,6 @@ import FreeCAD
|
||||
import os
|
||||
import zipfile
|
||||
import re
|
||||
import sys
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -160,8 +159,7 @@ class ArchReference:
|
||||
f = zdoc.open(self.parts[obj.Part][1])
|
||||
shapedata = f.read()
|
||||
f.close()
|
||||
if sys.version_info.major >= 3:
|
||||
shapedata = shapedata.decode("utf8")
|
||||
shapedata = shapedata.decode("utf8")
|
||||
shape = self.cleanShape(shapedata,obj,self.parts[obj.Part][2])
|
||||
obj.Shape = shape
|
||||
if not pl.isIdentity():
|
||||
@@ -263,8 +261,7 @@ class ArchReference:
|
||||
materials = {}
|
||||
writemode = False
|
||||
for line in docf:
|
||||
if sys.version_info.major >= 3:
|
||||
line = line.decode("utf8")
|
||||
line = line.decode("utf8")
|
||||
if "<Object name=" in line:
|
||||
n = re.findall('name=\"(.*?)\"',line)
|
||||
if n:
|
||||
@@ -320,8 +317,7 @@ class ArchReference:
|
||||
writemode1 = False
|
||||
writemode2 = False
|
||||
for line in docf:
|
||||
if sys.version_info.major >= 3:
|
||||
line = line.decode("utf8")
|
||||
line = line.decode("utf8")
|
||||
if ("<ViewProvider name=" in line) and (part in line):
|
||||
writemode1 = True
|
||||
elif writemode1 and ("<Property name=\"DiffuseColor\"" in line):
|
||||
@@ -341,10 +337,7 @@ class ArchReference:
|
||||
buf = cf.read()
|
||||
cf.close()
|
||||
for i in range(1,int(len(buf)/4)):
|
||||
if sys.version_info.major >= 3:
|
||||
colors.append((buf[i*4+3]/255.0,buf[i*4+2]/255.0,buf[i*4+1]/255.0,buf[i*4]/255.0))
|
||||
else:
|
||||
colors.append((ord(buf[i*4+3])/255.0,ord(buf[i*4+2])/255.0,ord(buf[i*4+1])/255.0,ord(buf[i*4])/255.0))
|
||||
colors.append((buf[i*4+3]/255.0,buf[i*4+2]/255.0,buf[i*4+1]/255.0,buf[i*4]/255.0))
|
||||
if colors:
|
||||
return colors
|
||||
return None
|
||||
@@ -610,8 +603,7 @@ class ViewProviderArchReference:
|
||||
writemode1 = False
|
||||
writemode2 = False
|
||||
for line in docf:
|
||||
if sys.version_info.major >= 3:
|
||||
line = line.decode("utf8")
|
||||
line = line.decode("utf8")
|
||||
if ("<Object name=" in line) and (part in line):
|
||||
writemode1 = True
|
||||
elif writemode1 and ("<Property name=\"SavedInventor\"" in line):
|
||||
@@ -628,8 +620,7 @@ class ViewProviderArchReference:
|
||||
return None
|
||||
f = zdoc.open(ivfile)
|
||||
buf = f.read()
|
||||
if sys.version_info.major >= 3:
|
||||
buf = buf.decode("utf8")
|
||||
buf = buf.decode("utf8")
|
||||
f.close()
|
||||
buf = buf.replace("lineWidth 2","lineWidth "+str(int(obj.ViewObject.LineWidth)))
|
||||
return buf
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import FreeCAD
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
@@ -172,11 +171,7 @@ class _ArchSchedule:
|
||||
# blank line
|
||||
continue
|
||||
# write description
|
||||
if sys.version_info.major >= 3:
|
||||
# use unicode for python3
|
||||
self.data["A"+str(li)] = obj.Description[i]
|
||||
else:
|
||||
self.data["A"+str(li)] = obj.Description[i].encode("utf8")
|
||||
self.data["A"+str(li)] = obj.Description[i]
|
||||
if verbose:
|
||||
l= "OPERATION: "+obj.Description[i]
|
||||
print("")
|
||||
@@ -261,8 +256,6 @@ class _ArchSchedule:
|
||||
q = None
|
||||
if obj.Unit[i]:
|
||||
unit = obj.Unit[i]
|
||||
if sys.version_info.major < 3:
|
||||
unit = unit.encode("utf8")
|
||||
unit = unit.replace("2","^2")
|
||||
unit = unit.replace("3","^3")
|
||||
unit = unit.replace("²","^2")
|
||||
@@ -504,8 +497,6 @@ class ArchScheduleTaskPanel:
|
||||
filename = QtGui.QFileDialog.getOpenFileName(QtGui.QApplication.activeWindow(), translate("Arch","Import CSV File"), None, "CSV file (*.csv)");
|
||||
if filename:
|
||||
filename = filename[0]
|
||||
if sys.version_info.major < 3:
|
||||
filename = filename.encode("utf8")
|
||||
self.form.list.clearContents()
|
||||
import csv
|
||||
with open(filename,'r') as csvfile:
|
||||
@@ -542,8 +533,6 @@ class ArchScheduleTaskPanel:
|
||||
if filename:
|
||||
filt = filename[1]
|
||||
filename = filename[0]
|
||||
if sys.version_info.major < 3:
|
||||
filename = filename.encode("utf8")
|
||||
# add missing extension
|
||||
if (not filename.lower().endswith(".csv")) and (not filename.lower().endswith(".tsv")) and (not filename.lower().endswith(".md")):
|
||||
if "csv" in filt:
|
||||
|
||||
@@ -145,7 +145,7 @@ ConditioningTypes = [
|
||||
"NaturallyVentedOnly"
|
||||
]
|
||||
|
||||
import FreeCAD,ArchComponent,ArchCommands,Draft,sys
|
||||
import FreeCAD,ArchComponent,ArchCommands,Draft
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -650,8 +650,6 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
t = t.replace("$walls",vobj.Object.FinishWalls)
|
||||
if hasattr(vobj.Object,"FinishCeiling"):
|
||||
t = t.replace("$ceiling",vobj.Object.FinishCeiling)
|
||||
if sys.version_info.major < 3:
|
||||
t = t.encode("utf8")
|
||||
if first:
|
||||
text1.append(t)
|
||||
else:
|
||||
|
||||
@@ -21,8 +21,7 @@ import sys, struct
|
||||
import numpy
|
||||
|
||||
# xrange is not available in python3
|
||||
if sys.version_info.major >= 3:
|
||||
xrange = range
|
||||
xrange = range
|
||||
|
||||
# Exceptions
|
||||
|
||||
|
||||
@@ -7,11 +7,9 @@ Defines some routines for calculating normals and transforming points.
|
||||
"""
|
||||
|
||||
import numpy
|
||||
import sys
|
||||
|
||||
# xrange is not available in python3
|
||||
if sys.version_info.major >= 3:
|
||||
xrange = range
|
||||
xrange = range
|
||||
|
||||
# Can push numpy.float64 (or even numpy.float80) into this if you
|
||||
# would like to use higher precision when calculating; results will be
|
||||
|
||||
@@ -225,10 +225,7 @@ def getGuiData(filename):
|
||||
df.close()
|
||||
cols = []
|
||||
for i in range(1,int(len(buf)/4)):
|
||||
if sys.version_info.major < 3:
|
||||
cols.append(ord(buf[i*4+3])/255.0,ord(buf[i*4+2])/255.0,ord(buf[i*4+1])/255.0,ord(buf[i*4])/255.0)
|
||||
else:
|
||||
cols.append((buf[i*4+3]/255.0,buf[i*4+2]/255.0,buf[i*4+1]/255.0,buf[i*4]/255.0))
|
||||
cols.append((buf[i*4+3]/255.0,buf[i*4+2]/255.0,buf[i*4+1]/255.0,buf[i*4]/255.0))
|
||||
guidata[key][propname]["value"] = cols
|
||||
zdoc.close()
|
||||
#print ("guidata:",guidata)
|
||||
@@ -243,11 +240,7 @@ def saveDiffuseColor(colorlist):
|
||||
property. Returns the path to the created temp file"""
|
||||
|
||||
def tochr(i):
|
||||
#print("tochr:",i)
|
||||
if sys.version_info.major < 3:
|
||||
return chr(i)
|
||||
else:
|
||||
return bytes((i,))
|
||||
return bytes((i,))
|
||||
# if too many colors, bail out and use only the first one for now...
|
||||
if len(colorlist) > 254:
|
||||
colorlist = colorlist[:1]
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD, DraftGeomUtils, Part, Draft, Arch, Mesh, MeshPart, os, sys, codecs, ntpath
|
||||
import FreeCAD, DraftGeomUtils, Part, Draft, Arch, Mesh, MeshPart, os, codecs, ntpath
|
||||
# import numpy as np
|
||||
if FreeCAD.GuiUp:
|
||||
from draftutils.translate import translate
|
||||
@@ -44,10 +44,6 @@ if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open
|
||||
|
||||
def decode(txt):
|
||||
|
||||
if sys.version_info.major < 3:
|
||||
if isinstance(txt,unicode):
|
||||
return txt.encode("utf8")
|
||||
return txt
|
||||
|
||||
def findVert(aVertex,aList):
|
||||
|
||||
Reference in New Issue
Block a user