#
# [USAGE]
#
# This quick & dirty script will summarize the output
# generated by the isspam application.
# To use, you do:
# ./isspam ./your-content/*.txt > output.txt
# Then you execute: python totals.py output.txt
# - retoor
import sys
import pathlib
totals = {}
count = 0
with pathlib.Path(sys.argv[1]).open("r") as f:
data = f.read()
for line in data.split("\n"):
if line.startswith("<"):
continue
parts = line.split(": ")
if(len(parts) < 2):
continue
key = parts[0]
if key == "File":
count += 1
if not key in ["File","Memory usage"]:
if key not in totals:
totals[key] = 0.0
value = float(parts[1].replace("%",""))
totals[key] += value
else:
value = parts[1]
for key, value in totals.items():
print(key.count("percentage"))
if key.count("percentage") > 0:
value = value / count
print(key,":",value)