Skip to content

Commit

Permalink
Simplify a bit more the Bodhi code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Bridon authored and pypingou committed Oct 3, 2012
1 parent 4513fe2 commit b4e5796
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions fedora_active_user.py
Expand Up @@ -84,17 +84,16 @@ def _get_bodhi_history(username):
log.debug('Querying Bodhi for user: {0}'.format(username))
json_obj = bodhiclient.send_request("user/%s" % username)

date = None
pkg = None
for update in json_obj['updates']:
date2 = datetime.datetime.strptime(update['date_submitted'],
'%Y-%m-%d %H:%M:%S')
log.debug('Old date: {0} - New date: {1}'.format(date, date2))
if not date or date2 > date:
date = date2
pkg = update['title']
def dategetter(field):
def getter(item):
return datetime.datetime.strptime(item[field],
"%Y-%m-%d %H:%M:%S")

return getter

latest = sorted(json_obj['updates'], key=dategetter("date_submitted"))[-1]
print('Last package update on bodhi:')
print(' {0} on package {1}'.format(date, pkg))
print(' {0} on package {1}'.format(latest["date_submitted"], latest["title"]))


def _get_bugzilla_history(email, all_comments=False):
Expand Down

0 comments on commit b4e5796

Please sign in to comment.