summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2013-07-15 22:02:40 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2013-09-11 02:06:14 -0700
commitbf4e060e6b21eac1be12b6610dfcd24bb555d931 (patch)
tree71ae0125f9866aacd090b2052d5f2fb92b5ebc90
parent4f5548372c423e2d7a37073ee843c3b9fad81e2c (diff)
core.py: Move parse_listfile to core.py
Replaces the two individual implementations of parse_listfile with a single shared instance in core.py. Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com> Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r--framework/core.py19
-rwxr-xr-xpiglit-summary-html.py12
-rwxr-xr-xpiglit-summary.py9
3 files changed, 20 insertions, 20 deletions
diff --git a/framework/core.py b/framework/core.py
index 108b517ad..150a70c6b 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -615,7 +615,6 @@ def loadTestResults(relativepath):
assert(testrun.name is not None)
return testrun
-
# Error messages to be ignored
Test.ignoreErrors = map(re.compile,
["couldn't open libtxc_dxtn.so",
@@ -659,3 +658,21 @@ Test.ignoreErrors = map(re.compile,
".*DeviceName.*",
"No memory leaks detected.",
"libGL: Can't open configuration file.*"])
+
+
+def parse_listfile(filename):
+ """
+ Parses a newline-seperated list in a text file and returns a python list
+ object. It will expand tildes on Unix-like system to the users home
+ directory.
+
+ ex file.txt:
+ ~/tests1
+ ~/tests2/main
+ /tmp/test3
+
+ returns:
+ ['/home/user/tests1', '/home/users/tests2/main', '/tmp/test3']
+ """
+ with open(filename, 'r') as file:
+ return [path.expanduser(i.rstrip('\n')) for i in file.readlines()]
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index 6fed689d9..b9a299655 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -27,21 +27,11 @@ import shutil
import os.path as path
import framework.summary as summary
-from framework.core import checkDir
+from framework.core import checkDir, parse_listfile
sys.path.append(path.dirname(path.realpath(sys.argv[0])))
-def parse_listfile(filename):
- """
- Read a list of newline seperated flies and return them as a python list.
- strip the last newline character so the list doesn't have an extra ''
- element at the end.
- """
- with open(filename, 'r') as file:
- return [path.expanduser(i.rstrip('\n')) for i in file.readlines()]
-
-
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--overwrite",
diff --git a/piglit-summary.py b/piglit-summary.py
index 24bb30d2f..ebc01b84f 100755
--- a/piglit-summary.py
+++ b/piglit-summary.py
@@ -35,14 +35,7 @@ import sys
sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
import framework.summary as summary
-
-
-def parse_listfile(filename):
- """
- Read a list of newline seperated file names and return them as a list
- """
- with open(filename, 'r') as file:
- return [path.expanduser(i.rstrip('\n')) for i in file.readlines()]
+from framework.core import parse_listfile
def main():
parser = argparse.ArgumentParser()