mirror of
https://github.com/justinccdev/opensimulator-tools.git
synced 2026-08-14 01:07:50 +00:00
Make the sets attribute for input batch json actually select a set
If there is no sets attribute we default to selecting all data sets
This commit is contained in:
@@ -80,7 +80,10 @@ class OSimStatsCorpus:
|
||||
return float(valueMatch.group(1)), valueMatch.group(2)
|
||||
|
||||
def getStat(self, statFullName):
|
||||
"""Get a statistic given its full name."""
|
||||
"""
|
||||
Get a statistic given its full name.
|
||||
FIXME: Does not allow one to interrogate a given set yet.
|
||||
"""
|
||||
if self._data == None:
|
||||
return None
|
||||
|
||||
@@ -92,24 +95,28 @@ class OSimStatsCorpus:
|
||||
else:
|
||||
return None
|
||||
|
||||
def getStats(self, glob = "*"):
|
||||
def getStats(self, setGlob = "*", selectGlob = "*"):
|
||||
"""
|
||||
Returns a dictionary of stats where fullName => stat.
|
||||
If glob is specified then this is used to match stats using their full name
|
||||
If no stats are found then an empty dictionary is returned.
|
||||
"""
|
||||
# FIXME: Doing far more work than necessary here if we simply want all stats without matching.
|
||||
if glob == None:
|
||||
glob = "*"
|
||||
|
||||
if selectGlob == None:
|
||||
selectGlob = "*"
|
||||
|
||||
if setGlob == None:
|
||||
setGlob = "*"
|
||||
|
||||
matchingStats = collections.OrderedDict()
|
||||
|
||||
for set in self._data.values():
|
||||
for category, containers in set.items():
|
||||
for container, stats in containers.items():
|
||||
for statName, stat in stats.items():
|
||||
if fnmatch.fnmatch(stat['fullName'], glob):
|
||||
matchingStats[stat['fullName']] = stat
|
||||
for setName, set in self._data.items():
|
||||
if fnmatch.fnmatch(setName, setGlob):
|
||||
for category, containers in set.items():
|
||||
for container, stats in containers.items():
|
||||
for statName, stat in stats.items():
|
||||
if fnmatch.fnmatch(stat['fullName'], selectGlob):
|
||||
matchingStats[stat['fullName']] = stat
|
||||
|
||||
return matchingStats
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ def plotSumAction(stats, type):
|
||||
totalsStat = OSimStatsHelper.sumStats(stats)
|
||||
plt.plot(totalsStat[type]['values'], label=totalsStat['container'])
|
||||
|
||||
def produceGraph(select, statType, action, show, save, outPath):
|
||||
stats = corpus.getStats(select)
|
||||
def produceGraph(sets, select, statType, action, show, save, outPath):
|
||||
stats = corpus.getStats(sets, select)
|
||||
|
||||
if len(stats) <= 0:
|
||||
print "No stats matching %s" % (select)
|
||||
@@ -99,6 +99,11 @@ if "batch" in opt:
|
||||
for graph in batchCommands["graphs"]:
|
||||
select = graph["select"]
|
||||
|
||||
if "sets" in graph:
|
||||
sets = graph["sets"]
|
||||
else:
|
||||
sets = "*"
|
||||
|
||||
if "type" in graph:
|
||||
type = graph["type"]
|
||||
else:
|
||||
@@ -118,7 +123,7 @@ if "batch" in opt:
|
||||
save = False
|
||||
show = True
|
||||
|
||||
produceGraph(select, type, action, show, save, outPath)
|
||||
produceGraph(sets, select, type, action, show, save, outPath)
|
||||
|
||||
else:
|
||||
save = "out" in opt
|
||||
@@ -129,4 +134,4 @@ else:
|
||||
else:
|
||||
outPath = None
|
||||
|
||||
produceGraph(opt.select, opt.type, opt.action, show, save, outPath)
|
||||
produceGraph("*", opt.select, opt.type, opt.action, show, save, outPath)
|
||||
Reference in New Issue
Block a user