From: Dan White Date: Fri, 6 Jun 2014 16:58:34 +0000 (-0500) Subject: cleanup TimeSampleHistogram X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=f6f9b4a3ea6cbb874d7304ef1ad3cd8b75d44ae1;p=pubbin.git cleanup TimeSampleHistogram --- diff --git a/TimeSampleHistogram b/TimeSampleHistogram index ec7dde4..244b841 100755 --- a/TimeSampleHistogram +++ b/TimeSampleHistogram @@ -68,7 +68,7 @@ def iso_year_start(iso_year): "The gregorian calendar date of the first day of the given ISO year" fourth_jan = dt.date(iso_year, 1, 4) delta = dt.timedelta(fourth_jan.isoweekday()-1) - return fourth_jan - delta + return fourth_jan - delta def iso_to_gregorian(iso_year, iso_week, iso_day): "Gregorian calendar date for the given ISO year, week and day" @@ -143,7 +143,8 @@ else: # read and parse timeSampler files # files = [f for f in os.listdir(os.environ['HOME']) - if f.startswith('.timeSampler') and not f.endswith('.gz')] + if f.startswith('.timeSampler') and not + (f.endswith('.gz') or f.endswith('.all'))] hist = defaultdict(lambda: 0) histHier = defaultdict(lambda: 0) @@ -180,11 +181,13 @@ for file in files: #print h.groups() # segregate non-gtd-project items - if len(t) < 3 or t[2] != '.': + #if len(t) < 3 or t[2] != '.': + if '.' not in t: #if t.lower() == t and t[0:2] != 'ed' or t == 'Tasks': histOther[t] += 1 else: - histGtd[t[0:2]] += 1 + a = t.split('.') + histGtd[a[0]] += 1 if hist: maxlen = max(map(len, hist.iterkeys())) @@ -248,7 +251,7 @@ for k,v in sorted(hist.iteritems(), cmp=sorter): if not opt.bare: print ('%%%is' % (name_len + count_len + 2)) % sum(hist.values()) - + if opt.gtd: if not opt.bare: @@ -259,6 +262,6 @@ if opt.gtd: print '%-5s %4i' % (k, histGtd[k]) print 'other %4i' % (sum(hist.values()) - sum(histGtd.values())) -#for k in sorted(histOther.keys()): - #print '%s: %3i' % (k, histOther[k]) + for k in sorted(histOther.keys()): + print '%s: %3i' % (k, histOther[k])