Retrieves the algorithm history of the workspace and saves it to a Python script file or Python variable.
Example - generate a python script for a workspace:
ExGeneratePythonScriptSimple
#create a workspace and run some operations on it ws = CreateSampleWorkspace() ws = CropWorkspace(ws, XMin=7828.162291, XMax=11980.906921) ws = Power(ws, Exponent=1.5) ws = RenameWorkspace(ws, OutputWorkspace="MyTestWorkspace")
script_text = GeneratePythonScript(ws) print script_text
Output:
ExGeneratePythonScriptSimple
CreateSampleWorkspace(OutputWorkspace='ws') CropWorkspace(InputWorkspace='ws',OutputWorkspace='ws',XMin='7828.1622909999996',XMax='11980.906921') Power(InputWorkspace='ws',OutputWorkspace='ws',Exponent='1.5') RenameWorkspace(InputWorkspace='ws',OutputWorkspace='MyTestWorkspace')
Example - generate a python script and save it to file:
ExGeneratePythonScriptSimple
#create a workspace and run some operations on it ws = CreateSampleWorkspace() ws = CropWorkspace(ws, XMin=7828.162291, XMax=11980.906921) ws = Power(ws, Exponent=1.5) ws = RenameWorkspace(ws, OutputWorkspace="MyTestWorkspace")
GeneratePythonScript(ws, Filename='myscript.py')
- with open ('myscript.py', 'r') as script:
print script.read()
ExGeneratePythonScriptSimple import os try: os.remove('myscript.py') except: pass
Output:
ExGeneratePythonScriptSimple
CreateSampleWorkspace(OutputWorkspace='ws') CropWorkspace(InputWorkspace='ws',OutputWorkspace='ws',XMin='7828.1622909999996',XMax='11980.906921') Power(InputWorkspace='ws',OutputWorkspace='ws',Exponent='1.5') RenameWorkspace(InputWorkspace='ws',OutputWorkspace='MyTestWorkspace')