Chromium Code Reviews| Index: my_activity.py |
| diff --git a/my_activity.py b/my_activity.py |
| index 3bd13d7cae20b501a259ab9e24ac857c350317df..525db56863ea5d118822e9ad4762e17aabe774ab 100755 |
| --- a/my_activity.py |
| +++ b/my_activity.py |
| @@ -709,18 +709,18 @@ class MyActivity(object): |
| self.webkit_repo = None |
| @staticmethod |
| - def print_change(change): |
| - print '%s %s' % ( |
|
cjhopman
2012/12/17 23:03:51
Could this use string.format() instead of %?
nyquist
2012/12/19 07:08:11
Done.
|
| - change['review_url'], |
| - change['header'], |
| - ) |
| + def print_change(change, output_format): |
| + print output_format % { |
| + 'title': change['header'], |
| + 'url': change['review_url'] |
| + } |
| @staticmethod |
| - def print_issue(issue): |
| - print '%s %s' % ( |
| - issue['url'], |
| - issue['header'], |
| - ) |
| + def print_issue(issue, output_format): |
|
cjhopman
2012/12/17 23:08:27
To ensure that the different formatters are always
nyquist
2012/12/19 07:08:11
Done.
|
| + print output_format % { |
| + 'title': issue['header'], |
| + 'url': issue['url'], |
| + } |
| def filter_issue(self, issue, should_filter_by_user=True): |
| def maybe_filter_username(email): |
| @@ -773,7 +773,7 @@ class MyActivity(object): |
| if self.changes: |
| print '\nChanges:' |
| for change in self.changes: |
| - self.print_change(change) |
| + self.print_change(change, self.options.output_format) |
| def get_reviews(self): |
| for instance in rietveld_instances: |
| @@ -791,7 +791,7 @@ class MyActivity(object): |
| if self.reviews: |
| print '\nReviews:' |
| for review in self.reviews: |
| - self.print_change(review) |
| + self.print_change(review, self.options.output_format) |
| def get_issues(self): |
| for project in google_code_projects: |
| @@ -818,7 +818,7 @@ class MyActivity(object): |
| if self.issues: |
| print '\nIssues:' |
| for c in self.issues: |
| - self.print_issue(c) |
| + self.print_issue(c, self.options.output_format) |
| def print_activity(self): |
| self.print_changes() |
| @@ -861,7 +861,13 @@ def main(): |
| '-a', '--auth', |
| action='store_true', |
| help='Ask to authenticate for instances with no auth cookie') |
| - |
| + parser.add_option( |
| + '-f', '--output_format', |
| + dest='output_format', metavar='<format>', |
| + default='%(url)s %(title)s', |
| + help='Specifies the format to use when printing your activity.' |
| + ' Uses standard Python string formatting and defaults to:' |
| + ' %(url)s %(title)s') |
|
cjhopman
2012/12/17 23:08:27
Should the help also specify what named arguments
nyquist
2012/12/19 07:08:11
Done.
|
| group = optparse.OptionGroup(parser, 'Activity Types', |
| 'By default, all activity will be looked up and ' |
| 'printed. If any of these are specified, only ' |