| OLD | NEW |
| 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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 '-Q', '--last_quarter', action='store_true', | 716 '-Q', '--last_quarter', action='store_true', |
| 717 help='Use last quarter\'s dates, i.e. %s to %s' % ( | 717 help='Use last quarter\'s dates, i.e. %s to %s' % ( |
| 718 quarter_begin.strftime('%Y-%m-%d'), quarter_end.strftime('%Y-%m-%d'))) | 718 quarter_begin.strftime('%Y-%m-%d'), quarter_end.strftime('%Y-%m-%d'))) |
| 719 parser.add_option( | 719 parser.add_option( |
| 720 '-Y', '--this_year', action='store_true', | 720 '-Y', '--this_year', action='store_true', |
| 721 help='Use this year\'s dates') | 721 help='Use this year\'s dates') |
| 722 parser.add_option( | 722 parser.add_option( |
| 723 '-w', '--week_of', metavar='<date>', | 723 '-w', '--week_of', metavar='<date>', |
| 724 help='Show issues for week of the date') | 724 help='Show issues for week of the date') |
| 725 parser.add_option( | 725 parser.add_option( |
| 726 '-W', '--last_week', action='store_true', | 726 '-W', '--last_week', action='count', |
| 727 help='Show last week\'s issues') | 727 help='Show last week\'s issues. Use more times for more weeks.') |
| 728 parser.add_option( | 728 parser.add_option( |
| 729 '-a', '--auth', | 729 '-a', '--auth', |
| 730 action='store_true', | 730 action='store_true', |
| 731 help='Ask to authenticate for instances with no auth cookie') | 731 help='Ask to authenticate for instances with no auth cookie') |
| 732 | 732 |
| 733 activity_types_group = optparse.OptionGroup(parser, 'Activity Types', | 733 activity_types_group = optparse.OptionGroup(parser, 'Activity Types', |
| 734 'By default, all activity will be looked up and ' | 734 'By default, all activity will be looked up and ' |
| 735 'printed. If any of these are specified, only ' | 735 'printed. If any of these are specified, only ' |
| 736 'those specified will be searched.') | 736 'those specified will be searched.') |
| 737 activity_types_group.add_option( | 737 activity_types_group.add_option( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 options.user = username(options.user) | 801 options.user = username(options.user) |
| 802 | 802 |
| 803 if not options.begin: | 803 if not options.begin: |
| 804 if options.last_quarter: | 804 if options.last_quarter: |
| 805 begin, end = quarter_begin, quarter_end | 805 begin, end = quarter_begin, quarter_end |
| 806 elif options.this_year: | 806 elif options.this_year: |
| 807 begin, end = get_year_of(datetime.today()) | 807 begin, end = get_year_of(datetime.today()) |
| 808 elif options.week_of: | 808 elif options.week_of: |
| 809 begin, end = (get_week_of(datetime.strptime(options.week_of, '%m/%d/%y'))) | 809 begin, end = (get_week_of(datetime.strptime(options.week_of, '%m/%d/%y'))) |
| 810 elif options.last_week: | 810 elif options.last_week: |
| 811 begin, end = (get_week_of(datetime.today() - timedelta(days=7))) | 811 begin, end = (get_week_of(datetime.today() - |
| 812 timedelta(days=1 + 7 * options.last_week))) |
| 812 else: | 813 else: |
| 813 begin, end = (get_week_of(datetime.today() - timedelta(days=1))) | 814 begin, end = (get_week_of(datetime.today() - timedelta(days=1))) |
| 814 else: | 815 else: |
| 815 begin = datetime.strptime(options.begin, '%m/%d/%y') | 816 begin = datetime.strptime(options.begin, '%m/%d/%y') |
| 816 if options.end: | 817 if options.end: |
| 817 end = datetime.strptime(options.end, '%m/%d/%y') | 818 end = datetime.strptime(options.end, '%m/%d/%y') |
| 818 else: | 819 else: |
| 819 end = datetime.today() | 820 end = datetime.today() |
| 820 options.begin, options.end = begin, end | 821 options.begin, options.end = begin, end |
| 821 | 822 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 my_activity.print_issues() | 859 my_activity.print_issues() |
| 859 return 0 | 860 return 0 |
| 860 | 861 |
| 861 | 862 |
| 862 if __name__ == '__main__': | 863 if __name__ == '__main__': |
| 863 try: | 864 try: |
| 864 sys.exit(main()) | 865 sys.exit(main()) |
| 865 except KeyboardInterrupt: | 866 except KeyboardInterrupt: |
| 866 sys.stderr.write('interrupted\n') | 867 sys.stderr.write('interrupted\n') |
| 867 sys.exit(1) | 868 sys.exit(1) |
| OLD | NEW |