Skip to content

Instantly share code, notes, and snippets.

@eXeC64
Created February 24, 2015 13:22
Show Gist options
  • Save eXeC64/0b8c40d577e633e68418 to your computer and use it in GitHub Desktop.
Save eXeC64/0b8c40d577e633e68418 to your computer and use it in GitHub Desktop.
Pretty printer for coverity issue CSV files
#!/usr/bin/env python
import argparse, csv
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="pretty print a coverity issues csv file")
parser.add_argument("file",
type=str,
help="The csv file to parse")
parser.add_argument("-c",
dest="colors",
const=True,
default=False,
action="store_const",
help="Colorize output")
args = parser.parse_args()
if args.colors:
ENDC = "\033[0m"
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[32m"
BLUE = "\033[34m"
BOLD = "\033[1m"
else:
ENDC = ""
RED = ""
GREEN = ""
YELLOW = ""
BLUE = ""
BOLD = ""
with open(args.file, "r") as csv_file:
reader = csv.DictReader(csv_file)
for row in reader:
filename = row["File"].split("/")[-1]
if row["Owner"] == "Unassigned":
owner = RED + "Unassigned"
else:
owner = GREEN + row["Owner"]
if row["Status"] == "New":
status = RED + "New"
else:
status = BLUE + row["Status"]
if row["Function"] == "":
function = BLUE + "<outside function>"
else:
function = BLUE + row["Function"] + "()"
print(BOLD + " Issue: " + ENDC +
GREEN + row["CID"] + ENDC)
print(BOLD + " Type: " + ENDC +
BLUE + row["Type"] + ENDC)
print(BOLD + "Location: " + ENDC +
GREEN + filename + RED + ":" + function + ENDC)
print(BOLD + " Status: " + ENDC +
status + ENDC)
print(BOLD + " Owner: " + ENDC +
owner + ENDC)
print(BOLD + "Detected: " + ENDC +
row["First Detected"] + ENDC)
print("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment