Add pylint with indent check

This is an initial creation of pylint with a basic indent checker.
Small issues corrected.  Job added to gate with
Ib554a284e92583cc1d6a5c2219b3922852ca4c73

Change-Id: I7e24d8348db3aef79e1395d12692199a1f80161a
Co-Authored-By: Andreas Florath <andreas@florath.net>
This commit is contained in:
Ian Wienand 2017-05-29 16:05:35 +10:00
parent 3ac57740c6
commit 543dc1baa6
4 changed files with 25 additions and 10 deletions

View File

@ -27,15 +27,17 @@ data_dir = os.path.abspath(
def _populate_element(element_dir, element_name, element_deps=[], provides=[]): def _populate_element(element_dir, element_name, element_deps=[], provides=[]):
logger.debug("Populate %s <%s>" % (element_name, element_dir)) logger.debug("Populate %s <%s>" % (element_name, element_dir))
element_home = os.path.join(element_dir, element_name) element_home = os.path.join(element_dir, element_name)
os.mkdir(element_home) os.mkdir(element_home)
deps_path = os.path.join(element_home, 'element-deps') deps_path = os.path.join(element_home, 'element-deps')
with open(deps_path, 'w') as deps_file:
deps_file.write("\n".join(element_deps)) with open(deps_path, 'w') as deps_file:
deps_file.write("\n".join(element_deps))
provides_path = os.path.join(element_home, 'element-provides') provides_path = os.path.join(element_home, 'element-provides')
with open(provides_path, 'w') as provides_file:
provides_file.write("\n".join(provides)) with open(provides_path, 'w') as provides_file:
provides_file.write("\n".join(provides))
class TestElementDeps(testtools.TestCase): class TestElementDeps(testtools.TestCase):
@ -94,11 +96,11 @@ class TestElementDeps(testtools.TestCase):
# helper to return an (element, path) tuple from the standard dir # helper to return an (element, path) tuple from the standard dir
def _e(self, element): def _e(self, element):
return (element, os.path.join(self.element_dir, element)) return (element, os.path.join(self.element_dir, element))
# helper to return an (element, path) tuple from the override dir # helper to return an (element, path) tuple from the override dir
def _eo(self, element): def _eo(self, element):
return (element, os.path.join(self.element_override_dir, element)) return (element, os.path.join(self.element_override_dir, element))
def test_non_transitive_deps(self): def test_non_transitive_deps(self):
result = element_dependencies.get_elements(['requires-foo'], result = element_dependencies.get_elements(['requires-foo'],

7
pylint.cfg Normal file
View File

@ -0,0 +1,7 @@
[MASTER]
persistent=no
[MESSAGES CONTROL]
disable=all
enable=bad-indentation

View File

@ -2,6 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
hacking<0.11,>=0.10.0 hacking<0.11,>=0.10.0
pylint==1.4.5 # GPLv2
oslotest>=1.10.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD testrepository>=0.0.18 # Apache-2.0/BSD

View File

@ -16,6 +16,11 @@ commands =
flake8 {posargs} flake8 {posargs}
dib-lint dib-lint
[testenv:pylint]
setenv = VIRTUAL_ENV={envdir}
deps = pylint
commands = pylint --rcfile pylint.cfg diskimage_builder
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}