[llvm-commits] [zorg] r146942 - /zorg/trunk/lnt/lnt/server/db/v4db.py
Daniel Dunbar
daniel at zuster.org
Mon Dec 19 17:14:14 PST 2011
Author: ddunbar
Date: Mon Dec 19 19:14:14 2011
New Revision: 146942
URL: http://llvm.org/viewvc/llvm-project?rev=146942&view=rev
Log:
[lnt/v0.4] lnt.server.db.v4db: Add more dict like methods to V4DB.testsuite, and implement some of the basic queries used by the common import code.
Modified:
zorg/trunk/lnt/lnt/server/db/v4db.py
Modified: zorg/trunk/lnt/lnt/server/db/v4db.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/db/v4db.py?rev=146942&r1=146941&r2=146942&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/db/v4db.py (original)
+++ zorg/trunk/lnt/lnt/server/db/v4db.py Mon Dec 19 19:14:14 2011
@@ -11,6 +11,10 @@
def __init__(self, v4db):
self.v4db = v4db
+ def __iter__(self):
+ for name, in self.v4db.query(testsuite.TestSuite.name):
+ yield name
+
def __getitem__(self, name):
# Get the test suite object.
ts = self.v4db.query(testsuite.TestSuite).\
@@ -21,6 +25,17 @@
# Instantiate the per-test suite wrapper object for this test suite.
return testsuitedb.TestSuiteDB(self.v4db, ts)
+ def keys(self):
+ return iter(self)
+
+ def values(self):
+ for name in self:
+ yield self[name]
+
+ def items(self):
+ for name in self:
+ yield name,self[name]
+
def __init__(self, path, echo=False):
# If the path includes no database type, assume sqlite.
#
@@ -49,5 +64,23 @@
# by the TestSuites table.
# The magic starts by returning a object which will allow us to use
- # array access to get the per-test suite database wrapper.
+ # dictionary like access to get the per-test suite database wrapper.
return V4DB.TestSuiteAccessor(self)
+
+ # FIXME: The getNum...() methods below should be phased out once we can
+ # eliminate the v0.3 style databases.
+ def getNumMachines(self):
+ return sum([ts.query(ts.Machine).count()
+ for ts in self.testsuite.values()])
+ def getNumRuns(self):
+ return sum([ts.query(ts.Run).count()
+ for ts in self.testsuite.values()])
+ def getNumSamples(self):
+ return sum([ts.query(ts.Sample).count()
+ for ts in self.testsuite.values()])
+ def getNumTests(self):
+ return sum([ts.query(ts.Test).count()
+ for ts in self.testsuite.values()])
+
+ def importDataFromDict(self, data):
+ raise NotImplementedError
More information about the llvm-commits
mailing list