From 56cc948e8e075b476123bf8b81682bf93cd8cfb7 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 25 Nov 2013 03:23:08 +0000 Subject: [PATCH] Tweak formatting for hacking. I'm about to bring in regular project infrastructure, this is a prelude to that. Change-Id: I58031c196ee4105a4f51c99bf7a9ad3a29d84c6b --- openreviews.py | 4 ++-- reviewers.py | 26 ++++++++++++++------------ testprojectinfo.py | 2 +- utils.py | 4 ++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/openreviews.py b/openreviews.py index 4c331f4..b8001f2 100755 --- a/openreviews.py +++ b/openreviews.py @@ -19,9 +19,9 @@ import calendar import datetime import getpass +import logging import optparse import sys -import logging import utils @@ -54,7 +54,7 @@ def quartile_age(changes, quartile=2, key='age'): if not changes: return 0 changes = sorted(changes, key=lambda change: change[key]) - quartile_age = changes[len(changes) * quartile/4][key] + quartile_age = changes[len(changes) * quartile / 4][key] return sec_to_period_string(quartile_age) diff --git a/reviewers.py b/reviewers.py index bb0888e..f695571 100755 --- a/reviewers.py +++ b/reviewers.py @@ -29,7 +29,7 @@ import utils def round_to_day(ts): - SECONDS_PER_DAY = 60*60*24 + SECONDS_PER_DAY = 60 * 60 * 24 return (ts / (SECONDS_PER_DAY)) * SECONDS_PER_DAY @@ -213,8 +213,8 @@ def main(argv=None): all_reviews = plus + minus ratio = ((plus / (all_reviews)) * 100) if all_reviews > 0 else 0 r = (k['total'], k['votes']['-2'], - k['votes']['-1'], k['votes']['1'], - k['votes']['2'], k['votes']['A'], "%5.1f%%" % ratio) + k['votes']['-1'], k['votes']['1'], + k['votes']['2'], k['votes']['A'], "%5.1f%%" % ratio) dratio = (((float(k['disagreements']) / all_reviews) * 100) if all_reviews else 0.0) d = (k['disagreements'], "%5.1f%%" % dratio) @@ -247,7 +247,8 @@ def main(argv=None): 'Reviews for the last %d days in projects: %s\n' % (options.days, [project['name'] for project in projects])) else: - file_obj.write('Reviews for the last %d days in %s\n' + file_obj.write( + 'Reviews for the last %d days in %s\n' % (options.days, projects[0]['name'])) if options.all: file_obj.write( @@ -256,11 +257,12 @@ def main(argv=None): file_obj.write( '** -- %s-core team member\n' % projects[0]['name']) writer(reviewer_data, file_obj) - file_obj.write('\nTotal reviews: %d (%.1f/day)\n' % (total, - float(total) / options.days)) - file_obj.write('Total reviewers: %d (avg %.1f reviews/day)\n' % ( - len(reviewers), - float(total) / options.days / len(reviewers))) + file_obj.write( + '\nTotal reviews: %d (%.1f/day)\n' % ( + total, float(total) / options.days)) + file_obj.write( + 'Total reviewers: %d (avg %.1f reviews/day)\n' % ( + len(reviewers), float(total) / options.days / len(reviewers))) file_obj.write('Total reviews by core team: %d (%.1f/day)\n' % ( core_total, float(core_total) / options.days)) core_team_size = sum([len(project['core-team']) @@ -304,9 +306,9 @@ def main(argv=None): ' Average number of patches per changeset: %.1f\n' % (float(patches_created) / changes_involved)) file_obj.write( - '\n(*) Disagreements are defined as a +1 or +2 vote on a ' \ - 'patch where a core team member later gave a -1 or -2 vote' \ - ', or a negative vote overridden with a positive one ' \ + '\n(*) Disagreements are defined as a +1 or +2 vote on a ' + 'patch where a core team member later gave a -1 or -2 vote' + ', or a negative vote overridden with a positive one ' 'afterwards.\n') file_obj.write( '\n(***) Received - the number of reviews that this person ' diff --git a/testprojectinfo.py b/testprojectinfo.py index 1adbc61..6aec6b9 100755 --- a/testprojectinfo.py +++ b/testprojectinfo.py @@ -24,7 +24,7 @@ import utils def main(): logging.basicConfig(level=logging.DEBUG) # Make sure all projects info load successfully - projects = utils.get_projects_info('', True) + utils.get_projects_info('', True) return 0 diff --git a/utils.py b/utils.py index 89595d7..bd32f56 100644 --- a/utils.py +++ b/utils.py @@ -18,11 +18,11 @@ import cPickle as pickle import glob import json -import paramiko +import logging import os import time -import logging +import paramiko CACHE_AGE = 3600 # Seconds