summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorChad Versace <chad@chad-versace.us>2011-07-19 10:10:41 -0700
committerChad Versace <chad@chad-versace.us>2011-07-29 17:23:03 -0700
commitc6732ed50ad9c282b6c764da1e8134698d83f01f (patch)
tree6f1de19f0b4404d4cbb05c3777d80845a950da98 /framework
parent84544ba918cbd0c20bf84cc9e228ad7f844ad4d5 (diff)
core: Add method TestrunResult.__checkFileIsNotInOldFormat
Factor out from TestrunResult.parseFile the code that checks if the file is in the old format. Place that code into a separate method, __checkFileIsNotInOldFormat. CC: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Chad Versace <chad@chad-versace.us>
Diffstat (limited to 'framework')
-rw-r--r--framework/core.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/framework/core.py b/framework/core.py
index 3c959e7d9..c025311b5 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -278,21 +278,27 @@ class TestrunResult:
self.lspci = None
self.tests = {}
- def write(self, file):
- # Serialize only the keys in serialized_keys.
- keys = set(self.__dict__.keys()).intersection(self.serialized_keys)
- raw_dict = dict([(k, self.__dict__[k]) for k in keys])
- json.dump(raw_dict, file, indent=JSONWriter.INDENT)
+ def __checkFileIsNotInOldFormat(self, file):
+ '''
+ If file contains the old, custom format, then raise
+ ``ResultFileInOldFormatError``.
- def parseFile(self, file):
- # If file contains the old, custom format, then raise
- # an informative error.
+ :return: None
+ '''
saved_position = file.tell()
first_line = file.readline()
if first_line.startswith('name:'):
raise ResultFileInOldFormatError(file.name)
file.seek(saved_position)
+ def write(self, file):
+ # Serialize only the keys in serialized_keys.
+ keys = set(self.__dict__.keys()).intersection(self.serialized_keys)
+ raw_dict = dict([(k, self.__dict__[k]) for k in keys])
+ json.dump(raw_dict, file, indent=JSONWriter.INDENT)
+
+ def parseFile(self, file):
+ self.__checkFileIsNotInOldFormat(file)
raw_dict = json.load(file)
# Check that only expected keys were unserialized.