py3: OpenSCAD: make Mod/OpenSCAD python3 compatible

This commit is contained in:
Clemens Weissbacher
2018-10-25 11:22:20 +02:00
committed by Yorik van Havre
parent 54f88cc75c
commit cef825c567
5 changed files with 27 additions and 23 deletions

View File

@@ -52,8 +52,7 @@ from OpenSCADUtils import *
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD")
printverbose = params.GetBool('printVerbose',False)
if open.__module__ == '__builtin__':
pythonopen = open # to distinguish python built-in open function from the one declared here
pythonopen = open
# Get the token map from the lexer. This is required.
import tokrules
@@ -136,7 +135,7 @@ def processcsg(filename):
if printverbose: print('Parser Loaded')
# Give the lexer some input
#f=open('test.scad', 'r')
f = pythonopen(filename, 'r')
f = pythonopen(filename, 'r', encoding="utf8")
#lexer.input(f.read())
if printverbose: print('Start Parser')
@@ -431,7 +430,7 @@ def p_not_supported(p):
if gui and not FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
GetBool('usePlaceholderForUnsupported'):
from PySide import QtGui
QtGui.QMessageBox.critical(None, unicode(translate('OpenSCAD',"Unsupported Function"))+" : "+p[1],unicode(translate('OpenSCAD',"Press OK")))
QtGui.QMessageBox.critical(None, translate('OpenSCAD',"Unsupported Function")+" : "+p[1],translate('OpenSCAD',"Press OK"))
else:
p[0] = [placeholder(p[1],p[6],p[3])]
@@ -1204,6 +1203,6 @@ def p_projection_action(p) :
if gui and not FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
GetBool('usePlaceholderForUnsupported'):
from PySide import QtGui
QtGui.QMessageBox.critical(None, unicode(translate('OpenSCAD',"Unsupported Function"))+" : "+p[1],unicode(translate('OpenSCAD',"Press OK")))
QtGui.QMessageBox.critical(None, translate('OpenSCAD',"Unsupported Function")+" : "+p[1],translate('OpenSCAD',"Press OK"))
else:
p[0] = [placeholder(p[1],p[6],p[3])]