From 7da752110a27b5c4cb8b24766d5f4e9ec91a2331 Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Thu, 6 Oct 2016 11:44:31 +1100 Subject: [PATCH] Switch to hacking and fix errors ./doc/source/_exts/candidates.py:20:1: H306 imports not in alphabetical order (jinja2.filesystemloader, jinja2.environment.environment) ./doc/source/_exts/events.py:17:1: H306 imports not in alphabetical order (os, calendar) ./doc/source/_exts/events.py:21:1: H306 imports not in alphabetical order (jinja2.filesystemloader, jinja2.environment.environment) ./openstack_election/check_candidacy.py:62:29: E126 continuation line over-indented for hanging indent ./openstack_election/utils.py:27:1: H306 imports not in alphabetical order (yaml, re) ./openstack_election/cmds/close_election.py:90:9: H232 Python 3.x incompatible octal 755 should be written as 0o755 ./openstack_election/tests/test_utils.py:25:21: E126 continuation line over-indented for hanging indent ./tools/new-election.py:18:31: H301 one import per line ./tools/new-election.py:27:5: H233 Python 3.x incompatible use of print operator ./tools/new-election.py:31:5: H233 Python 3.x incompatible use of print operator ./tools/new-election.py:41:5: H233 Python 3.x incompatible use of print operator Co-Authored-By: Nguyen Hung Phuong Change-Id: Idd9bc1f1f92da1658e6da2af588c575ee0ba2cb0 --- doc/source/_exts/candidates.py | 9 ++++----- doc/source/_exts/events.py | 11 +++++------ openstack_election/check_candidacy.py | 4 ++-- openstack_election/cmds/close_election.py | 2 +- openstack_election/tests/test_utils.py | 13 ++++++------- openstack_election/utils.py | 2 +- test-requirements.txt | 2 +- tools/new-election.py | 16 ++++++++++------ tox.ini | 2 +- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/doc/source/_exts/candidates.py b/doc/source/_exts/candidates.py index 8882249a..e115df65 100644 --- a/doc/source/_exts/candidates.py +++ b/doc/source/_exts/candidates.py @@ -13,19 +13,18 @@ """Build candidates list """ +import jinja2 +import jinja2.environment import os import yaml -from jinja2 import FileSystemLoader -from jinja2.environment import Environment - from openstack_election import utils def render_template(template, data, **kwargs): template_dir = kwargs.get('template_dir', os.getcwd()) - loader = FileSystemLoader(template_dir) - env = Environment(trim_blocks=True, loader=loader) + loader = jinja2.FileSystemLoader(template_dir) + env = jinja2.environment.Environment(trim_blocks=True, loader=loader) template = env.get_template(template) return template.render(data) diff --git a/doc/source/_exts/events.py b/doc/source/_exts/events.py index f93a86ce..af5d4bfd 100644 --- a/doc/source/_exts/events.py +++ b/doc/source/_exts/events.py @@ -13,13 +13,12 @@ """Add election timer data """ -import os import calendar +import jinja2 +import jinja2.environment +import os import time -from jinja2 import FileSystemLoader -from jinja2.environment import Environment - from openstack_election import utils @@ -46,8 +45,8 @@ def build_timer(app): output_file = os.path.join(utils.CANDIDATE_PATH, "events.rst") with open(output_file, "w") as out: template_dir = os.path.join(".", "doc", "source", "_exts") - loader = FileSystemLoader(template_dir) - env = Environment(trim_blocks=True, loader=loader) + loader = jinja2.FileSystemLoader(template_dir) + env = jinja2.environment.Environment(trim_blocks=True, loader=loader) template = env.get_template("events.jinja") out.write(template.render({'events': utils.conf['timelines']})) diff --git a/openstack_election/check_candidacy.py b/openstack_election/check_candidacy.py index 117bc48a..4f9fb4f5 100755 --- a/openstack_election/check_candidacy.py +++ b/openstack_election/check_candidacy.py @@ -59,8 +59,8 @@ def check_candidate(project_name, email, projects, limit=1): (repo_name, email)) for review in utils.get_reviews(query): url = ('%s/%s/commit/?id=%s' % ( - utils.CGIT_URL, review['project'], - review['current_revision'])) + utils.CGIT_URL, review['project'], + review['current_revision'])) print('%2d: %s %s' % (found, pretty_datetime(review['submitted']), url)) diff --git a/openstack_election/cmds/close_election.py b/openstack_election/cmds/close_election.py index 12c336fe..1f305905 100755 --- a/openstack_election/cmds/close_election.py +++ b/openstack_election/cmds/close_election.py @@ -87,7 +87,7 @@ def main(): args.outputdir = os.path.expanduser(args.outputdir) if not os.path.isdir(args.outputdir): - os.mkdir(args.outputdir, 0755) + os.mkdir(args.outputdir, 0o755) db_file = os.path.join(args.outputdir, "%s.yaml" % args.round) diff --git a/openstack_election/tests/test_utils.py b/openstack_election/tests/test_utils.py index 58bec26e..f0ed07d4 100644 --- a/openstack_election/tests/test_utils.py +++ b/openstack_election/tests/test_utils.py @@ -22,13 +22,12 @@ import openstack_election.utils class TestGerritUtils(testtools.TestCase): def test_candidate_files(self): review = {'revisions': { - 'Ifake': { - 'files': { - 'some/file': {}, - 'candidates/some/file': {}} - } - } - } + 'Ifake': { + 'files': { + 'some/file': {}, + 'candidates/some/file': {}} + } + }} self.assertEqual(openstack_election.utils.candidate_files(review), ['candidates/some/file']) diff --git a/openstack_election/utils.py b/openstack_election/utils.py index 21ffbf8e..dbd357f4 100644 --- a/openstack_election/utils.py +++ b/openstack_election/utils.py @@ -19,12 +19,12 @@ import json import os import pickle import pytz +import re import requests import subprocess import time import urllib import yaml -import re # Per election constants diff --git a/test-requirements.txt b/test-requirements.txt index 7f107c12..58171394 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,7 @@ # needed for doc build sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 -flake8>=2.5.4,<2.6.0 # MIT +hacking>=0.11.0,<0.12 # Apache-2.0 yamllint mock>=2.0 # BSD oslotest>=1.10.0 # Apache-2.0 diff --git a/tools/new-election.py b/tools/new-election.py index 49800743..f9845c7f 100755 --- a/tools/new-election.py +++ b/tools/new-election.py @@ -12,10 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals + import argparse import os -from utils import get_projects, name2dir +from openstack_election import utils parser = argparse.ArgumentParser() parser.add_argument('name', help='The release cycle name') @@ -24,21 +28,21 @@ options = parser.parse_args() os.chdir(options.root) if not os.path.isdir("candidates"): - print "candidates directory not found" + print("candidates directory not found") exit(1) if os.path.exists("candidates/%s" % options.name): - print "candidates/%s: directory already exists" % options.name + print("candidates/%s: directory already exists" % (options.name)) exit(1) -projects = get_projects() +projects = utils.get_projects() project_list = projects.keys() project_list.sort() for project in project_list + ["TC"]: - dpath = "candidates/%s/%s" % (options.name, name2dir(project)) + dpath = "candidates/%s/%s" % (options.name, utils.name2dir(project)) os.makedirs(dpath) open("%s/.placeholder" % dpath, "w").close() - print "[+] Created %s" % dpath + print("[+] Created %s" % (dpath)) print("Done. Now please manually update events.yaml and " "doc/source/index.rst substitutions") diff --git a/tox.ini b/tox.ini index 143287fa..4fa3aac7 100644 --- a/tox.ini +++ b/tox.ini @@ -25,4 +25,4 @@ commands = {posargs} commands = python setup.py build_sphinx [flake8] -exclude=.tox,doc/source/conf.py +exclude=.tox,doc/source/conf.py,rolls/owners.py