Changeset 22:43d14913e8fd in stamper for stamper
- Timestamp:
- Jul 23, 2014, 2:03:55 PM (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stamper/stamper.py
r19 r22 9 9 STAMPS_FILE = expanduser('~/.workstamps.json') 10 10 DATE_FORMAT = '%Y-%m-%d %H:%M' 11 HOURS_DAY = 8 12 SECS_DAY = HOURS_DAY * 60 * 60 11 13 12 14 … … 150 152 return details, totals 151 153 152 def show_stamps(self, customer=None, stamp_filter=None, verbose=False): 154 def show_stamps(self, customer=None, stamp_filter=None, verbose=False, 155 sum=False): 153 156 if stamp_filter: 154 157 stamp_filter = self.validate_filter(stamp_filter) … … 157 160 158 161 if customer: 159 total = timedelta(seconds=totals.get(customer, 0)) 162 seconds=totals.get(customer, 0) 163 total = timedelta(seconds) 160 164 print(' %(customer)s: %(total)s' % {'customer': customer, 161 165 'total': total}) 162 166 else: 163 167 for c in totals: 164 total = timedelta(seconds=totals[c]) 168 seconds=totals[c] 169 total = timedelta(seconds) 165 170 print(' %(customer)s: %(total)s' % {'customer': c, 166 171 'total': total}) … … 176 181 print(line) 177 182 print(' Total: %(total)s' % {'total': totals[day]}) 183 184 if sum: 185 sum_tot = '' 186 if totals: 187 print('------ Totals ------' % {'day': day}) 188 for day, tot in totals.iteritems(): 189 print(' %(day)s: %(total)s' % {'day': day, 'total': tot}) 190 sum_tot = "%(total)s %(new)s" % { 191 'total': sum_tot, 192 'new': total 193 } 194 totalSecs, sec = divmod(seconds, 60) 195 hr, min = divmod(totalSecs, 60) 196 totalDays, remaining = divmod(seconds, SECS_DAY) 197 remainingMin, remainingSec = divmod(remaining, (60)) 198 remainingHr, remainingMin = divmod(remainingMin, (60)) 199 print('----- %d:%02d:%02d -----' % (hr, min, sec)) 200 print('--- %d days, remaining: %d:%02d (%d hours/day) ---' % ( 201 totalDays, remainingHr, remainingMin, HOURS_DAY 202 ))
Note:
See TracChangeset
for help on using the changeset viewer.