Loading tools/warn/html_writer.py +25 −0 Original line number Original line Diff line number Diff line Loading @@ -359,6 +359,25 @@ def dump_csv(csvwriter, warn_patterns): csvwriter.writerow([total, '', 'All warnings']) csvwriter.writerow([total, '', 'All warnings']) def dump_csv_with_description(csvwriter, warning_records, warning_messages, warn_patterns, project_names): """Outputs all the warning messages by project.""" csv_output = [] for record in warning_records: project_name = project_names[record[1]] pattern = warn_patterns[record[0]] severity = pattern['severity'].header category = pattern['category'] description = pattern['description'] warning = warning_messages[record[2]] csv_output.append([project_name, severity, category, description, warning]) csv_output = sorted(csv_output) for output in csv_output: csvwriter.writerow(output) # Return s with escaped backslash and quotation characters. # Return s with escaped backslash and quotation characters. def escape_string(s): def escape_string(s): return s.replace('\\', '\\\\').replace('"', '\\"') return s.replace('\\', '\\\\').replace('"', '\\"') Loading Loading @@ -666,6 +685,12 @@ def write_out_csv(flags, warn_patterns, warning_messages, warning_links, with open(flags.csvpath, 'w') as f: with open(flags.csvpath, 'w') as f: dump_csv(csv.writer(f, lineterminator='\n'), warn_patterns) dump_csv(csv.writer(f, lineterminator='\n'), warn_patterns) if flags.csvwithdescription: with open(flags.csvwithdescription, 'w') as f: dump_csv_with_description(csv.writer(f, lineterminator='\n'), warning_records, warning_messages, warn_patterns, project_names) if flags.gencsv: if flags.gencsv: dump_csv(csv.writer(sys.stdout, lineterminator='\n'), warn_patterns) dump_csv(csv.writer(sys.stdout, lineterminator='\n'), warn_patterns) else: else: Loading tools/warn/warn_common.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,9 @@ def parse_args(use_google3): help='Save CSV warning file to the passed path') help='Save CSV warning file to the passed path') parser.add_argument('--gencsv', action='store_true', parser.add_argument('--gencsv', action='store_true', help='Generate CSV file with number of various warnings') help='Generate CSV file with number of various warnings') parser.add_argument('--csvwithdescription', default='', help="""Save CSV warning file to the passed path this csv will contain all the warning descriptions""") parser.add_argument('--byproject', action='store_true', parser.add_argument('--byproject', action='store_true', help='Separate warnings in HTML output by project names') help='Separate warnings in HTML output by project names') parser.add_argument('--url', default='', parser.add_argument('--url', default='', Loading Loading
tools/warn/html_writer.py +25 −0 Original line number Original line Diff line number Diff line Loading @@ -359,6 +359,25 @@ def dump_csv(csvwriter, warn_patterns): csvwriter.writerow([total, '', 'All warnings']) csvwriter.writerow([total, '', 'All warnings']) def dump_csv_with_description(csvwriter, warning_records, warning_messages, warn_patterns, project_names): """Outputs all the warning messages by project.""" csv_output = [] for record in warning_records: project_name = project_names[record[1]] pattern = warn_patterns[record[0]] severity = pattern['severity'].header category = pattern['category'] description = pattern['description'] warning = warning_messages[record[2]] csv_output.append([project_name, severity, category, description, warning]) csv_output = sorted(csv_output) for output in csv_output: csvwriter.writerow(output) # Return s with escaped backslash and quotation characters. # Return s with escaped backslash and quotation characters. def escape_string(s): def escape_string(s): return s.replace('\\', '\\\\').replace('"', '\\"') return s.replace('\\', '\\\\').replace('"', '\\"') Loading Loading @@ -666,6 +685,12 @@ def write_out_csv(flags, warn_patterns, warning_messages, warning_links, with open(flags.csvpath, 'w') as f: with open(flags.csvpath, 'w') as f: dump_csv(csv.writer(f, lineterminator='\n'), warn_patterns) dump_csv(csv.writer(f, lineterminator='\n'), warn_patterns) if flags.csvwithdescription: with open(flags.csvwithdescription, 'w') as f: dump_csv_with_description(csv.writer(f, lineterminator='\n'), warning_records, warning_messages, warn_patterns, project_names) if flags.gencsv: if flags.gencsv: dump_csv(csv.writer(sys.stdout, lineterminator='\n'), warn_patterns) dump_csv(csv.writer(sys.stdout, lineterminator='\n'), warn_patterns) else: else: Loading
tools/warn/warn_common.py +3 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,9 @@ def parse_args(use_google3): help='Save CSV warning file to the passed path') help='Save CSV warning file to the passed path') parser.add_argument('--gencsv', action='store_true', parser.add_argument('--gencsv', action='store_true', help='Generate CSV file with number of various warnings') help='Generate CSV file with number of various warnings') parser.add_argument('--csvwithdescription', default='', help="""Save CSV warning file to the passed path this csv will contain all the warning descriptions""") parser.add_argument('--byproject', action='store_true', parser.add_argument('--byproject', action='store_true', help='Separate warnings in HTML output by project names') help='Separate warnings in HTML output by project names') parser.add_argument('--url', default='', parser.add_argument('--url', default='', Loading