Skip to content

Commit

Permalink
Re #10234. support property "PlotName"
Browse files Browse the repository at this point in the history
forgot to commit changes to the source code at the last commit for this
  • Loading branch information
yxqd committed Aug 31, 2015
1 parent 6b045db commit 45aea2b
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def PyInit(self):

self.declareProperty(
FileProperty("JsonFilename", "", FileAction.Save, ['.json']),
"Name of the output Json file. ")
"Name of the output Json file")

self.declareProperty("PlotName", "", "Name of the output plot")

return

Expand All @@ -55,6 +57,7 @@ def PyExec(self):
# Properties
inputwsname = self.getPropertyValue("InputWorkspace")
outfilename = self.getPropertyValue("JsonFilename")
plotname = self.getPropertyValue("PlotName")

# Check properties
inputws = AnalysisDataService.retrieve(inputwsname)
Expand All @@ -70,17 +73,17 @@ def PyExec(self):
"Output file %s already exists" % outfilename)

# Generate Json file
output = self._save(inputws, outfilename)
output = self._save(inputws, outfilename, plotname)
return

def _save(self, inputws, outpath):
d = self._serialize(inputws)
def _save(self, inputws, outpath, plotname):
d = self._serialize(inputws, plotname)
import json
json.dump(d, open(outpath, 'wt'))
return

def _serialize(self, ws):
wname = ws.getName()
def _serialize(self, ws, plotname):
wname = plotname or ws.getName()
# init dictionary
ishist = ws.isHistogramData()
type = "histogram" if ishist else "point"
Expand Down

0 comments on commit 45aea2b

Please sign in to comment.