Permalink
Browse files

Prettify the comment handling code

The code was iterating over all comments of a bug, and overwriting
the return string for all comments by the user.

This makes the intent much more explicit (only print something for
the last comment of a user on a given bug).
  • Loading branch information...
1 parent 17da476 commit b8b9b3ebec66d22d3effce4dbcb107a148b3ec61 @bochecha bochecha committed with Sep 19, 2012
Showing with 10 additions and 8 deletions.
  1. +10 −8 fedora_active_user.py
View
@@ -122,15 +122,17 @@ def _get_bugzilla_history(email, all_comments=False):
print('Last comment on the most recent ticket on bugzilla:')
ids = [bug.bug_id for bug in bugbz]
for bug in bzclient.getbugs(ids):
- string = None
log.debug(bug.bug_id)
- for com in bug.longdescs:
- if com['who'] == user.userid:
- string = ' #{0} {1} {2}'.format(bug.bug_id,
- com['time'].split(' ')[0],
- com['author'])
- if string:
- print(string)
+
+ user_coms = filter(lambda com: com["who"] == user.userid,
+ bug.longdescs)
+
+ if user_coms:
+ last_com = user_coms[-1]
+ print(' #{0} {1} {2}'.format(bug.bug_id,
+ last_com['time'].split(' ')[0],
+ last_com['author']))
+
if not all_comments:
break

0 comments on commit b8b9b3e

Please sign in to comment.