pep8 job enable and fix pep8 reported issue

use flake8 as pep8 tools
enable check and gate for pep8(voting)
Fix below flake8 issues:
    E127 continuation line over-indented for visual indent
    E211 whitespace before '('
    E222 multiple spaces after operator
    E302 expected 2 blank lines, found 1
    E501 line too long (101 > 79 characters)
    E502 the backslash is redundant between brackets
    F401 'platform' imported but unused
    W391 blank line at end of file

Change-Id: Idfb953e52c8ee35c2adefdf0e4143a381c7f49e2
Story: 2003426
Task:  24596
Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
Sun Austin 2018-09-04 09:57:48 +08:00
parent fedb95ba79
commit 90ce692186
5 changed files with 29 additions and 19 deletions

View File

@ -2,9 +2,9 @@
- project: - project:
check: check:
jobs: jobs:
- openstack-tox-pep8:
voting: false
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-pep8
gate: gate:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-pep8

View File

@ -9,16 +9,17 @@ SPDX-License-Identifier: Apache-2.0
from __future__ import print_function from __future__ import print_function
import getopt import getopt
import os import os
import platform
import subprocess import subprocess
import sys import sys
import xml.etree.ElementTree as ElementTree import xml.etree.ElementTree as ElementTree
def usage(): def usage():
print("Usage: %s --groups <groups.xml> --pkgdir <pkgdir>" \ print("Usage: %s --groups <groups.xml> --pkgdir <pkgdir>"
% os.path.basename(sys.argv[0])) % os.path.basename(sys.argv[0]))
exit(1) exit(1)
def add_text_tag_to_xml(parent, def add_text_tag_to_xml(parent,
name, name,
text): text):
@ -108,18 +109,23 @@ def main():
usage() usage()
# Get the pkglist # Get the pkglist
cmd = "find %s -name '*.rpm' | xargs rpm -qp --queryformat '%%{NAME}\n'" % pkgdir cmd = "find %s -name '*.rpm' \
| xargs rpm -qp --queryformat '%%{NAME}\n'" % pkgdir
rpmlist = subprocess.check_output(cmd, shell=True).split() rpmlist = subprocess.check_output(cmd, shell=True).split()
tree = ElementTree.parse(groups_file) tree = ElementTree.parse(groups_file)
comps = tree.getroot() comps = tree.getroot()
comps.tail = '\n' comps.tail = '\n'
add_group(comps, 'controller', rpmlist, filter_dir, 'filter_out_from_controller') add_group(comps, 'controller', rpmlist,
add_group(comps, 'controller-compute', rpmlist, filter_dir, 'filter_out_from_smallsystem') filter_dir, 'filter_out_from_controller')
add_group(comps, 'controller-compute-lowlatency', rpmlist, filter_dir, 'filter_out_from_smallsystem_lowlatency') add_group(comps, 'controller-compute', rpmlist,
filter_dir, 'filter_out_from_smallsystem')
add_group(comps, 'controller-compute-lowlatency', rpmlist,
filter_dir, 'filter_out_from_smallsystem_lowlatency')
add_group(comps, 'compute', rpmlist, filter_dir, 'filter_out_from_compute') add_group(comps, 'compute', rpmlist, filter_dir, 'filter_out_from_compute')
add_group(comps, 'compute-lowlatency', rpmlist, filter_dir, 'filter_out_from_compute_lowlatency') add_group(comps, 'compute-lowlatency', rpmlist,
filter_dir, 'filter_out_from_compute_lowlatency')
add_group(comps, 'storage', rpmlist, filter_dir, 'filter_out_from_storage') add_group(comps, 'storage', rpmlist, filter_dir, 'filter_out_from_storage')
add_group(comps, 'controller') add_group(comps, 'controller')
@ -134,4 +140,3 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -1,3 +1,4 @@
bashate >= 0.2 bashate >= 0.2
PyYAML >= 3.1.0 PyYAML >= 3.1.0
yamllint >= 0.5.2 yamllint >= 0.5.2
flake8

12
tox.ini
View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = linters envlist = linters,pep8
minversion = 2.3 minversion = 2.3
skipsdist = True skipsdist = True
@ -33,11 +33,15 @@ commands =
[testenv:pep8] [testenv:pep8]
usedevelop = False usedevelop = False
skip_install = True
deps = deps =
pep8 flake8
description =
Run style checks
commands = commands =
pep8 flake8
[flake8]
show-source = True
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-*
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}