py3: OpenSCAD: use io.open more explicit
This commit is contained in:
@@ -41,10 +41,7 @@ except AttributeError:
|
||||
from PySide import QtGui
|
||||
return QtGui.QApplication.translate(context, text, None)
|
||||
|
||||
try:
|
||||
from io import open
|
||||
except ImportError:
|
||||
from codecs import open
|
||||
import io
|
||||
|
||||
try:
|
||||
import FreeCAD
|
||||
@@ -180,7 +177,7 @@ def callopenscadstring(scadstr,outputext='csg'):
|
||||
import os,tempfile,time
|
||||
dir1=tempfile.gettempdir()
|
||||
inputfilename=os.path.join(dir1,'%s.scad' % next(tempfilenamegen))
|
||||
inputfile = open(inputfilename,'w', encoding="utf8")
|
||||
inputfile = io.open(inputfilename,'w', encoding="utf8")
|
||||
inputfile.write(scadstr)
|
||||
inputfile.close()
|
||||
outputfilename = callopenscad(inputfilename,outputext=outputext,\
|
||||
|
||||
@@ -50,7 +50,9 @@ convexity = 'convexity = %d' % conv
|
||||
#***************************************************************************
|
||||
# Radius values not fixed for value apart from cylinder & Cone
|
||||
# no doubt there will be a problem when they do implement Value
|
||||
pythonopen = open
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open # to distinguish python built-in open function from the one declared here
|
||||
|
||||
|
||||
def center(b):
|
||||
if b == 2:
|
||||
@@ -247,7 +249,7 @@ def export(exportList,filename):
|
||||
# process Objects
|
||||
print("\nStart Export 0.1d\n")
|
||||
print("Open Output File")
|
||||
csg = pythonopen(filename,'w', encoding="utf8")
|
||||
csg = pythonopen(filename,'w')
|
||||
print("Write Initial Output")
|
||||
# Not sure if comments as per scad are allowed in csg file
|
||||
csg.write("// CSG file generated from FreeCAD %s\n" % \
|
||||
|
||||
@@ -33,7 +33,7 @@ __url__ = ["http://www.sloan-home.co.uk/ImportCSG"]
|
||||
|
||||
printverbose = False
|
||||
|
||||
import FreeCAD, os, sys
|
||||
import FreeCAD, io, os, sys
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
gui = True
|
||||
@@ -52,8 +52,6 @@ from OpenSCADUtils import *
|
||||
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD")
|
||||
printverbose = params.GetBool('printVerbose',False)
|
||||
|
||||
pythonopen = open
|
||||
|
||||
# Get the token map from the lexer. This is required.
|
||||
import tokrules
|
||||
from tokrules import tokens
|
||||
@@ -135,7 +133,7 @@ def processcsg(filename):
|
||||
if printverbose: print('Parser Loaded')
|
||||
# Give the lexer some input
|
||||
#f=open('test.scad', 'r')
|
||||
f = pythonopen(filename, 'r', encoding="utf8")
|
||||
f = io.open(filename, 'r', encoding="utf8")
|
||||
#lexer.input(f.read())
|
||||
|
||||
if printverbose: print('Start Parser')
|
||||
|
||||
Reference in New Issue
Block a user