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

Side by Side Diff: my_activity.py

Issue 116873002: Add more formatting options for my_activity.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Review feedback Created 7 years 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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 except ImportError: 790 except ImportError:
791 print "Failed to import WebKit committer list, skipping WebKit checks." 791 print "Failed to import WebKit committer list, skipping WebKit checks."
792 self.webkit_repo = None 792 self.webkit_repo = None
793 return 793 return
794 794
795 if not webkit_account(self.user): 795 if not webkit_account(self.user):
796 email = self.user + "@chromium.org" 796 email = self.user + "@chromium.org"
797 print "No %s in committers.py, skipping WebKit checks." % email 797 print "No %s in committers.py, skipping WebKit checks." % email
798 self.webkit_repo = None 798 self.webkit_repo = None
799 799
800 def print_heading(self, heading):
801 print
802 print self.options.output_format_heading.format(heading=heading)
803
800 def print_change(self, change): 804 def print_change(self, change):
801 optional_values = { 805 optional_values = {
802 'reviewers': ', '.join(change['reviewers']) 806 'reviewers': ', '.join(change['reviewers'])
803 } 807 }
804 self.print_generic(self.options.output_format, 808 self.print_generic(self.options.output_format,
805 self.options.output_format_changes, 809 self.options.output_format_changes,
806 change['header'], 810 change['header'],
807 change['review_url'], 811 change['review_url'],
808 change['author'], 812 change['author'],
809 optional_values) 813 optional_values)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 self.changes += self.rietveld_search(instance, owner=self.user) 891 self.changes += self.rietveld_search(instance, owner=self.user)
888 892
889 for instance in gerrit_instances: 893 for instance in gerrit_instances:
890 self.changes += self.gerrit_search(instance, owner=self.user) 894 self.changes += self.gerrit_search(instance, owner=self.user)
891 895
892 for instance in git_instances: 896 for instance in git_instances:
893 self.changes += self.git_search(instance, owner=self.user) 897 self.changes += self.git_search(instance, owner=self.user)
894 898
895 def print_changes(self): 899 def print_changes(self):
896 if self.changes: 900 if self.changes:
897 print '\nChanges:' 901 self.print_heading('Changes')
898 for change in self.changes: 902 for change in self.changes:
899 self.print_change(change) 903 self.print_change(change)
900 904
901 def get_reviews(self): 905 def get_reviews(self):
902 for instance in rietveld_instances: 906 for instance in rietveld_instances:
903 self.reviews += self.rietveld_search(instance, reviewer=self.user) 907 self.reviews += self.rietveld_search(instance, reviewer=self.user)
904 908
905 for instance in gerrit_instances: 909 for instance in gerrit_instances:
906 reviews = self.gerrit_search(instance, reviewer=self.user) 910 reviews = self.gerrit_search(instance, reviewer=self.user)
907 reviews = filter(lambda r: not username(r['owner']) == self.user, reviews) 911 reviews = filter(lambda r: not username(r['owner']) == self.user, reviews)
908 self.reviews += reviews 912 self.reviews += reviews
909 913
910 for instance in git_instances: 914 for instance in git_instances:
911 self.reviews += self.git_search(instance, reviewer=self.user) 915 self.reviews += self.git_search(instance, reviewer=self.user)
912 916
913 def print_reviews(self): 917 def print_reviews(self):
914 if self.reviews: 918 if self.reviews:
915 print '\nReviews:' 919 self.print_heading('Reviews')
916 for review in self.reviews: 920 for review in self.reviews:
917 self.print_review(review) 921 self.print_review(review)
918 922
919 def get_issues(self): 923 def get_issues(self):
920 for project in google_code_projects: 924 for project in google_code_projects:
921 self.issues += self.google_code_issue_search(project) 925 self.issues += self.google_code_issue_search(project)
922 926
923 for instance in bugzilla_instances: 927 for instance in bugzilla_instances:
924 self.issues += self.bugzilla_issues(instance, self.user) 928 self.issues += self.bugzilla_issues(instance, self.user)
925 929
926 def print_issues(self): 930 def print_issues(self):
927 if self.issues: 931 if self.issues:
928 print '\nIssues:' 932 self.print_heading('Issues')
929 for issue in self.issues: 933 for issue in self.issues:
930 self.print_issue(issue) 934 self.print_issue(issue)
931 935
932 def process_activities(self): 936 def process_activities(self):
933 # If a webkit bug was a review, don't list it as an issue. 937 # If a webkit bug was a review, don't list it as an issue.
934 ids = {} 938 ids = {}
935 for review in self.reviews + self.changes: 939 for review in self.reviews + self.changes:
936 if 'webkit_bug_id' in review: 940 if 'webkit_bug_id' in review:
937 ids[review['webkit_bug_id']] = True 941 ids[review['webkit_bug_id']] = True
938 942
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 'additional variable {reviewers}') 1028 'additional variable {reviewers}')
1025 output_format_group.add_option( 1029 output_format_group.add_option(
1026 '--output-format-issues', metavar='<format>', 1030 '--output-format-issues', metavar='<format>',
1027 default=None, 1031 default=None,
1028 help='Specifies the format to use when printing issues. Supports the ' 1032 help='Specifies the format to use when printing issues. Supports the '
1029 'additional variable {owner}.') 1033 'additional variable {owner}.')
1030 output_format_group.add_option( 1034 output_format_group.add_option(
1031 '--output-format-reviews', metavar='<format>', 1035 '--output-format-reviews', metavar='<format>',
1032 default=None, 1036 default=None,
1033 help='Specifies the format to use when printing reviews.') 1037 help='Specifies the format to use when printing reviews.')
1038 output_format_group.add_option(
1039 '--output-format-heading', metavar='<format>',
1040 default=u'{heading}:',
1041 help='Specifies the format to use when printing headings.')
1042 output_format_group.add_option(
1043 '-m', '--markdown', action='store_true',
1044 help='Use markdown-friendly output (overrides --output-format '
1045 'and --output-format-heading)')
1034 parser.add_option_group(output_format_group) 1046 parser.add_option_group(output_format_group)
1035 1047
1036 # Remove description formatting 1048 # Remove description formatting
1037 parser.format_description = ( 1049 parser.format_description = (
1038 lambda _: parser.description) # pylint: disable=E1101 1050 lambda _: parser.description) # pylint: disable=E1101
1039 1051
1040 options, args = parser.parse_args() 1052 options, args = parser.parse_args()
1041 options.local_user = os.environ.get('USER') 1053 options.local_user = os.environ.get('USER')
1042 if args: 1054 if args:
1043 parser.error('Args unsupported') 1055 parser.error('Args unsupported')
(...skipping 12 matching lines...) Expand all
1056 else: 1068 else:
1057 begin, end = (get_week_of(datetime.today() - timedelta(days=1))) 1069 begin, end = (get_week_of(datetime.today() - timedelta(days=1)))
1058 else: 1070 else:
1059 begin = datetime.strptime(options.begin, '%m/%d/%y') 1071 begin = datetime.strptime(options.begin, '%m/%d/%y')
1060 if options.end: 1072 if options.end:
1061 end = datetime.strptime(options.end, '%m/%d/%y') 1073 end = datetime.strptime(options.end, '%m/%d/%y')
1062 else: 1074 else:
1063 end = datetime.today() 1075 end = datetime.today()
1064 options.begin, options.end = begin, end 1076 options.begin, options.end = begin, end
1065 1077
1078 if options.markdown:
1079 options.output_format = ' * [{title}]({url})'
1080 options.output_format_heading = '### {heading} ###'
1081
1066 print 'Searching for activity by %s' % options.user 1082 print 'Searching for activity by %s' % options.user
1067 print 'Using range %s to %s' % (options.begin, options.end) 1083 print 'Using range %s to %s' % (options.begin, options.end)
1068 1084
1069 my_activity = MyActivity(options) 1085 my_activity = MyActivity(options)
1070 1086
1071 if not (options.changes or options.reviews or options.issues): 1087 if not (options.changes or options.reviews or options.issues):
1072 options.changes = True 1088 options.changes = True
1073 options.issues = True 1089 options.issues = True
1074 options.reviews = True 1090 options.reviews = True
1075 1091
(...skipping 20 matching lines...) Expand all
1096 print '\n\n\n' 1112 print '\n\n\n'
1097 1113
1098 my_activity.print_changes() 1114 my_activity.print_changes()
1099 my_activity.print_reviews() 1115 my_activity.print_reviews()
1100 my_activity.print_issues() 1116 my_activity.print_issues()
1101 return 0 1117 return 0
1102 1118
1103 1119
1104 if __name__ == '__main__': 1120 if __name__ == '__main__':
1105 sys.exit(main()) 1121 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