aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorspv <spv@spv.sh>2025-12-25 17:51:04 -0500
committerspv <spv@spv.sh>2025-12-25 17:51:04 -0500
commit591402473b9dc0d6b087588078b2643c52ded765 (patch)
tree7aa1484044ae7318ebb5325369f865c3e7365c03 /src
parent0c01714c06d2dfb91b759ba9852c79e815aa0ffd (diff)
sb_nueve, part 2: the nueve'ing
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sb_nueve73
1 files changed, 71 insertions, 2 deletions
diff --git a/src/sb_nueve b/src/sb_nueve
index 0c3fa0d..fed9749 100755
--- a/src/sb_nueve
+++ b/src/sb_nueve
@@ -15,7 +15,10 @@ def parse_hourly_report(report_fn):
ret = {}
for line in report.split("\n")[:-1]:
- key, val = line.split(',')
+ try:
+ key, val = line.split(',')
+ except:
+ print(report_fn)
if key == "total keypresses": val = int(val)
if key == "work time": val = float(val)
if key == "avg keys/sec": val = float(val) if val != "-nan" else None
@@ -89,7 +92,66 @@ def parse_for_week(day):
for x in range(weekday, -1, -1):
this_one = time.localtime(since_epoch - (x * 86400))
this_one_iso = time.strftime('%Y-%m-%d', this_one)
- parse_for_day(this_one_iso)
+ daily_report = parse_for_day(this_one_iso)
+
+ for x in daily_report:
+ if not x in weekly_report:
+ weekly_report[x] = daily_report[x]
+ else:
+ if type(daily_report[x]) == int:
+ weekly_report[x] += daily_report[x]
+
+ return weekly_report
+
+def parse_for_month(day):
+ tm = time.strptime(day, '%Y-%m-%d')
+ since_epoch = time.mktime(tm)
+ monthday = tm.tm_mday
+
+ print(tm)
+
+ monthly_report = {}
+
+ for x in range(0, tm.tm_mday):
+ this_one = time.localtime(since_epoch - (x * 86400))
+ this_one_iso = time.strftime('%Y-%m-%d', this_one)
+ try:
+ daily_report = parse_for_day(this_one_iso)
+ except:
+ pass # fuck you
+
+ for x in daily_report:
+ if not x in monthly_report:
+ monthly_report[x] = daily_report[x]
+ else:
+ if type(daily_report[x]) == int:
+ monthly_report[x] += daily_report[x]
+
+ return monthly_report
+
+def parse_for_year(day):
+ tm = time.strptime(day, '%Y-%m-%d')
+ since_epoch = time.mktime(tm)
+ yearday = tm.tm_yday
+
+ yearly_report = {}
+
+ for x in range(0, tm.tm_yday):
+ this_one = time.localtime(since_epoch - (x * 86400))
+ this_one_iso = time.strftime('%Y-%m-%d', this_one)
+ try:
+ daily_report = parse_for_day(this_one_iso)
+ except:
+ pass # fuck you
+
+ for x in daily_report:
+ if not x in yearly_report:
+ yearly_report[x] = daily_report[x]
+ else:
+ if type(daily_report[x]) == int:
+ yearly_report[x] += daily_report[x]
+
+ return yearly_report
def main():
parser = argparse.ArgumentParser(description='stroke_buddy statistics')
@@ -123,6 +185,13 @@ def main():
report = parse_for_day(time.strftime('%Y-%m-%d'))
if args.timeframe == 'w':
report = parse_for_week(time.strftime('%Y-%m-%d'))
+ print(report)
+ if args.timeframe == 'm':
+ report = parse_for_month(time.strftime('%Y-%m-%d'))
+ print(report)
+ if args.timeframe == 'y':
+ report = parse_for_year(time.strftime('%Y-%m-%d'))
+ print(report)
if args.action == 'c':
if args.timeframe == 't':