From 30fe02f133fc5282d61ce4e60ca3a4a69fb96bb4 Mon Sep 17 00:00:00 2001 From: Trey Blancher Date: Thu, 26 Aug 2021 17:00:10 -0400 Subject: [PATCH] Converted to Python3, round to nearest quarter hour --- timetracker.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/timetracker.py b/timetracker.py index ea7a28d..a969fb4 100755 --- a/timetracker.py +++ b/timetracker.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import fileinput import math @@ -7,7 +7,7 @@ import sys import time def nearest(hr): - return math.ceil(hr*4)/4 + return round(hr*4)/4 # Variables start = {} # Data structure for storing the beginning of a time frame @@ -58,12 +58,12 @@ for act in sorted(start.keys()): else: ec = 0 if bc - ec > 1: - print >> sys.stderr, "ERROR: Missing more than one End" + print("ERROR: Missing more than one End", file=sys.stderr) sys.exit(2) elif bc > ec: # bc should be exactly one greater start[act].pop() elif ec > bc: - print >> sys.stderr, "ERROR: Missing a Begin" + print("ERROR: Missing a Begin", file=sys.stderr) sys.exit(1) delta = 0 @@ -94,7 +94,7 @@ for act in sorted(ind.keys()): #sec = "{:d}s".format(int(ind[act])) #print table.format(a=act, s=sec, h=hrs, m=minutes, f=fhrs) - print table.format(a=act, f=fhrs) + print(table.format(a=act, f=fhrs)) # if case.match(act): # ttot += ind[act] # else: @@ -109,8 +109,8 @@ total = "{t:<20} {h:>10}" #gtots = "{:d}s".format(int(gtot)) gtoth = "{:3.2f}hrs".format(gtoth) -print +print() #print total.format(t="Incident total:", s=ttots, h=ttoth) #print total.format(t="Unnumbered total:", s=utots, h=utoth) -print total.format(t="Section total:", h=gtoth) +print(total.format(t="Section total:", h=gtoth))