On 05/06/2016 02:23 PM, Dylan Baker wrote:
Quoting Brian Paul (2016-05-03 15:50:01)
On 05/03/2016 03:59 PM, Dylan Baker wrote:
This option allows the format of the output string to be modified by
passing a command line argument. This allows for specialized formats to
be printed for other uses than the original usage that print-commands
was designed for.

Can you give an example of what the --format option would look like?

I think the help message below ("Format will be called with the {name}
will be replaced with the name of the test, and {command} with the test
command") is a bit scrambled.

-Brian




Signed-off-by: Dylan Baker <[email protected]>
---
   framework/programs/print_commands.py | 13 ++++++++++++-
   1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/framework/programs/print_commands.py 
b/framework/programs/print_commands.py
index 06bd004..c7ccf15 100755
--- a/framework/programs/print_commands.py
+++ b/framework/programs/print_commands.py
@@ -68,6 +68,15 @@ def main(input_):
                           metavar="<regex>",
                           help="Exclude matching tests (can be used more than "
                                "once)")
+    parser.add_argument("--format",
+                        dest="format_string",
+                        default="{name} ::: {command}",
+                        action="store",
+                        help="A python format string to be passed to "
+                             "str.format. Format will be called with the "
+                             "{name} will be replaced with the name of the "
+                             "test, and {command} with the test command. "
+                             "Neither are required.")
       parser.add_argument("testProfile",
                           metavar="<Path to testfile>",
                           help="Path to results folder")
@@ -85,4 +94,6 @@ def main(input_):
       profile_._prepare_test_list()
       for name, test in six.iteritems(profile_.test_list):
           assert isinstance(test, Test)
-        print(name, ':::', get_command(test, piglit_dir))
+        print(args.format_string.format(
+            name=name,
+            command=get_command(test, piglit_dir)))



What about something like this:

A template string that defines the output format. It has two replacement tokens
that can be provided, along with an arbitrary text, which will be printed
verbatim. The two tokens are '{name}', which will be replaced with the name of
the test; and '{command}', which will be replaced with the command to run the
test.


Sounds great.  Thanks.

-Brian

_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to