Fix run time errors with python3.12 and pyside6 (#13337)
* Change pyopen=open expression to from builtins import open as pyopen --------- Co-authored-by: Adrián Insaurralde Avalos <36372335+adrianinsaval@users.noreply.github.com>
This commit is contained in:
@@ -46,6 +46,7 @@ from DraftGeomUtils import vec
|
||||
from importIFCHelper import dd2dms
|
||||
from draftutils import params
|
||||
from draftutils.messages import _msg, _err
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
@@ -54,10 +55,6 @@ __title__ = "FreeCAD IFC export"
|
||||
__author__ = ("Yorik van Havre", "Jonathan Wiedemann", "Bernd Hahnebach")
|
||||
__url__ = "https://www.freecad.org"
|
||||
|
||||
# Save the Python open function because it will be redefined
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pyopen = open
|
||||
|
||||
# Templates and other definitions ****
|
||||
# Specific FreeCAD <-> IFC slang translations
|
||||
translationtable = {
|
||||
|
||||
@@ -25,6 +25,7 @@ __url__ = "https://www.freecad.org"
|
||||
|
||||
import FreeCAD
|
||||
import Draft
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
from draftutils.translate import translate
|
||||
|
||||
@@ -44,6 +44,7 @@ import importIFCmulticore
|
||||
|
||||
from draftutils import params
|
||||
from draftutils.messages import _msg, _err
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui as Gui
|
||||
@@ -55,10 +56,6 @@ __url__ = "https://www.freecad.org"
|
||||
DEBUG = False # Set to True to see debug messages. Otherwise, totally silent
|
||||
ZOOMOUT = True # Set to False to not zoom extents after import
|
||||
|
||||
# Save the Python open function because it will be redefined
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pyopen = open
|
||||
|
||||
# Templates and other definitions ****
|
||||
# which IFC type must create which FreeCAD type
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
import FreeCAD, Arch, Draft, os, sys, time, Part, DraftVecUtils, uuid, math, re
|
||||
from draftutils import params
|
||||
from draftutils.translate import translate
|
||||
from builtins import open as pyopen
|
||||
|
||||
__title__="FreeCAD IFC importer"
|
||||
__author__ = "Yorik van Havre"
|
||||
@@ -54,8 +55,7 @@ supportedIfcTypes = ["IfcSite", "IfcBuilding", "IfcBuildingStorey", "IfcBeam", "
|
||||
"IfcPile", "IfcFooting", "IfcReinforcingBar", "IfcTendon"]
|
||||
# TODO : shading device not supported?
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pyopen = open # because we'll redefine open below
|
||||
|
||||
|
||||
def open(filename,skip=None):
|
||||
"called when freecad opens a file"
|
||||
|
||||
@@ -27,6 +27,7 @@ import FreeCAD
|
||||
import Draft
|
||||
import Mesh
|
||||
import Part
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
@@ -37,8 +38,7 @@ else:
|
||||
def translate(ctxt, txt): return txt
|
||||
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def export(exportList, filename):
|
||||
@@ -52,7 +52,7 @@ def export(exportList, filename):
|
||||
}
|
||||
|
||||
# Write file
|
||||
outfile = pythonopen(filename, "w")
|
||||
outfile = pyopen(filename, "w")
|
||||
json.dump(data, outfile, separators = (',', ':'))
|
||||
outfile.close()
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import Mesh
|
||||
import MeshPart
|
||||
import Part
|
||||
from draftutils import params
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
from draftutils.translate import translate
|
||||
@@ -50,8 +51,7 @@ else:
|
||||
# and supports exporting faces with more than 3 vertices
|
||||
# and supports object colors / materials
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
def findVert(aVertex,aList):
|
||||
"finds aVertex in aList, returns index"
|
||||
@@ -260,7 +260,7 @@ def export(exportList,filename,colors=None):
|
||||
outfile.close()
|
||||
FreeCAD.Console.PrintMessage(translate("Arch","Successfully written") + " " + filename + "\n")
|
||||
if materials:
|
||||
outfile = pythonopen(filenamemtl,"w")
|
||||
outfile = pyopen(filenamemtl,"w")
|
||||
outfile.write("# FreeCAD v" + ver[0] + "." + ver[1] + " build" + ver[2] + " Arch module\n")
|
||||
outfile.write("# https://www.freecad.org\n")
|
||||
kinds = {"AmbientColor":"Ka ","DiffuseColor":"Kd ","SpecularColor":"Ks ","EmissiveColor":"Ke ","Transparency":"Tr ","Dissolve":"d "}
|
||||
@@ -306,7 +306,7 @@ def insert(filename,docname):
|
||||
doc = FreeCAD.newDocument(docname)
|
||||
FreeCAD.ActiveDocument = doc
|
||||
|
||||
with pythonopen(filename,"r") as infile:
|
||||
with pyopen(filename,"r") as infile:
|
||||
verts = []
|
||||
facets = []
|
||||
activeobject = None
|
||||
@@ -327,7 +327,7 @@ def insert(filename,docname):
|
||||
if line[:7] == "mtllib ":
|
||||
matlib = os.path.join(os.path.dirname(filename),line[7:])
|
||||
if os.path.exists(matlib):
|
||||
with pythonopen(matlib,"r") as matfile:
|
||||
with pyopen(matlib,"r") as matfile:
|
||||
mname = None
|
||||
color = None
|
||||
trans = None
|
||||
|
||||
@@ -34,6 +34,7 @@ import Arch
|
||||
import Draft
|
||||
import Mesh
|
||||
import Part
|
||||
from builtins import open as pyopen
|
||||
|
||||
## @package importSH3D
|
||||
# \ingroup ARCH
|
||||
@@ -43,8 +44,7 @@ import Part
|
||||
|
||||
DEBUG = True
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pyopen = open # because we'll redefine open below
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
import os
|
||||
import FreeCAD
|
||||
from builtins import open as pyopen
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
def open(filename):
|
||||
|
||||
@@ -142,7 +142,7 @@ def checkShapeFileLibrary():
|
||||
return False
|
||||
b = u.read()
|
||||
fp = os.path.join(FreeCAD.getUserMacroDir(True),"shapefile.py")
|
||||
f = pythonopen(fp,"wb")
|
||||
f = pyopen(fp,"wb")
|
||||
f.write(b)
|
||||
f.close()
|
||||
try:
|
||||
|
||||
@@ -44,6 +44,7 @@ import Part
|
||||
import OfflineRenderingUtils
|
||||
import json
|
||||
import textwrap
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
@@ -52,7 +53,7 @@ else:
|
||||
FreeCADGui = None
|
||||
def translate(ctxt, txt): return txt
|
||||
|
||||
if open.__module__ in ['__builtin__','io']: pythonopen = open
|
||||
|
||||
|
||||
## @package importWebGL
|
||||
# \ingroup ARCH
|
||||
@@ -868,7 +869,7 @@ def export( exportList, filename, colors = None, camera = None ):
|
||||
|
||||
html = html.replace('$data', json.dumps(data, separators=(',', ':')) ) # Shape Data
|
||||
|
||||
outfile = pythonopen(filename, "w")
|
||||
outfile = pyopen(filename, "w")
|
||||
outfile.write( html )
|
||||
outfile.close()
|
||||
FreeCAD.Console.PrintMessage( translate("Arch", "Successfully written") + ' ' + filename + "\n" )
|
||||
|
||||
@@ -40,6 +40,7 @@ import datetime
|
||||
import shlex
|
||||
from PathScripts import PathUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -137,9 +138,7 @@ POST_OPERATION = """"""
|
||||
TOOL_CHANGE = """M05
|
||||
M09"""
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -279,7 +278,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import datetime
|
||||
import Path
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -126,9 +127,7 @@ POST_OPERATION = """"""
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -242,7 +241,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import datetime
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
Dumper is an extremely simple postprocessor file for the Path workbench. It is used
|
||||
@@ -35,9 +36,7 @@ shows the dialog so you can see it. Useful for debugging, but not much else.
|
||||
now = datetime.datetime.now()
|
||||
SHOW_EDITOR = True
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def export(objectslist, filename, argstring):
|
||||
|
||||
@@ -27,6 +27,7 @@ import Path
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import datetime
|
||||
import importDXF
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -58,9 +59,7 @@ else:
|
||||
Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule())
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
|
||||
@@ -33,6 +33,7 @@ import datetime
|
||||
import shlex
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a post processor file for the FreeCAD Path workbench. It is used to
|
||||
@@ -151,9 +152,7 @@ M30
|
||||
# Create following variable for use with the 2nd reference plane.
|
||||
clearanceHeight = None
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -346,7 +345,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import PathScripts.PathUtils as PathUtils
|
||||
import argparse
|
||||
import datetime
|
||||
import shlex
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -153,9 +154,7 @@ POST_OPERATION = """"""
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -284,7 +283,7 @@ def export(objectslist, filename, argstring):
|
||||
|
||||
print("done postprocessing.")
|
||||
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import argparse
|
||||
import datetime
|
||||
import shlex
|
||||
import re
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
TOOLTIP = """
|
||||
@@ -156,13 +157,6 @@ CURRENT_X = 0
|
||||
CURRENT_Y = 0
|
||||
CURRENT_Z = 0
|
||||
|
||||
|
||||
# ***************************************************************************
|
||||
# * to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
|
||||
global OUTPUT_HEADER
|
||||
@@ -346,7 +340,7 @@ def export(objectslist, filename, argstring):
|
||||
print("Done postprocessing.")
|
||||
|
||||
# write the file
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# ***************************************************************************
|
||||
|
||||
import datetime
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is an example postprocessor file for the Path workbench. It is used
|
||||
@@ -33,9 +34,7 @@ to GCode.
|
||||
|
||||
now = datetime.datetime.now()
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def export(objectslist, filename, argstring):
|
||||
@@ -48,7 +47,7 @@ def export(objectslist, filename, argstring):
|
||||
print("the given object is not a path")
|
||||
gcode = obj.Path.toGCode()
|
||||
gcode = parse(gcode)
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(gcode)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ from GCode.
|
||||
import FreeCAD
|
||||
import Path
|
||||
import os
|
||||
from builtins import open as pyopen
|
||||
|
||||
# LEVEL = Path.Log.Level.DEBUG
|
||||
LEVEL = Path.Log.Level.INFO
|
||||
@@ -44,9 +45,7 @@ if LEVEL == Path.Log.Level.DEBUG:
|
||||
Path.Log.trackModule(Path.Log.thisModule())
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
@@ -60,7 +59,7 @@ def open(filename):
|
||||
def insert(filename, docname):
|
||||
"called when freecad imports a file"
|
||||
Path.Log.track(filename)
|
||||
gfile = pythonopen(filename)
|
||||
gfile = pyopen(filename)
|
||||
gcode = gfile.read()
|
||||
gfile.close()
|
||||
gcode = parse(gcode)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
import datetime
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
now = datetime.datetime.now()
|
||||
|
||||
@@ -90,9 +91,7 @@ POST_OPERATION = """"""
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -205,7 +204,7 @@ def export(objectslist, filename, argstring):
|
||||
|
||||
print("done postprocessing.")
|
||||
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import shlex
|
||||
#from PathScripts import PostUtils
|
||||
import Path.Post.Utils as PostUtils
|
||||
from PathScripts import PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = '''
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -111,9 +112,7 @@ POST_OPERATION = ''''''
|
||||
# Tool Change commands will be inserted before a tool change
|
||||
TOOL_CHANGE = ''''''
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -428,7 +427,7 @@ def parse(pathobj):
|
||||
|
||||
def writeFile(filename, final):
|
||||
if not filename == '-':
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import shlex
|
||||
import os.path
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -137,9 +138,7 @@ POST_OPERATION = """"""
|
||||
# Tool Change commands will be inserted before a tool change
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -311,7 +310,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import PathScripts.PathUtils as PathUtils
|
||||
import os
|
||||
import re
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import Path.Op.Gui.Custom as PathCustomGui
|
||||
@@ -80,9 +81,7 @@ class PathNoJobException(Exception):
|
||||
super().__init__("No job object")
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
@@ -186,7 +185,7 @@ def _identifygcodeByToolNumberList(filename):
|
||||
Path.Log.track(filename)
|
||||
gcodeByToolNumberList = []
|
||||
|
||||
gfile = pythonopen(filename)
|
||||
gfile = pyopen(filename)
|
||||
gcode = gfile.read()
|
||||
gfile.close()
|
||||
|
||||
|
||||
14
src/Mod/CAM/Path/Post/scripts/grbl_post.py
Executable file → Normal file
14
src/Mod/CAM/Path/Post/scripts/grbl_post.py
Executable file → Normal file
@@ -34,6 +34,7 @@ import argparse
|
||||
import datetime
|
||||
import shlex
|
||||
import re
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
TOOLTIP = """
|
||||
@@ -182,12 +183,6 @@ CURRENT_Y = 0
|
||||
CURRENT_Z = 0
|
||||
|
||||
|
||||
# ***************************************************************************
|
||||
# * to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
|
||||
global OUTPUT_HEADER
|
||||
@@ -405,10 +400,9 @@ def export(objectslist, filename, argstring):
|
||||
print("Done postprocessing.")
|
||||
|
||||
# write the file
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
if filename != "-":
|
||||
with pyopen(filename, "w") as gfile:
|
||||
gfile.write(final)
|
||||
|
||||
return final
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import Path
|
||||
import PathScripts
|
||||
import shlex
|
||||
import math
|
||||
from builtins import open as pyopen
|
||||
|
||||
# **************************************************************************#
|
||||
# USER EDITABLE STUFF HERE #
|
||||
@@ -246,8 +247,7 @@ parser.add_argument(
|
||||
|
||||
TOOLTIP_ARGS = parser.format_help()
|
||||
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -540,7 +540,7 @@ def export(objectslist, filename, argstring):
|
||||
if SHOW_EDITOR:
|
||||
PostUtils.editor(Program_Out)
|
||||
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(Program_Out)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import datetime
|
||||
import shlex
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -135,9 +136,7 @@ TOOL_CHANGE = """"""
|
||||
|
||||
POWER_ON_DELAY = 0
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ == "__builtin__":
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -253,7 +252,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "wb")
|
||||
gfile = pyopen(filename, "wb")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import datetime
|
||||
import shlex
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -128,9 +129,7 @@ POST_OPERATION = """"""
|
||||
# Tool Change commands will be inserted before a tool change
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -290,7 +289,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import datetime
|
||||
import shlex
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -128,9 +129,7 @@ POST_OPERATION = """"""
|
||||
# Tool Change commands will be inserted before a tool change
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -291,7 +290,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import datetime
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
TOOLTIP = """
|
||||
@@ -79,9 +80,7 @@ POST_OPERATION = """"""
|
||||
# Tool Change commands will be inserted before a tool change
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
CurrentState = {}
|
||||
|
||||
@@ -183,7 +182,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
# Write the output
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import FreeCAD
|
||||
import Path
|
||||
import os
|
||||
import Path
|
||||
from builtins import open as pyopen
|
||||
|
||||
AXIS = (
|
||||
"X",
|
||||
@@ -62,9 +63,7 @@ AXIS = (
|
||||
) # OpenSBP always puts multiaxis move parameters in this order
|
||||
SPEEDS = "XY", "Z", "A", "B"
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
@@ -78,7 +77,7 @@ def insert(filename, docname):
|
||||
"""called when freecad imports a file
|
||||
This insert expects parse to return a list of strings
|
||||
each string will become a separate path"""
|
||||
gfile = pythonopen(filename)
|
||||
gfile = pyopen(filename)
|
||||
gcode = gfile.read()
|
||||
gfile.close()
|
||||
gcode = parse(gcode)
|
||||
|
||||
@@ -30,6 +30,7 @@ import time
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
import math
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """Post processor for Maho M 600E mill
|
||||
|
||||
@@ -296,8 +297,7 @@ GCODE_FOOTER = "M30"
|
||||
|
||||
linenr = 0 # variable has to be global because it is used by linenumberify and export
|
||||
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def angleUnder180(command, lastX, lastY, x, y, i, j):
|
||||
@@ -623,6 +623,6 @@ def export(objectslist, filename, argstring):
|
||||
gcode += linenumberify(GCODE_FOOTER)
|
||||
if SHOW_EDITOR:
|
||||
PostUtils.editor(gcode)
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(gcode)
|
||||
gfile.close()
|
||||
|
||||
@@ -37,10 +37,9 @@ http://paulbourke.net/dataformats/hpgl/
|
||||
import FreeCAD
|
||||
import Part
|
||||
import Path.Post.Utils as PostUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
# Entrypoint used by FreeCAD
|
||||
@@ -51,7 +50,7 @@ def export(objectslist, filename, argstring):
|
||||
for obj in objectslist:
|
||||
code += convertobject(obj)
|
||||
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(code)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -28,10 +28,9 @@ This is an preprocessor to read gcode files produced from slic3r.
|
||||
import os
|
||||
import Path
|
||||
import FreeCAD
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
def open(filename):
|
||||
@@ -43,7 +42,7 @@ def open(filename):
|
||||
|
||||
def insert(filename, docname):
|
||||
"called when freecad imports a file"
|
||||
gfile = pythonopen(filename)
|
||||
gfile = pyopen(filename)
|
||||
gcode = gfile.read()
|
||||
gfile.close()
|
||||
gcode = parse(gcode)
|
||||
|
||||
@@ -29,6 +29,7 @@ import PathScripts.PathUtils as PathUtils
|
||||
import FreeCAD
|
||||
from FreeCAD import Units
|
||||
import shlex
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -140,9 +141,7 @@ TOOL_CHANGE = """"""
|
||||
# Number of digits after the decimal point
|
||||
PRECISION = 5
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -280,7 +279,7 @@ def export(objectslist, filename, argstring):
|
||||
else:
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import datetime
|
||||
|
||||
# import shlex
|
||||
import Path.Post.Utils as PostUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
VERSION = "0.0.4"
|
||||
|
||||
@@ -280,13 +281,6 @@ parser.add_argument(
|
||||
parser.add_argument("--repeat", action="store_true", help="repeat axis arguments")
|
||||
TOOLTIP_ARGS = parser.format_help()
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ == "__builtin__":
|
||||
pythonopen = open
|
||||
|
||||
# debug option, trace to screen while processing to see where things break up.
|
||||
trace_gcode = False
|
||||
@@ -538,7 +532,7 @@ def export(objectslist, filename, argstring):
|
||||
|
||||
if not filename == "-":
|
||||
print("export: writing to '{}'".format(filename))
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import datetime
|
||||
import shlex
|
||||
import Path.Post.Utils as PostUtils
|
||||
import PathScripts.PathUtils as PathUtils
|
||||
from builtins import open as pyopen
|
||||
|
||||
TOOLTIP = """
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -184,9 +185,7 @@ POST_OPERATION = """"""
|
||||
# Tool Change commands will be inserted before a tool change
|
||||
TOOL_CHANGE = """"""
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def processArguments(argstring):
|
||||
@@ -401,7 +400,7 @@ def export(objectslist, filename, argstring):
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == "-":
|
||||
gfile = pythonopen(filename, "w")
|
||||
gfile = pyopen(filename, "w")
|
||||
gfile.write(final)
|
||||
gfile.close()
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import Draft
|
||||
import Part
|
||||
from FreeCAD import Vector
|
||||
from FreeCAD import Console as FCC
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
@@ -53,8 +54,7 @@ else:
|
||||
def translate(context, txt):
|
||||
return txt
|
||||
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
useDraftWire = True
|
||||
|
||||
@@ -133,7 +133,7 @@ def process(filename):
|
||||
_regex = r'^\s*' + xval + r'\,?\s*' + yval + r'\s*$'
|
||||
|
||||
regex = re.compile(_regex)
|
||||
afile = pythonopen(filename, 'r')
|
||||
afile = pyopen(filename, 'r')
|
||||
# read the airfoil name which is always at the first line
|
||||
airfoilname = afile.readline().strip()
|
||||
|
||||
|
||||
@@ -50,9 +50,7 @@ else:
|
||||
def translate(context, txt):
|
||||
return txt
|
||||
|
||||
# Save the native open function to avoid collisions
|
||||
if open.__module__ == '__builtin__':
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
|
||||
@@ -66,6 +66,7 @@ from FreeCAD import Console as FCC
|
||||
from Draft import LinearDimension
|
||||
from draftutils import params
|
||||
from draftutils import utils
|
||||
from builtins import open as pyopen
|
||||
|
||||
gui = FreeCAD.GuiUp
|
||||
draftui = None
|
||||
@@ -85,11 +86,6 @@ dxfReader = None
|
||||
dxfColorMap = None
|
||||
dxfLibrary = None
|
||||
|
||||
# Save the native open function to avoid collisions
|
||||
# with the function declared here
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
def errorDXFLib(gui):
|
||||
"""Download the files required to convert DXF files.
|
||||
@@ -3625,7 +3621,7 @@ def export(objectslist, filename, nospline=False, lwPoly=False):
|
||||
# arch view: export it "as is"
|
||||
dxf = exportList[0].Proxy.getDXF()
|
||||
if dxf:
|
||||
f = pythonopen(filename, "w")
|
||||
f = pyopen(filename, "w")
|
||||
f.write(dxf)
|
||||
f.close()
|
||||
|
||||
@@ -3906,11 +3902,11 @@ def exportPage(page, filename):
|
||||
template = os.path.splitext(page.Template)[0] + ".dxf"
|
||||
views = page.Group
|
||||
if os.path.exists(template):
|
||||
f = pythonopen(template, "U")
|
||||
f = pyopen(template, "U")
|
||||
template = f.read()
|
||||
f.close()
|
||||
# find & replace editable texts
|
||||
f = pythonopen(page.Template, "rb")
|
||||
f = pyopen(page.Template, "rb")
|
||||
svgtemplate = f.read()
|
||||
f.close()
|
||||
editables = re.findall("freecad:editable=\"(.*?)\"", svgtemplate)
|
||||
@@ -3950,7 +3946,7 @@ def exportPage(page, filename):
|
||||
c = dxfcounter()
|
||||
pat = re.compile("(_handle_)")
|
||||
template = pat.sub(c.incr, template)
|
||||
f = pythonopen(filename, "w")
|
||||
f = pyopen(filename, "w")
|
||||
f.write(template)
|
||||
f.close()
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import FreeCAD, os, Part, DraftVecUtils, DraftGeomUtils
|
||||
from FreeCAD import Vector
|
||||
from FreeCAD import Console as FCC
|
||||
from draftutils import params
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
from draftutils.translate import translate
|
||||
@@ -52,9 +53,7 @@ else:
|
||||
def translate(context, txt):
|
||||
return txt
|
||||
|
||||
# Save the native open function to avoid collisions
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def getpoint(data):
|
||||
@@ -286,7 +285,7 @@ def parse(filename, doc):
|
||||
-------
|
||||
None
|
||||
"""
|
||||
filebuffer = pythonopen(filename)
|
||||
filebuffer = pyopen(filename)
|
||||
global objects
|
||||
objects = {}
|
||||
global color
|
||||
@@ -416,7 +415,7 @@ def export(exportList, filename):
|
||||
return
|
||||
|
||||
# writing file
|
||||
oca = pythonopen(filename, 'w')
|
||||
oca = pyopen(filename, 'w')
|
||||
oca.write("#oca file generated from FreeCAD\r\n")
|
||||
oca.write("# edges\r\n")
|
||||
count = 1
|
||||
|
||||
@@ -61,6 +61,7 @@ from draftutils import params
|
||||
from draftutils import utils
|
||||
from draftutils.translate import translate
|
||||
from draftutils.messages import _err, _msg, _wrn
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
from PySide import QtWidgets
|
||||
@@ -74,9 +75,7 @@ else:
|
||||
gui = False
|
||||
draftui = None
|
||||
|
||||
# Save the native open function to avoid collisions
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
svgcolors = {
|
||||
'Pink': (255, 192, 203),
|
||||
@@ -1701,8 +1700,8 @@ def getContents(filename, tag, stringmode=False):
|
||||
if stringmode:
|
||||
contents = filename
|
||||
else:
|
||||
# Use the native Python open which was saved as `pythonopen`
|
||||
f = pythonopen(filename)
|
||||
# Use the native Python open which was saved as `pyopen`
|
||||
f = pyopen(filename)
|
||||
contents = f.read()
|
||||
f.close()
|
||||
|
||||
@@ -1746,8 +1745,8 @@ def open(filename):
|
||||
parser.setContentHandler(svgHandler())
|
||||
parser._cont_handler.doc = doc
|
||||
|
||||
# Use the native Python open which was saved as `pythonopen`
|
||||
f = pythonopen(filename)
|
||||
# Use the native Python open which was saved as `pyopen`
|
||||
f = pyopen(filename)
|
||||
parser.parse(f)
|
||||
f.close()
|
||||
doc.recompute()
|
||||
@@ -1785,8 +1784,8 @@ def insert(filename, docname):
|
||||
parser.setContentHandler(svgHandler())
|
||||
parser._cont_handler.doc = doc
|
||||
|
||||
# Use the native Python open which was saved as `pythonopen`
|
||||
parser.parse(pythonopen(filename))
|
||||
# Use the native Python open which was saved as `pyopen`
|
||||
parser.parse(pyopen(filename))
|
||||
doc.recompute()
|
||||
|
||||
|
||||
@@ -1854,8 +1853,8 @@ def export(exportList, filename):
|
||||
sizey = maxy - miny
|
||||
miny += margin
|
||||
|
||||
# Use the native Python open which was saved as `pythonopen`
|
||||
svg = pythonopen(filename, 'w')
|
||||
# Use the native Python open which was saved as `pyopen`
|
||||
svg = pyopen(filename, 'w')
|
||||
|
||||
# Write header.
|
||||
# We specify the SVG width and height in FreeCAD's physical units (mm),
|
||||
|
||||
@@ -34,13 +34,14 @@ import os
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Console
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
EIGENVALUE_OUTPUT_SECTION = " E I G E N V A L U E O U T P U T"
|
||||
|
||||
|
||||
# ********* generic FreeCAD import and export methods *********
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(
|
||||
|
||||
@@ -35,10 +35,11 @@ import os
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Console
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
# ********* generic FreeCAD import and export methods *********
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
|
||||
@@ -38,6 +38,7 @@ from . import importToolsFem
|
||||
from . import readFenicsXML
|
||||
from . import writeFenicsXML
|
||||
from . import writeFenicsXDMF
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
@@ -46,7 +47,7 @@ if FreeCAD.GuiUp:
|
||||
|
||||
# Template copied from importZ88Mesh.py. Thanks Bernd!
|
||||
# ********* generic FreeCAD import and export methods *********
|
||||
pyopen = open
|
||||
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
class WriteXDMFTaskPanel:
|
||||
|
||||
@@ -35,10 +35,11 @@ import os
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Console
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
# ********* generic FreeCAD import and export methods *********
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
|
||||
@@ -32,13 +32,14 @@ __url__ = "https://www.freecad.org"
|
||||
import FreeCAD
|
||||
|
||||
from femmesh import meshtools
|
||||
from builtins import open as pyopen
|
||||
|
||||
# ************************************************************************************************
|
||||
# ********* generic FreeCAD import and export methods ********************************************
|
||||
# names are fix given from FreeCAD, these methods are called from FreeCAD
|
||||
# they are set in FEM modules Init.py
|
||||
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
# export mesh to python
|
||||
|
||||
@@ -36,10 +36,11 @@ import FreeCAD
|
||||
from FreeCAD import Console
|
||||
|
||||
import Fem
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
# ********* generic FreeCAD import and export methods *********
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(
|
||||
|
||||
@@ -36,6 +36,7 @@ import FreeCAD
|
||||
from FreeCAD import Console
|
||||
|
||||
from . import importToolsFem
|
||||
from builtins import open as pyopen
|
||||
|
||||
has_yaml = True
|
||||
try:
|
||||
@@ -53,7 +54,7 @@ except ImportError:
|
||||
# names are fix given from FreeCAD, these methods are called from FreeCAD
|
||||
# they are set in FEM modules Init.py
|
||||
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(
|
||||
|
||||
@@ -35,13 +35,14 @@ import FreeCAD
|
||||
from FreeCAD import Console
|
||||
|
||||
from femmesh import meshtools
|
||||
from builtins import open as pyopen
|
||||
|
||||
# ************************************************************************************************
|
||||
# ********* generic FreeCAD import and export methods ********************************************
|
||||
# names are fix given from FreeCAD, these methods are called from FreeCAD
|
||||
# they are set in FEM modules Init.py
|
||||
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(
|
||||
|
||||
@@ -33,10 +33,11 @@ import os
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Console
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
# ********* generic FreeCAD import and export methods *********
|
||||
pyopen = open
|
||||
|
||||
|
||||
|
||||
def open(
|
||||
|
||||
@@ -25,10 +25,7 @@ import FreeCAD, Part, os, FreeCADGui
|
||||
from FreeCAD import Base
|
||||
from math import *
|
||||
import ImportGui
|
||||
|
||||
# to distinguish python built-in open function from the one declared here
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open
|
||||
from builtins import open as pyopen
|
||||
|
||||
##########################################################
|
||||
# Script version dated 19-Jan-2012 #
|
||||
@@ -74,7 +71,7 @@ def insert(filename,docname):
|
||||
|
||||
def process_emn(doc,filename):
|
||||
"""process_emn(document, filename)-> adds emn geometry from emn file"""
|
||||
emnfile=pythonopen(filename, "r")
|
||||
emnfile=pyopen(filename, "r")
|
||||
emn_unit=1.0 #presume millimeter like emn unit
|
||||
emn_version=2 #presume emn_version 2
|
||||
board_thickness=0 #presume 0 board height
|
||||
@@ -227,7 +224,7 @@ def split_records(line_record):
|
||||
def process_emp(doc,filename,placement,board_thickness):
|
||||
"""process_emp(doc,filename,placement,board_thickness) -> place components from emn file to board"""
|
||||
filename=filename.partition(".emn")[0]+".emp"
|
||||
empfile=pythonopen(filename, "r")
|
||||
empfile=pyopen(filename, "r")
|
||||
emp_unit=1.0 #presume millimeter like emn unit
|
||||
emp_version=2 #presume emn_version 2
|
||||
comp_height=0 #presume 0 part height
|
||||
@@ -274,7 +271,7 @@ def process_emp(doc,filename,placement,board_thickness):
|
||||
FreeCAD.Console.PrintMessage("\n".join(passed_sections)+"\n")
|
||||
#Write file with list of footprint
|
||||
if IDF_diag==1:
|
||||
empfile=pythonopen(IDF_diag_path+"/footprint.lst", "w")
|
||||
empfile=pyopen(IDF_diag_path+"/footprint.lst", "w")
|
||||
for compx in comps:
|
||||
empfile.writelines(str(compx[1][1])+"\n")
|
||||
empfile.close()
|
||||
@@ -331,12 +328,12 @@ def place_steps(doc,placement,board_thickness):
|
||||
|
||||
list of models and path to step files is set at start of this script
|
||||
model_tab_filename= "" & step_path="" """
|
||||
model_file=pythonopen(model_tab_filename, "r")
|
||||
model_file=pyopen(model_tab_filename, "r")
|
||||
model_lines=model_file.readlines()
|
||||
model_file.close()
|
||||
model_dict=[]
|
||||
if IDF_diag==1:
|
||||
model_file=pythonopen(IDF_diag_path+"/missing_models.lst", "w")
|
||||
model_file=pyopen(IDF_diag_path+"/missing_models.lst", "w")
|
||||
keys=[]
|
||||
#prev_step="*?.*?" #hope nobody will insert this step filename
|
||||
step_dict=[]
|
||||
|
||||
@@ -31,14 +31,13 @@ import FreeCAD
|
||||
|
||||
from materialtools.cardutils import get_material_template
|
||||
import Materials
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
from PySide import QtGui
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
|
||||
def open(filename):
|
||||
@@ -119,7 +118,7 @@ def read_old(filename):
|
||||
|
||||
# print(filename)
|
||||
card_name_file = os.path.splitext(os.path.basename(filename))[0]
|
||||
f = pythonopen(filename, encoding="utf8")
|
||||
f = pyopen(filename, encoding="utf8")
|
||||
try:
|
||||
content = f.readlines()
|
||||
# print(len(content))
|
||||
@@ -194,7 +193,7 @@ def read2(filename):
|
||||
|
||||
# print(filename)
|
||||
card_name_file = os.path.splitext(os.path.basename(filename))[0]
|
||||
f = pythonopen(filename, encoding="utf8")
|
||||
f = pyopen(filename, encoding="utf8")
|
||||
try:
|
||||
content = f.readlines()
|
||||
# print(len(content))
|
||||
@@ -335,7 +334,7 @@ def write(filename, dictionary, write_group_section=True):
|
||||
if FreeCAD.GuiUp:
|
||||
QtGui.QMessageBox.critical(None, "No card name", error_message)
|
||||
return
|
||||
f = pythonopen(filename, "w", encoding="utf-8")
|
||||
f = pyopen(filename, "w", encoding="utf-8")
|
||||
# write header
|
||||
# first five lines are the same in any card file, see comment above read def
|
||||
if header["CardName"] != card_name_file:
|
||||
|
||||
@@ -29,6 +29,7 @@ __author__ = "Keith Sloan <keith@sloan-home.co.uk>"
|
||||
__url__ = ["http://www.sloan-home.co.uk/Export/Export.html"]
|
||||
|
||||
import FreeCAD
|
||||
from builtins import open as pyopen
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
gui = True
|
||||
@@ -48,9 +49,6 @@ 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
|
||||
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:
|
||||
@@ -254,7 +252,7 @@ def export(exportList, filename):
|
||||
# process Objects
|
||||
print("\nStart Export 0.1d\n")
|
||||
print("Open Output File")
|
||||
csg = pythonopen(filename,'w')
|
||||
csg = pyopen(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" % \
|
||||
|
||||
@@ -44,9 +44,7 @@ import Draft
|
||||
from OpenSCADFeatures import *
|
||||
from OpenSCADUtils import *
|
||||
|
||||
# Save the native open function to avoid collisions
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
pythonopen = open
|
||||
|
||||
import ply.lex as lex
|
||||
import ply.yacc as yacc
|
||||
|
||||
@@ -66,6 +64,7 @@ original_root_objects = []
|
||||
# Get the token map from the lexer. This is required.
|
||||
import tokrules
|
||||
from tokrules import tokens
|
||||
from builtins import open as pyopen
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
@@ -897,8 +896,8 @@ def processSVG(fname, ext):
|
||||
|
||||
# pathName is a Global
|
||||
filename = os.path.join(pathName,fname+'.'+ext)
|
||||
# Use the native Python open which was saved as `pythonopen`
|
||||
parser.parse(pythonopen(filename))
|
||||
# Use the native Python open which was saved as `pyopen`
|
||||
parser.parse(pyopen(filename))
|
||||
|
||||
#combine SVG objects into one
|
||||
shapes = []
|
||||
|
||||
@@ -12,9 +12,9 @@ import re
|
||||
from OpenSCADFeatures import *
|
||||
from OpenSCAD2Dgeom import *
|
||||
from OpenSCADUtils import *
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
if open.__module__ in ['__builtin__','io']:
|
||||
pythonopen = open # to distinguish python built-in open function from the one declared here
|
||||
|
||||
|
||||
def openscadmesh(doc, scadstr, objname):
|
||||
@@ -661,9 +661,9 @@ def readfile(filename):
|
||||
tmpfile=callopenscad(filename)
|
||||
if OpenSCADUtils.workaroundforissue128needed():
|
||||
lastimportpath = os.getcwd() #https://github.com/openscad/openscad/issues/128
|
||||
f = pythonopen(tmpfile)
|
||||
f = pyopen(tmpfile)
|
||||
else:
|
||||
f = pythonopen(filename)
|
||||
f = pyopen(filename)
|
||||
rootnode = parsenode(f.read())[0]
|
||||
f.close()
|
||||
if isopenscad and tmpfile:
|
||||
|
||||
@@ -24,9 +24,9 @@ __title__="FreeCAD OpenSCAD Workbench - DRAWEXE exporter"
|
||||
__author__ = "Sebastian Hoogen <github@sebastianhoogen.de>"
|
||||
|
||||
import FreeCAD, Part
|
||||
from builtins import open as pyopen
|
||||
|
||||
|
||||
if open.__module__ == '__builtin__':
|
||||
pythonopen = open
|
||||
|
||||
# unsupported primitives
|
||||
# Part:: Wedge, Helix, Spiral, Elipsoid
|
||||
@@ -252,7 +252,7 @@ def isDeform(ob):
|
||||
class Drawexporter(object):
|
||||
def __init__(self, filename):
|
||||
self.objectcache=set()
|
||||
self.csg = pythonopen(filename,'w')
|
||||
self.csg = pyopen(filename,'w')
|
||||
#self.csg=csg
|
||||
self.filename=filename
|
||||
#settings
|
||||
|
||||
@@ -63,9 +63,6 @@ except ValueError:
|
||||
else:
|
||||
gui = True
|
||||
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
# The sepToken structure is used in the tokenizer functions isKey and
|
||||
# getNextToken.
|
||||
|
||||
Reference in New Issue
Block a user