Changeset 32:80a51180155e in stamper
- Timestamp:
- Aug 9, 2014, 10:04:58 AM (10 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bin/stamps
r30 r32 21 21 parser.add_argument('-t', '--timeline', action="store_true", 22 22 help='Show a timeline of recorded times') 23 parser.add_argument('-d', '--delete', action="store", type=int, 24 help='Delete up to n recorded stamps') 23 25 24 26 args = parser.parse_args() … … 36 38 if args.timeline: 37 39 s.timeline() 40 elif args.delete: 41 s.remove_stamps(args.delete) 38 42 elif args.graph: 39 43 s.graph_stamps(args.customer, args.filter) -
stamper/stamper.py
r30 r32 48 48 }) 49 49 50 def last_stamp(self): 50 def last_stamp(self, n=1): 51 """ 52 return the stamp in position -n, that is, starting from the latest one 53 and going back N positions in the list of stamps 54 """ 51 55 if not self.stamps: 52 56 return None 53 return self.stamps[- 1]57 return self.stamps[-n] 54 58 55 59 def worktime(self, start, end): … … 311 315 totalDays, remainingHr, remainingMin, HOURS_DAY 312 316 )) 317 318 def remove_stamps(self, n=1): 319 """ 320 Remove up to n stamps back, asking for confirmation before delete 321 """ 322 for i in range(n): 323 stamp = self.last_stamp() 324 if not stamp['customer']: 325 print(stamp['start'] + ' start') 326 else: 327 print(' '.join([stamp['end'], 328 stamp['customer'], 329 stamp['action']])) 330 confirm = '' 331 while confirm.lower() not in ['y', 'n']: 332 confirm = raw_input('delete stamp? (y/n) ') 333 confirm = confirm.lower() 334 if confirm == 'y': 335 self.stamps.pop() 336 else: 337 # if the user says no to the removal of an stamp, we cannot 338 # keep deleting stamps after that one, as that could leave the 339 # stamps in an inconsistent state. 340 print('Aborting removal of stamps') 341 break 342 self.save_stamps()
Note:
See TracChangeset
for help on using the changeset viewer.