Changeset 61:8fe64b5932b9 in stamper
- Timestamp:
- Feb 13, 2015, 5:35:18 PM (10 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
bin/stamps
r55 r61 21 21 # Call the proper methods, based on the given parameters 22 22 if args.timeline: 23 s.timeline(args.customer, args.filter )23 s.timeline(args.customer, args.filter, args.description) 24 24 elif args.delete: 25 25 s.remove_stamps(args.delete) 26 26 elif args.graph: 27 s.graph_stamps(args.customer, args.filter )27 s.graph_stamps(args.customer, args.filter, args.description) 28 28 elif args.import_file: 29 29 s.import_stamps(args.import_file) 30 30 elif args.push: 31 s.push_stamps(args.customer, args.filter )31 s.push_stamps(args.customer, args.filter, args.description) 32 32 else: 33 s.show_stamps(args.customer, args.filter, args.verbose, args.sum) 33 s.show_stamps(args.customer, args.filter, args.verbose, args.sum, 34 args.description) -
stamper/cli.py
r55 r61 17 17 parser.add_argument('-t', '--timeline', action="store_true", 18 18 help='Show a timeline of recorded times') 19 parser.add_argument('-desc', '--description', action="store", 20 help='Filter results by the description in the stamp') 19 21 parser.add_argument('-d', '--delete', action="store", type=int, 20 22 help='Delete up to n recorded stamps') -
stamper/stamper.py
r60 r61 180 180 return customers 181 181 182 def totals(self, filter_from=None, filter_to=None ):182 def totals(self, filter_from=None, filter_to=None, filter_descr=None): 183 183 totals = {} 184 184 for stamp in self.stamps: … … 196 196 # similar for the end date 197 197 continue 198 if filter_descr and filter_descr not in stamp['action']: 199 continue 198 200 if customer not in totals: 199 201 totals[customer] = 0 … … 201 203 return totals 202 204 203 def details(self, filter_customer=None, filter_from=None, filter_to=None): 205 def details(self, filter_customer=None, filter_from=None, filter_to=None, 206 filter_descr=None): 204 207 details = OrderedDict() 205 208 totals = OrderedDict() … … 223 226 if filter_to and start > filter_to: 224 227 # similar for the end date 228 continue 229 if filter_descr and filter_descr not in stamp['action']: 225 230 continue 226 231 # avoid "start" stamps … … 246 251 return details, totals, total_customer 247 252 248 def timeline(self, customer=None, stamp_filter=None ):253 def timeline(self, customer=None, stamp_filter=None, filter_descr=None): 249 254 filter_from, filter_to = self.validate_filter(stamp_filter) 250 255 for stamp in self.stamps: … … 259 264 # similar for the end date 260 265 continue 261 266 if filter_descr and stamp['action']: 267 if filter_descr not in stamp['action']: 268 continue 262 269 if not stamp['customer']: 263 270 if customer is None: … … 272 279 stamp['action']])) 273 280 274 def graph_stamps(self, customer=None, stamp_filter=None ):281 def graph_stamps(self, customer=None, stamp_filter=None, filter_descr=None): 275 282 """ 276 283 Generate charts with information from the stamps … … 285 292 details, totals, totals_customers = self.details(customer, 286 293 filter_from, 287 filter_to) 294 filter_to, 295 filter_descr) 288 296 days = [] 289 297 values = {} … … 324 332 325 333 def show_stamps(self, customer=None, stamp_filter=None, verbose=False, 326 sum=False ):334 sum=False, filter_descr=None): 327 335 filter_from, filter_to = self.validate_filter(stamp_filter) 328 336 … … 332 340 details, totals, total_customer = self.details(customer, 333 341 filter_from, 334 filter_to) 342 filter_to, 343 filter_descr) 335 344 for day in details: 336 345 print('------ %(day)s ------' % {'day': day}) … … 349 358 350 359 # now calculate the totals and show them 351 totals = self.totals(filter_from, filter_to )360 totals = self.totals(filter_from, filter_to, filter_descr) 352 361 if customer: 353 362 seconds=totals.get(customer, 0) … … 431 440 print('[warning] remember to review the resulting stamps file') 432 441 433 def push_stamps(self, customer=None, stamp_filter=None ):442 def push_stamps(self, customer=None, stamp_filter=None, filter_descr=None): 434 443 filter_from, filter_to = self.validate_filter(stamp_filter) 435 444 … … 449 458 if filter_to and start > filter_to: 450 459 # similar for the end date 460 continue 461 if filter_descr and filter_descr not in stamp['action']: 451 462 continue 452 463 stamps.append(stamp)
Note:
See TracChangeset
for help on using the changeset viewer.