diff --git a/2015.04/required.py b/2015.04/required.py index 8e7b96f7..b73efef9 100644 --- a/2015.04/required.py +++ b/2015.04/required.py @@ -1,13 +1,12 @@ import json -import urllib -capabilities_file = open('../2015.04.json','r') +capabilities_file = open('../2015.04.json', 'r') defcore = json.loads(capabilities_file.read()) capabilities = defcore['capabilities'] required_tests = [] flagged_tests = [] -required_tests_file = open('2015.04.required.txt','w') +required_tests_file = open('2015.04.required.txt', 'w') flagged_tests_file = open('2015.04.flagged.txt', 'w') for capability_name in capabilities: diff --git a/2015.05/required.py b/2015.05/required.py index a534594e..555d2684 100644 --- a/2015.05/required.py +++ b/2015.05/required.py @@ -1,13 +1,12 @@ import json -import urllib -capabilities_file = open('../2015.05.json','r') +capabilities_file = open('../2015.05.json', 'r') defcore = json.loads(capabilities_file.read()) capabilities = defcore['capabilities'] required_tests = [] flagged_tests = [] -required_tests_file = open('2015.05.required.txt','w') +required_tests_file = open('2015.05.required.txt', 'w') flagged_tests_file = open('2015.05.flagged.txt', 'w') for capability_name in capabilities: diff --git a/organize.py b/organize.py index 68559675..ee887143 100644 --- a/organize.py +++ b/organize.py @@ -1,7 +1,7 @@ import json -defcore = json.loads(open('2015.next.json','r').read()) -new_caps = json.loads(open('newcaps.json','r').read()) +defcore = json.loads(open('2015.next.json', 'r').read()) +new_caps = json.loads(open('newcaps.json', 'r').read()) capabilities = {} @@ -56,4 +56,5 @@ for capability in capabilities: cap["required-since"] = ", ".join(cap["required-since"]) cap["description"] = ", ".join(cap["description"]) cap["project"] = ", ".join(cap["project"]) -print json.dumps(capabilities, sort_keys=True, indent=2, separators=(',', ': ')) +print json.dumps(capabilities, sort_keys=True, indent=2, + separators=(',', ': ')) diff --git a/tools/flake8wrap.sh b/tools/flake8wrap.sh new file mode 100755 index 00000000..42a66bee --- /dev/null +++ b/tools/flake8wrap.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# A simple wrapper around flake8 which makes it possible +# to ask it to only verify files changed in the current +# git HEAD patch. +# +# Intended to be invoked via tox: +# +# tox -epep8 -- -HEAD +# +# Lovingly borrowed from openstack/nova. + +if test "x$1" = "x-HEAD" ; then + shift + files=$(git diff --name-only HEAD~1 | tr '\n' ' ') + echo "Running flake8 on ${files}" + diff -u --from-file /dev/null ${files} | flake8 --diff "$@" +else + echo "Running flake8 on all files" + exec flake8 "$@" +fi diff --git a/tools/jsonToRst.py b/tools/jsonToRst.py index bc236857..7545ef02 100755 --- a/tools/jsonToRst.py +++ b/tools/jsonToRst.py @@ -66,9 +66,9 @@ with open(outFileName, "w") as outFile: line01 = "OpenStack DefCore %s" % data["id"] - outFile.write('='*len(line01) + '\n') + outFile.write('=' * len(line01) + '\n') outFile.write(line01 + '\n') - outFile.write('='*len(line01) + '\n') + outFile.write('=' * len(line01) + '\n') # Nonlooping if data.get('platform') is None: @@ -76,7 +76,8 @@ with open(outFileName, "w") as outFile: sys.exit(1) # Correct Source - if data.get('source') != 'http://git.openstack.org/cgit/openstack/defcore/': + if data.get('source') != \ + 'http://git.openstack.org/cgit/openstack/defcore/': print "The expected DefCore source not found" sys.exit(1) @@ -128,7 +129,7 @@ Platform Components {component} Component Capabilities """.format(component=component.capitalize())) - outFile.write('='*(len(component) + 23)) # footer + outFile.write('=' * (len(component) + 23)) # footer for event in order: @@ -142,7 +143,8 @@ Platform Components for req in data['components'][component][event]: outFile.write("* {name} ({project})\n".format( name=req, - project=data["capabilities"][req].get("project").capitalize())) + project=data["capabilities"][req].get( + "project").capitalize())) # Designated -Sections @@ -164,7 +166,7 @@ this specification.""") outFile.write('\n\n{event} Designated Sections\n'.format( event=event.capitalize())) # +20 is for length of header - outFile.write('-'*(len(event) + 20) + '\n\n') + outFile.write('-' * (len(event) + 20) + '\n\n') names = sorted(desig[event].keys()) if len(names) is 0: diff --git a/tox.ini b/tox.ini index 65d460a0..9de0a2c7 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +envlist = docs,doc8,pep8 minversion = 1.6 skipsdist = True @@ -18,3 +19,20 @@ commands = [testenv:docs] commands= python setup.py build_sphinx + +[testenv:pep8] +basepython = python2.7 +deps = + {[testenv]deps} +commands= + bash tools/flake8wrap.sh +whitelist_externals = + sh + bash + +[flake8] +# E125 is deliberately excluded. +# See https://github.com/jcrocholl/pep8/issues/126 + +ignore = E125 +exclude = .venv,.git,.tox,doc,conf.py