| 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 19 matching lines...) Expand all Loading... |
| 30 from functools import partial | 30 from functools import partial |
| 31 import json | 31 import json |
| 32 import optparse | 32 import optparse |
| 33 import os | 33 import os |
| 34 import subprocess | 34 import subprocess |
| 35 import sys | 35 import sys |
| 36 import urllib | 36 import urllib |
| 37 import urllib2 | 37 import urllib2 |
| 38 | 38 |
| 39 import auth | 39 import auth |
| 40 import fix_encoding |
| 40 import gerrit_util | 41 import gerrit_util |
| 41 import rietveld | 42 import rietveld |
| 42 from third_party import upload | 43 from third_party import upload |
| 43 | 44 |
| 44 try: | 45 try: |
| 45 from dateutil.relativedelta import relativedelta # pylint: disable=F0401 | 46 from dateutil.relativedelta import relativedelta # pylint: disable=F0401 |
| 46 except ImportError: | 47 except ImportError: |
| 47 print 'python-dateutil package required' | 48 print 'python-dateutil package required' |
| 48 exit(1) | 49 exit(1) |
| 49 | 50 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 required_values = { | 605 required_values = { |
| 605 'title': title, | 606 'title': title, |
| 606 'url': url, | 607 'url': url, |
| 607 'author': author, | 608 'author': author, |
| 608 } | 609 } |
| 609 # Merge required and optional values. | 610 # Merge required and optional values. |
| 610 if optional_values is not None: | 611 if optional_values is not None: |
| 611 values = dict(required_values.items() + optional_values.items()) | 612 values = dict(required_values.items() + optional_values.items()) |
| 612 else: | 613 else: |
| 613 values = required_values | 614 values = required_values |
| 614 print output_format.format(**values) | 615 print output_format.format(**values).encode(sys.getdefaultencoding()) |
| 615 | 616 |
| 616 | 617 |
| 617 def filter_issue(self, issue, should_filter_by_user=True): | 618 def filter_issue(self, issue, should_filter_by_user=True): |
| 618 def maybe_filter_username(email): | 619 def maybe_filter_username(email): |
| 619 return not should_filter_by_user or username(email) == self.user | 620 return not should_filter_by_user or username(email) == self.user |
| 620 if (maybe_filter_username(issue['author']) and | 621 if (maybe_filter_username(issue['author']) and |
| 621 self.filter_modified(issue['created'])): | 622 self.filter_modified(issue['created'])): |
| 622 return True | 623 return True |
| 623 if (maybe_filter_username(issue['owner']) and | 624 if (maybe_filter_username(issue['owner']) and |
| 624 (self.filter_modified(issue['created']) or | 625 (self.filter_modified(issue['created']) or |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 | 855 |
| 855 print '\n\n\n' | 856 print '\n\n\n' |
| 856 | 857 |
| 857 my_activity.print_changes() | 858 my_activity.print_changes() |
| 858 my_activity.print_reviews() | 859 my_activity.print_reviews() |
| 859 my_activity.print_issues() | 860 my_activity.print_issues() |
| 860 return 0 | 861 return 0 |
| 861 | 862 |
| 862 | 863 |
| 863 if __name__ == '__main__': | 864 if __name__ == '__main__': |
| 865 # Fix encoding to support non-ascii issue titles. |
| 866 fix_encoding.fix_encoding() |
| 867 |
| 864 try: | 868 try: |
| 865 sys.exit(main()) | 869 sys.exit(main()) |
| 866 except KeyboardInterrupt: | 870 except KeyboardInterrupt: |
| 867 sys.stderr.write('interrupted\n') | 871 sys.stderr.write('interrupted\n') |
| 868 sys.exit(1) | 872 sys.exit(1) |
| OLD | NEW |