cleanup TimeSampleHistogram
authorDan White <dan@whiteaudio.com>
Fri, 6 Jun 2014 16:58:34 +0000 (11:58 -0500)
committerDan White <dan@whiteaudio.com>
Fri, 6 Jun 2014 16:58:34 +0000 (11:58 -0500)
TimeSampleHistogram

index ec7dde4b4506ded7b590b1308eafaa9c2bb2af13..244b841820197d25c44e5da4a4fcfba1a0e08fc4 100755 (executable)
@@ -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])