[Piglit] [PATCH 3/9] summary.py: Replace Result class with load_result function
Dylan Baker
baker.dylan.c at gmail.com
Tue Oct 15 12:13:25 CEST 2013
This is groundwork for getting us down to one loader for results.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/summary.py | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/framework/summary.py b/framework/summary.py
index 62cd91a..1a15fa7 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -35,22 +35,20 @@ __all__ = [
]
-class Result(core.TestrunResult):
- """
- Object that opens, reads, and stores the data in a resultfile.
- """
- def __init__(self, resultfile):
- # Run the init from TestrunResult
- core.TestrunResult.__init__(self)
+def load_result(resultfile):
+ # Run the init from TestrunResult
+ result = core.TestrunResult().
+
+ # Load the json file, or if that fails assume that the locations given
+ # is a folder containing a json file
+ try:
+ with open(resultfile, 'r') as file:
+ result.parseFile(file)
+ except IOError:
+ with open(path.join(resultfile, 'main'), 'r') as file:
+ result.parseFile(file)
- # Load the json file, or if that fails assume that the locations given
- # is a folder containing a json file
- try:
- with open(resultfile, 'r') as file:
- result = self.parseFile(file)
- except IOError:
- with open(path.join(resultfile, 'main'), 'r') as file:
- result = self.parseFile(file)
+ return result
class HTMLIndex(list):
@@ -357,7 +355,7 @@ class Summary:
# Create a Result object for each piglit result and append it to the
# results list
- self.results = [Result(i) for i in resultfiles]
+ self.results = [load_result(i) for i in resultfiles]
self.status = {}
self.fractions = {}
--
1.8.1.5
More information about the Piglit
mailing list