mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
pep8 cleanup
This commit is contained in:
parent
b6c1bcb64d
commit
f0413bfd45
1 changed files with 13 additions and 5 deletions
|
@ -13,6 +13,7 @@ from ansible.utils.module_docs import get_docstring, BLACKLIST_MODULES
|
||||||
|
|
||||||
BLACKLIST_DIRS = frozenset(('.git',))
|
BLACKLIST_DIRS = frozenset(('.git',))
|
||||||
|
|
||||||
|
|
||||||
class Validator(object):
|
class Validator(object):
|
||||||
"""Validator instances are intended to be run on a single object. if you
|
"""Validator instances are intended to be run on a single object. if you
|
||||||
are scanning multiple objects for problems, you'll want to have a separate
|
are scanning multiple objects for problems, you'll want to have a separate
|
||||||
|
@ -57,7 +58,10 @@ class Validator(object):
|
||||||
|
|
||||||
class ModuleValidator(Validator):
|
class ModuleValidator(Validator):
|
||||||
BLACKLIST_PATTERNS = ('.git*', '*.pyc', '*.pyo', '.*')
|
BLACKLIST_PATTERNS = ('.git*', '*.pyc', '*.pyo', '.*')
|
||||||
BLACKLIST_FILES = frozenset(('.git', '.gitignore', '.travis.yml', '.gitattributes', '.gitmodules', 'COPYING', 'CONTRIBUTING.md', 'README.md', '__init__.py'))
|
BLACKLIST_FILES = frozenset(('.git', '.gitignore', '.travis.yml',
|
||||||
|
'.gitattributes', '.gitmodules', 'COPYING',
|
||||||
|
'CONTRIBUTING.md', 'README.md',
|
||||||
|
'__init__.py'))
|
||||||
BLACKLIST = BLACKLIST_FILES.union(BLACKLIST_MODULES)
|
BLACKLIST = BLACKLIST_FILES.union(BLACKLIST_MODULES)
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
@ -176,17 +180,20 @@ class ModuleValidator(Validator):
|
||||||
super(ModuleValidator, self).validate()
|
super(ModuleValidator, self).validate()
|
||||||
|
|
||||||
# Blacklists -- these files are not checked
|
# Blacklists -- these files are not checked
|
||||||
if not frozenset((self.basename, self.name)).isdisjoint(self.BLACKLIST):
|
if not frozenset((self.basename,
|
||||||
|
self.name)).isdisjoint(self.BLACKLIST):
|
||||||
return
|
return
|
||||||
for pat in self.BLACKLIST_PATTERNS:
|
for pat in self.BLACKLIST_PATTERNS:
|
||||||
if fnmatch(self.basename, pat):
|
if fnmatch(self.basename, pat):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._powershell_module():
|
if self._powershell_module():
|
||||||
self.warnings.append('Cannot check powershell modules at this time. Skipping')
|
self.warnings.append('Cannot check powershell modules at this '
|
||||||
|
'time. Skipping')
|
||||||
return
|
return
|
||||||
if not self._python_module():
|
if not self._python_module():
|
||||||
self.errors.append('Official Ansible modules must have a .py extension')
|
self.errors.append('Official Ansible modules must have a .py '
|
||||||
|
'extension')
|
||||||
return
|
return
|
||||||
if self.ast is None:
|
if self.ast is None:
|
||||||
self.errors.append('Python SyntaxError while parsing module')
|
self.errors.append('Python SyntaxError while parsing module')
|
||||||
|
@ -226,7 +233,8 @@ class PythonPackageValidator(Validator):
|
||||||
|
|
||||||
init_file = os.path.join(self.path, '__init__.py')
|
init_file = os.path.join(self.path, '__init__.py')
|
||||||
if not os.path.exists(init_file):
|
if not os.path.exists(init_file):
|
||||||
self.errors.append('Ansible module subdirectories must contain an __init__.py')
|
self.errors.append('Ansible module subdirectories must contain an '
|
||||||
|
'__init__.py')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue