diff --git a/bugdaystats.py b/bugdaystats.py index 6d5af17..211fdd3 100755 --- a/bugdaystats.py +++ b/bugdaystats.py @@ -15,12 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. -import simplejson as json import os import sys import time -from jinja2 import Environment, FileSystemLoader + +from jinja2 import Environment +from jinja2 import FileSystemLoader from launchpadlib.launchpad import Launchpad +import simplejson as json def create_files(templatepath, outputpath, projects): @@ -146,23 +148,23 @@ def update_stats(outputpath, project_name, rotation, daily=False): if __name__ == '__main__': if len(sys.argv) < 2: - print >> sys.stderr, "No directory supplied" + print("No directory supplied", file=sys.stderr) basepath = os.path.dirname(sys.argv[0]) configpath = os.path.join(basepath, "config.js") templatepath = os.path.join(basepath, "templates") outputpath = sys.argv[1] if not os.path.isdir(outputpath): - print >> sys.stderr, '%s is not a directory' % outputpath + print('%s is not a directory' % outputpath, file=sys.stderr) sys.exit(1) if not os.path.isfile(configpath): - print >> sys.stderr, '%s does not contain config.js' % basepath + print('%s does not contain config.js' % basepath, file=sys.stderr) sys.exit(1) cachedir = os.path.expanduser("~/.launchpadlib/cache/") if not os.path.exists(cachedir): - os.makedirs(cachedir, 0700) + os.makedirs(cachedir, 0o0700) with open(configpath, 'r') as configfile: config = json.load(configfile) diff --git a/setup.py b/setup.py index d49c60a..881c817 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os from setuptools import setup setup( diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..b218ef5 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +hacking>=4.0.0,<4.1.0 # Apache-2.0 +flake8-logging-format>=0.6.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index f3e0fc3..404a87b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,25 @@ [tox] -envlist = pyflakes, pep8, py27 +minversion = 3.18.0 +skipsdist = True +envlist = pep8,py27 [testenv] -install_command = pip install --allow-external lazr.authentication --allow-insecure lazr.authentication -U {opts} {packages} +basepython = python3 +usedevelop = True +install_command=python -m pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages} -[testenv:pyflakes] -deps = pyflakes -commands = pyflakes bugdaystats.py +deps = -r{toxinidir}/test-requirements.txt [testenv:pep8] -deps = pep8==1.3.3 -commands = pep8 --ignore=E125 --repeat --show-source --exclude=.tox . +commands = + flake8 {posargs} . + +[flake8] +# The following checks are ignored on purpose. +# +# E125 unexpected spaces around keyword/parameter equals +# reason: no improvement in readability +ignore = E251 +exclude = .git,.venv,.tox,dist,tools,doc/ext,*egg,build +max-complexity = 30 +import-order-style = pep8