Modified logic to account for tasks that are less than five minutes

remove_general
Trey Blancher 3 years ago
parent 52f9bb0f83
commit 34a5bc5bb2
  1. 24
      timetracker.py

@ -20,7 +20,7 @@ comment = re.compile("^\s*#") # regex for finding empty lines (and skipp
delim = re.compile(":\s{2}") # regex for splitting timestamp entry
begin = re.compile("^Begin\s(?P<action>.*)\s*$")
end = re.compile("^End\s{3}(?P<action>.*)\s*$")
incident = re.compile("^(PDROP|CHG)-?\d+")
case = re.compile("^(PDROP|CHG)-?\d+")
for line in fileinput.input():
if empty.match(line) or comment.match(line): # if the current line is empty
@ -66,15 +66,18 @@ for act in sorted(start.keys()):
print >> sys.stderr, "ERROR: Missing a Begin"
sys.exit(1)
sigma = 0
while (len(start[act]) > 0 and len(start[act]) > 0):
delta = 0
while (len(start[act]) > 0 and len(finish[act]) > 0):
beg = start[act].pop(0)
en = finish[act].pop(0)
sigma += en - beg
delta += en - beg
ind[act] = sigma
gtot += sigma
gtoth += nearest(sigma/3600)
ind[act] = delta
gtot += delta
if delta <= 300:
gtoth += 0.08
else:
gtoth += nearest(delta/3600.00)
ttot = 0
utot = 0
@ -84,12 +87,15 @@ table = "{a:<50} {f:>10}"
for act in sorted(ind.keys()):
#minutes = "{:d}min".format(int(ind[act]%3600/60))
#hrs = "{:d}hrs".format(int(nearest(ind[act]/3600)))
fhrs = "{:.2f}hrs".format(nearest(ind[act]/3600))
if ind[act] <= 300:
fhrs = "{:.2f}hrs".format(0.08)
else:
fhrs = "{:.2f}hrs".format(nearest(ind[act]/3600.00))
#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)
if incident.match(act):
if case.match(act):
ttot += ind[act]
else:
utot += ind[act]

Loading…
Cancel
Save