Changeset 22:43d14913e8fd in stamper
- Timestamp:
- Jul 23, 2014, 2:03:55 PM (10 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bin/stamps
r10 r22 15 15 parser.add_argument('-v', '--verbose', action="store_true", 16 16 help='Include detailed times information') 17 parser.add_argument('-s', '--sum', action="store_true", 18 help='Include sum of times') 17 19 18 20 args = parser.parse_args() … … 20 22 s = Stamper() 21 23 s.load_stamps() 22 s.show_stamps(args.customer, args.filter, args.verbose )24 s.show_stamps(args.customer, args.filter, args.verbose, args.sum) -
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.