[Piglit] [PATCH 2/2] framework: Make csv summary a subset of formatted summary.

Dylan Baker dylan at pnwbakers.com
Sat Sep 30 03:26:43 UTC 2017


Quoting Rafael Antognolli (2017-09-29 12:00:05)
> It's really just about calling the formatted with a csv template.
> 
> Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
> ---
>  framework/programs/summary.py | 39 ++++++++-------------------------------
>  1 file changed, 8 insertions(+), 31 deletions(-)
> 
> diff --git a/framework/programs/summary.py b/framework/programs/summary.py
> index e21fa5fda..afb3460ce 100644
> --- a/framework/programs/summary.py
> +++ b/framework/programs/summary.py
> @@ -172,50 +172,27 @@ def console(input_):
>  
>  @exceptions.handler
>  def csv(input_):
> -    unparsed = parsers.parse_config(input_)[1]
> -
> -    # Adding the parent is necissary to get the help options
> -    parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
> -    parser.add_argument("-o", "--output",
> -                        metavar="<Output File>",
> -                        action="store",
> -                        dest="output",
> -                        default="stdout",
> -                        help="Output filename")
> -    parser.add_argument("testResults",
> -                        metavar="<Input Files>",
> -                        help="JSON results file to be converted")
> -    args = parser.parse_args(unparsed)
> -
> -    testrun = backends.load(args.testResults)
> -
> -    def write_results(output):
> -        for name, result in six.iteritems(testrun.tests):
> -            output.write("{},{},{},{}\n".format(name, result.time.total,
> -                                                result.returncode,
> -                                                result.result))
> -
> -    if args.output != "stdout":
> -        with open(args.output, 'w') as output:
> -            write_results(output)
> -    else:
> -        write_results(sys.stdout)
> +    format_string="{name},{time},{returncode},{result}"
> +    return formatted(input_, default_format_string=format_string)
>  
>  @exceptions.handler
> -def formatted(input_):
> +def formatted(input_, default_format_string=None):
>      # Make a copy of the status text list and add all. This is used as the
>      # argument list for -e/--exclude
>      statuses = set(str(s) for s in status.ALL)
>  
>      unparsed = parsers.parse_config(input_)[1]
>  
> +    if not default_format_string:
> +        default_format_string="{name} ::: {time} ::: " \
> +                              "{returncode} ::: {result}"
> +

If this is too long to put in the signature, how about as a constant at global
scope?

>      # Adding the parent is necissary to get the help options
>      parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
>      parser.add_argument("--format",
>                          dest="format_string",
>                          metavar="<format string>",
> -                        default="{name} ::: {time} ::: "
> -                                "{returncode} ::: {result}",
> +                        default=default_format_string,
>                          action="store",
>                          help="A template string that defines the format. "
>                               "Replacement tokens are {name}, {time}, "
> -- 
> 2.13.5
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20170929/e7625654/attachment.sig>


More information about the Piglit mailing list