diff --git a/analysis/opensimulator-stats-analyzer/src/osta/osta.py b/analysis/opensimulator-stats-analyzer/src/osta/osta.py index 8a98502..79080dd 100755 --- a/analysis/opensimulator-stats-analyzer/src/osta/osta.py +++ b/analysis/opensimulator-stats-analyzer/src/osta/osta.py @@ -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 diff --git a/analysis/opensimulator-stats-analyzer/src/ostagraph.py b/analysis/opensimulator-stats-analyzer/src/ostagraph.py index e17554b..93793d3 100755 --- a/analysis/opensimulator-stats-analyzer/src/ostagraph.py +++ b/analysis/opensimulator-stats-analyzer/src/ostagraph.py @@ -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) \ No newline at end of file + produceGraph("*", opt.select, opt.type, opt.action, show, save, outPath) \ No newline at end of file