Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: my_activity.py

Issue 230823003: Add --last_week/-W option to my_activity.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Get stats about your activity. 6 """Get stats about your activity.
7 7
8 Example: 8 Example:
9 - my_activity.py for stats for the current week (last week on mondays). 9 - my_activity.py for stats for the current week (last week on mondays).
10 - my_activity.py -Q for stats for last quarter. 10 - my_activity.py -Q for stats for last quarter.
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 parser.add_option( 695 parser.add_option(
696 '-b', '--begin', metavar='<date>', 696 '-b', '--begin', metavar='<date>',
697 help='Filter issues created after the date') 697 help='Filter issues created after the date')
698 parser.add_option( 698 parser.add_option(
699 '-e', '--end', metavar='<date>', 699 '-e', '--end', metavar='<date>',
700 help='Filter issues created before the date') 700 help='Filter issues created before the date')
701 quarter_begin, quarter_end = get_quarter_of(datetime.today() - 701 quarter_begin, quarter_end = get_quarter_of(datetime.today() -
702 relativedelta(months=2)) 702 relativedelta(months=2))
703 parser.add_option( 703 parser.add_option(
704 '-Q', '--last_quarter', action='store_true', 704 '-Q', '--last_quarter', action='store_true',
705 help='Use last quarter\'s dates, e.g. %s to %s' % ( 705 help='Use last quarter\'s dates, i.e. %s to %s' % (
szager1 2014/04/09 17:05:50 Thank you, that is a pet peeve of mine.
706 quarter_begin.strftime('%Y-%m-%d'), quarter_end.strftime('%Y-%m-%d'))) 706 quarter_begin.strftime('%Y-%m-%d'), quarter_end.strftime('%Y-%m-%d')))
707 parser.add_option( 707 parser.add_option(
708 '-Y', '--this_year', action='store_true', 708 '-Y', '--this_year', action='store_true',
709 help='Use this year\'s dates') 709 help='Use this year\'s dates')
710 parser.add_option( 710 parser.add_option(
711 '-w', '--week_of', metavar='<date>', 711 '-w', '--week_of', metavar='<date>',
712 help='Show issues for week of the date') 712 help='Show issues for week of the date')
713 parser.add_option( 713 parser.add_option(
714 '-W', '--last_week', action='store_true',
715 help='Show last week\'s issues')
716 parser.add_option(
714 '-a', '--auth', 717 '-a', '--auth',
715 action='store_true', 718 action='store_true',
716 help='Ask to authenticate for instances with no auth cookie') 719 help='Ask to authenticate for instances with no auth cookie')
717 720
718 activity_types_group = optparse.OptionGroup(parser, 'Activity Types', 721 activity_types_group = optparse.OptionGroup(parser, 'Activity Types',
719 'By default, all activity will be looked up and ' 722 'By default, all activity will be looked up and '
720 'printed. If any of these are specified, only ' 723 'printed. If any of these are specified, only '
721 'those specified will be searched.') 724 'those specified will be searched.')
722 activity_types_group.add_option( 725 activity_types_group.add_option(
723 '-c', '--changes', 726 '-c', '--changes',
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 787
785 options.user = username(options.user) 788 options.user = username(options.user)
786 789
787 if not options.begin: 790 if not options.begin:
788 if options.last_quarter: 791 if options.last_quarter:
789 begin, end = quarter_begin, quarter_end 792 begin, end = quarter_begin, quarter_end
790 elif options.this_year: 793 elif options.this_year:
791 begin, end = get_year_of(datetime.today()) 794 begin, end = get_year_of(datetime.today())
792 elif options.week_of: 795 elif options.week_of:
793 begin, end = (get_week_of(datetime.strptime(options.week_of, '%m/%d/%y'))) 796 begin, end = (get_week_of(datetime.strptime(options.week_of, '%m/%d/%y')))
797 elif options.last_week:
798 begin, end = (get_week_of(datetime.today() - timedelta(days=7)))
794 else: 799 else:
795 begin, end = (get_week_of(datetime.today() - timedelta(days=1))) 800 begin, end = (get_week_of(datetime.today() - timedelta(days=1)))
796 else: 801 else:
797 begin = datetime.strptime(options.begin, '%m/%d/%y') 802 begin = datetime.strptime(options.begin, '%m/%d/%y')
798 if options.end: 803 if options.end:
799 end = datetime.strptime(options.end, '%m/%d/%y') 804 end = datetime.strptime(options.end, '%m/%d/%y')
800 else: 805 else:
801 end = datetime.today() 806 end = datetime.today()
802 options.begin, options.end = begin, end 807 options.begin, options.end = begin, end
803 808
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 print '\n\n\n' 841 print '\n\n\n'
837 842
838 my_activity.print_changes() 843 my_activity.print_changes()
839 my_activity.print_reviews() 844 my_activity.print_reviews()
840 my_activity.print_issues() 845 my_activity.print_issues()
841 return 0 846 return 0
842 847
843 848
844 if __name__ == '__main__': 849 if __name__ == '__main__':
845 sys.exit(main()) 850 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698