Commit 73241229 authored by Vincent Stehlé's avatar Vincent Stehlé
Browse files

Parser.py: add a csv option



Add the --csv command line option to generate a .csv file. This is handy to
manually triage issues in a spreadsheet.
Signed-off-by: Vincent Stehlé's avatarVincent Stehlé <vincent.stehle@arm.com>
parent dfffc5af
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import sys import sys
import argparse import argparse
import csv
#based loosley on https://stackoverflow.com/a/4391978 #based loosley on https://stackoverflow.com/a/4391978
...@@ -162,12 +163,29 @@ def dict_2_md(input_list,file): ...@@ -162,12 +163,29 @@ def dict_2_md(input_list,file):
file.write("\n\n") file.write("\n\n")
# Generate csv
def gen_csv(cross_check, filename):
# Find keys
keys = set()
for x in cross_check:
keys = keys.union(x.keys())
# Write csv
with open(filename, 'w', newline='') as csvfile:
writer = csv.DictWriter(
csvfile, fieldnames=sorted(keys), delimiter=';')
writer.writeheader()
writer.writerows(cross_check)
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Process SCT results.' description='Process SCT results.'
' This program takes the SCT summary and sequence files,' ' This program takes the SCT summary and sequence files,'
' and generates a nice report in mardown format.', ' and generates a nice report in mardown format.',
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--csv', help='Output .csv filename')
parser.add_argument( parser.add_argument(
'--md', help='Output .md filename', default='result.md') '--md', help='Output .md filename', default='result.md')
parser.add_argument( parser.add_argument(
...@@ -231,6 +249,9 @@ def main(): ...@@ -231,6 +249,9 @@ def main():
resultfile.write("\n\n") resultfile.write("\n\n")
key_tree_2_md(warnings,resultfile,"group") key_tree_2_md(warnings,resultfile,"group")
# Generate csv if requested
if args.csv is not None:
gen_csv(cross_check, args.csv)
#command line argument 3&4, key are to support a key & value search. #command line argument 3&4, key are to support a key & value search.
#these will be displayed in CLI #these will be displayed in CLI
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment