mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
Make modules accept multiple paths
This commit is contained in:
parent
a90e1c353e
commit
074661ef0e
1 changed files with 30 additions and 28 deletions
|
@ -587,48 +587,50 @@ def re_compile(value):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('modules', help='Path to module or module directory')
|
parser.add_argument('modules', nargs='+',
|
||||||
|
help='Path to module or module directory')
|
||||||
parser.add_argument('-w', '--warnings', help='Show warnings',
|
parser.add_argument('-w', '--warnings', help='Show warnings',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
parser.add_argument('--exclude', help='RegEx exclusion pattern',
|
parser.add_argument('--exclude', help='RegEx exclusion pattern',
|
||||||
type=re_compile)
|
type=re_compile)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
args.modules = args.modules.rstrip('/')
|
args.modules[:] = [m.rstrip('/') for m in args.modules]
|
||||||
|
|
||||||
exit = []
|
exit = []
|
||||||
|
|
||||||
# Allow testing against a single file
|
# Allow testing against a single file
|
||||||
if os.path.isfile(args.modules):
|
for module in args.modules:
|
||||||
path = args.modules
|
if os.path.isfile(module):
|
||||||
if args.exclude and args.exclude.search(path):
|
path = module
|
||||||
sys.exit(0)
|
|
||||||
mv = ModuleValidator(path)
|
|
||||||
mv.validate()
|
|
||||||
exit.append(mv.report(args.warnings))
|
|
||||||
sys.exit(sum(exit))
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(args.modules):
|
|
||||||
basedir = root[len(args.modules)+1:].split('/', 1)[0]
|
|
||||||
if basedir in BLACKLIST_DIRS:
|
|
||||||
continue
|
|
||||||
for dirname in dirs:
|
|
||||||
if root == args.modules and dirname in BLACKLIST_DIRS:
|
|
||||||
continue
|
|
||||||
path = os.path.join(root, dirname)
|
|
||||||
if args.exclude and args.exclude.search(path):
|
if args.exclude and args.exclude.search(path):
|
||||||
continue
|
sys.exit(0)
|
||||||
pv = PythonPackageValidator(path)
|
|
||||||
pv.validate()
|
|
||||||
exit.append(pv.report(args.warnings))
|
|
||||||
|
|
||||||
for filename in files:
|
|
||||||
path = os.path.join(root, filename)
|
|
||||||
if args.exclude and args.exclude.search(path):
|
|
||||||
continue
|
|
||||||
mv = ModuleValidator(path)
|
mv = ModuleValidator(path)
|
||||||
mv.validate()
|
mv.validate()
|
||||||
exit.append(mv.report(args.warnings))
|
exit.append(mv.report(args.warnings))
|
||||||
|
sys.exit(sum(exit))
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(module):
|
||||||
|
basedir = root[len(module)+1:].split('/', 1)[0]
|
||||||
|
if basedir in BLACKLIST_DIRS:
|
||||||
|
continue
|
||||||
|
for dirname in dirs:
|
||||||
|
if root == module and dirname in BLACKLIST_DIRS:
|
||||||
|
continue
|
||||||
|
path = os.path.join(root, dirname)
|
||||||
|
if args.exclude and args.exclude.search(path):
|
||||||
|
continue
|
||||||
|
pv = PythonPackageValidator(path)
|
||||||
|
pv.validate()
|
||||||
|
exit.append(pv.report(args.warnings))
|
||||||
|
|
||||||
|
for filename in files:
|
||||||
|
path = os.path.join(root, filename)
|
||||||
|
if args.exclude and args.exclude.search(path):
|
||||||
|
continue
|
||||||
|
mv = ModuleValidator(path)
|
||||||
|
mv.validate()
|
||||||
|
exit.append(mv.report(args.warnings))
|
||||||
|
|
||||||
sys.exit(sum(exit))
|
sys.exit(sum(exit))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue