Skip to content

Commit

Permalink
py3: adapt scripts to work with Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer authored and looooo committed Jan 17, 2017
1 parent 1591601 commit 4f43cfa
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/App/PropertyGeo.cpp
Expand Up @@ -265,13 +265,13 @@ PyObject *PropertyVectorList::getPyObject(void)

void PropertyVectorList::setPyObject(PyObject *value)
{
if (PyList_Check(value)) {
Py_ssize_t nSize = PyList_Size(value);
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<Base::Vector3d> values;
values.resize(nSize);

for (Py_ssize_t i=0; i<nSize;++i) {
PyObject* item = PyList_GetItem(value, i);
PyObject* item = PySequence_GetItem(value, i);
PropertyVector val;
val.setPyObject( item );
values[i] = val.getValue();
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/ArchEquipment.py
Expand Up @@ -27,7 +27,8 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands,Units
import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands
from FreeCAD import Units
from FreeCAD import Vector
if FreeCAD.GuiUp:
import FreeCADGui
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchProfile.py
Expand Up @@ -59,7 +59,7 @@ def readPresets():
for profilefile in profilefiles:
if os.path.exists(profilefile):
try:
with open(profilefile, 'rb') as csvfile:
with open(profilefile, 'r') as csvfile:
beamreader = csv.reader(csvfile)
bid=1 #Unique index
for row in beamreader:
Expand Down
1 change: 0 additions & 1 deletion src/Mod/Arch/ArchStairs.py
Expand Up @@ -490,7 +490,6 @@ def makeCurvedStairsWithLanding(self,obj,edge):
print("Not yet implemented!")



class _ViewProviderStairs(ArchComponent.ViewProviderComponent):
"A View Provider for Stairs"
def __init__(self,vobj):
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Arch/ArchWindow.py
Expand Up @@ -21,7 +21,8 @@
#* *
#***************************************************************************

import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands,Units
import FreeCAD,Draft,ArchComponent,DraftVecUtils,ArchCommands
from FreeCAD import Units
from FreeCAD import Vector
if FreeCAD.GuiUp:
import FreeCADGui
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Arch/importIFC.py
Expand Up @@ -354,9 +354,12 @@ def insert(filename,docname,skip=[],only=[],root=None):
if DEBUG: print("done.")

global ROOT_ELEMENT

if root:
ROOT_ELEMENT = root

if DEBUG: print ("done.")

#global ifcfile # keeping global for debugging purposes
filename = decode(filename,utf=True)
ifcfile = ifcopenshell.open(filename)
Expand Down Expand Up @@ -513,6 +516,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
except:
if DEBUG: print(" ERROR unable to get object representation",)
if prepr and (MERGE_MODE_ARCH == 0) and archobj and CREATE_CLONES:

for s in prepr.Representations:
if s.RepresentationIdentifier.upper() == "BODY":
if s.Items[0].is_a("IfcMappedItem"):
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Fem/ccxFrdReader.py
Expand Up @@ -413,7 +413,7 @@ def importFrd(filename, analysis=None, result_name_prefix=None):

if 'Nodes' in m:
positions = []
for k, v in m['Nodes'].iteritems():
for k, v in m['Nodes'].items():
positions.append(v)
p_x_max, p_y_max, p_z_max = map(max, zip(*positions))
p_x_min, p_y_min, p_z_min = map(min, zip(*positions))
Expand Down Expand Up @@ -454,7 +454,7 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
strainv = result_set['strainv']
no_of_values = len(disp)
displacement = []
for k, v in disp.iteritems():
for k, v in disp.items():
displacement.append(v)

x_max, y_max, z_max = map(max, zip(*displacement))
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Start/StartPage/StartPage.py
Expand Up @@ -41,10 +41,10 @@ def translate(context,text):

s = cStringIO.StringIO()
for i in u:
if ord(i) == 39:
if i == 39:
s.write("\\'")
else:
s.write(i)
s.write(chr(i))
t = s.getvalue()
s.close()
return t
Expand Down Expand Up @@ -638,7 +638,7 @@ def setColors(html):
defaults["#textcolor"] = palette.text().color().name()
defaults["#windowcolor"] = palette.window().color().name()
defaults["#windowtextcolor"] = palette.windowText().color().name()
for k,v in defaults.iteritems():
for k,v in defaults.items():
html = html.replace(k,str(v))
return html

Expand Down

0 comments on commit 4f43cfa

Please sign in to comment.