From bda61c987af678ab62e98d2cbc58ab9ee5d83627 Mon Sep 17 00:00:00 2001 From: David Stern Date: Thu, 13 Dec 2018 16:19:29 +0000 Subject: [PATCH] Fixed missing 'setting' values in CSV output Setting was not being output correctly. Fixed. --- listrules.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/listrules.py b/listrules.py index 7ddcca2..b6da457 100644 --- a/listrules.py +++ b/listrules.py @@ -89,17 +89,17 @@ elif output_style=='csv': for column in desired_output_columns: # Add a comma to the output string, even if we will not output anything else, unless this is the very first desired output column if column is not desired_output_columns[0]: outstr=outstr+',' - if column in item: + if column=='setting': + # The setting value is derived from two columns: type and condition. + if 'condition' in item: + #print("Condition found") + outstr=outstr+'conditional '+item['type'] + else: + outstr=outstr+item['type'] + elif column in item: # This column is in the results item for this rule # Most columns are straight strings, but a few need special handling - if column=='setting': - # The setting value is derived from two columns: type and condition. - if 'condition' in item: - #print("Condition found") - outstr=outstr+'conditional '+item['type'] - else: - outstr=outstr+item['type'] - elif column in ['condition','description','reason']: + if column in ['condition','description','reason']: # The these strings can have values whcih contain commas, need we to quote them to avoid the commas being interpreted as column separators in the CSV outstr=outstr+'"'+item[column]+'"' elif column=='permissions': @@ -121,3 +121,4 @@ elif output_style=='csv': print(outstr) else: print "output_style can be json, simple or csv. You specified " + output_style + " which is invalid." +