Raise hacking version and fix pep8 errors

Various issues hit when switching to using stestr to run tests.
Presumably from other pulled in dependencies. This raises hacking to a
version that fixes a pyflakes issue [0] and addresses other pep8
violations that are then identified.

[0] https://github.com/PyCQA/pyflakes/pull/80

Change-Id: I9d8637d50067d6618aa408f4dbd9c736956099ed
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2019-04-26 08:56:43 -05:00 committed by Natal Ngétal
parent 39b1e03047
commit 58f2b47814
8 changed files with 32 additions and 43 deletions

View File

@ -14,7 +14,8 @@
from argparse import ArgumentParser from argparse import ArgumentParser
import bisect import bisect
from datetime import datetime, timedelta from datetime import datetime
from datetime import timedelta
import prettytable import prettytable
import sys import sys
from textwrap import dedent from textwrap import dedent
@ -37,7 +38,7 @@ offsets = {
} }
class Listener: class Listener(object):
def __init__(self, project_name, lp_projects): def __init__(self, project_name, lp_projects):
self.name = project_name self.name = project_name
@ -171,7 +172,7 @@ def main():
for project in projects: for project in projects:
lp_projects = project.get('lp_projects', []) lp_projects = project.get('lp_projects', [])
if not lp_projects: if not lp_projects:
print "Please specify a project." print("Please specify a project.")
return 1 return 1
listener = Listener(project['name'], lp_projects) listener = Listener(project['name'], lp_projects)
listeners.add(listener) listeners.add(listener)

View File

@ -51,7 +51,7 @@ def main(argv=None):
projects = utils.get_projects_info(options.project, options.all) projects = utils.get_projects_info(options.project, options.all)
if not projects: if not projects:
print "Please specify a project." print("Please specify a project.")
sys.exit(1) sys.exit(1)
changes = utils.get_changes(projects, options.user, options.key, changes = utils.get_changes(projects, options.user, options.key,
@ -76,8 +76,8 @@ def main(argv=None):
change['subject'])) change['subject']))
for x in approved_and_rebased: for x in approved_and_rebased:
print x print()
print "total %d" % len(approved_and_rebased) print("total %d" % len(approved_and_rebased))
def has_negative_feedback(patch_set): def has_negative_feedback(patch_set):

View File

@ -21,6 +21,8 @@ import logging
import optparse import optparse
import sys import sys
import six
from reviewstats import utils from reviewstats import utils
@ -174,7 +176,7 @@ def print_stats_txt(stats, f=sys.stdout):
print_item_txt(item, level) print_item_txt(item, level)
def print_item_txt(item, level): def print_item_txt(item, level):
if isinstance(item, basestring): if isinstance(item, six.text_type):
f.write('%s\n' % item.encode('utf-8')) f.write('%s\n' % item.encode('utf-8'))
elif isinstance(item, list): elif isinstance(item, list):
print_list_txt(item, level + 1) print_list_txt(item, level + 1)
@ -203,7 +205,7 @@ def print_stats_html(stats, f=sys.stdout):
f.write('</%s>\n' % ('ul' if level == 1 else 'ol')) f.write('</%s>\n' % ('ul' if level == 1 else 'ol'))
def print_item_html(item, level): def print_item_html(item, level):
if isinstance(item, basestring): if isinstance(item, six.text_type):
f.write('%s' % item.encode('utf-8')) f.write('%s' % item.encode('utf-8'))
elif isinstance(item, list): elif isinstance(item, list):
print_list_html(item, level + 1) print_list_html(item, level + 1)
@ -285,7 +287,7 @@ def main(argv=None):
base_dir=options.projects_dir) base_dir=options.projects_dir)
if not projects: if not projects:
print "Please specify a project." print("Please specify a project.")
sys.exit(1) sys.exit(1)
changes = utils.get_changes(projects, options.user, options.key, changes = utils.get_changes(projects, options.user, options.key,

View File

@ -169,12 +169,12 @@ def write_pretty(reviewer_data, file_obj, options, reviewers, projects,
file_obj.write( file_obj.write(
'\nTotal reviews: %d (%.1f/day)\n' % ( '\nTotal reviews: %d (%.1f/day)\n' % (
totals['all'], float(totals['all']) / options.days)) totals['all'], float(totals['all']) / options.days))
num_reviewers = len([r for r in reviewers if r[0]['total']]) num_reviewers = len([rev for rev in reviewers if rev[0]['total']])
file_obj.write( file_obj.write(
'Total reviewers: %d (avg %.1f reviews/day)\n' % ( 'Total reviewers: %d (avg %.1f reviews/day)\n' % (
num_reviewers, num_reviewers,
float(totals['all']) / options.days / num_reviewers float(totals['all']) / options.days / num_reviewers
if num_reviewers else 0)) if num_reviewers else 0))
file_obj.write('Total reviews by core team: %d (%.1f/day)\n' % ( file_obj.write('Total reviews by core team: %d (%.1f/day)\n' % (
totals['core'], float(totals['core']) / options.days)) totals['core'], float(totals['core']) / options.days))
@ -253,8 +253,8 @@ def main(argv=None):
optparser.add_option( optparser.add_option(
'-o', '--output', default='-', '-o', '--output', default='-',
help='Where to write output. If - stdout is used and only one output ' help='Where to write output. If - stdout is used and only one output '
'format may be given. Otherwise the output format is appended to ' 'format may be given. Otherwise the output format is appended to '
'the output parameter to generate file names.') 'the output parameter to generate file names.')
optparser.add_option( optparser.add_option(
'--outputs', default=['txt'], action='append', '--outputs', default=['txt'], action='append',
help='Select what outputs to generate. (txt,csv).') help='Select what outputs to generate. (txt,csv).')
@ -283,7 +283,7 @@ def main(argv=None):
projects = utils.get_projects_info(options.project, options.all) projects = utils.get_projects_info(options.project, options.all)
if not projects: if not projects:
print "Please specify a project." print("Please specify a project.")
sys.exit(1) sys.exit(1)
reviewers = {} reviewers = {}

View File

@ -40,7 +40,7 @@ def main():
project_name = projects[0]['name'] project_name = projects[0]['name']
if not projects: if not projects:
print "Please specify a project." print("Please specify a project.")
return 1 return 1
launchpad = Launchpad.login_with('openstack-releasing', 'production') launchpad = Launchpad.login_with('openstack-releasing', 'production')
@ -77,14 +77,14 @@ def main():
milestones.setdefault(milestone, []) milestones.setdefault(milestone, [])
milestones[milestone].append((change['url'], bugid)) milestones[milestone].append((change['url'], bugid))
print 'Reviews for bugs grouped by milestone for project: %s\n' % ( print('Reviews for bugs grouped by milestone for project: %s\n' % (
project_name) project_name))
for milestone, reviews in milestones.items(): for milestone, reviews in milestones.items():
if args.milestone and milestone != args.milestone: if args.milestone and milestone != args.milestone:
continue continue
print 'Milestone: %s' % milestone print('Milestone: %s' % milestone)
for review, bugid in reviews: for review, bugid in reviews:
print '--> %s -- https://bugs.launchpad.net/%s/+bug/%s' \ print('--> %s -- https://bugs.launchpad.net/%s/+bug/%s' %
% (review, project_name, bugid) (review, project_name, bugid))
print print()

View File

@ -1,13 +0,0 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -1,4 +1,4 @@
## -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2011 - Soren Hansen # Copyright (C) 2011 - Soren Hansen
# Copyright (C) 2013 - Red Hat, Inc. # Copyright (C) 2013 - Red Hat, Inc.
# #
@ -14,21 +14,20 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Utility functions module """Utility functions module"""
"""
import glob import glob
import gzip import gzip
import json import json
import logging import logging
import os import os
import requests
import requests.auth
from six.moves import cPickle as pickle
import time import time
import yaml import yaml
import paramiko import paramiko
import requests
import requests.auth
from six.moves import cPickle as pickle
from six.moves import cStringIO from six.moves import cStringIO
from six.moves import urllib from six.moves import urllib

View File

@ -1,4 +1,4 @@
hacking>=0.5.6,<0.8 hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
coverage>=3.6 coverage>=3.6
fixtures>=0.3.14 fixtures>=0.3.14