[Piglit] [PATCH 6/8] framework: use six to make python2 and 3 work in piglit-print-commands
Dylan Baker
baker.dylan.c at gmail.com
Wed Mar 30 18:18:37 UTC 2016
Use six.iteritems for iterating dictionaries, and conditionalize the
input conversion.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
piglit-print-commands.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/piglit-print-commands.py b/piglit-print-commands.py
index d23fc50..622d7fd 100755
--- a/piglit-print-commands.py
+++ b/piglit-print-commands.py
@@ -30,6 +30,8 @@ import argparse
import os
import sys
+import six
+
sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
from framework import options, profile
from framework.programs import parsers
@@ -53,7 +55,11 @@ def get_command(test, piglit_dir):
def main():
"""The main function."""
- input_ = [i.decode('utf-8') for i in sys.argv[1:]]
+ if six.PY2:
+ input_ = [i.decode('utf-8') for i in sys.argv[1:]]
+ elif six.PY3:
+ input_ = sys.argv[1:]
+
parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
parser.add_argument("-t", "--include-tests",
default=[],
@@ -82,7 +88,7 @@ def main():
profile_ = profile.load_test_profile(args.testProfile)
profile_._prepare_test_list()
- for name, test in profile_.test_list.items():
+ for name, test in six.iteritems(profile_.test_list):
assert isinstance(test, Test)
print(name, ':::', get_command(test, piglit_dir))
--
2.7.4
More information about the Piglit
mailing list