From 4d24f3ba610d6101857ddc9a9fb501d8639dd7b0 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 7 Oct 2015 15:23:00 -0500 Subject: [PATCH] Don't abspath things, and don't do root based magic --- ansible_testing/modules.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/ansible_testing/modules.py b/ansible_testing/modules.py index e94cf607a40..7acfbbb4d94 100644 --- a/ansible_testing/modules.py +++ b/ansible_testing/modules.py @@ -68,7 +68,8 @@ class Validator(object): ret = [] for trace in self.traces: - print(trace.replace(self._root, '').lstrip('/')) + #print(trace.replace(self._root, '').lstrip('/')) + print(trace) for error in self.errors: print('ERROR: %s' % error) ret.append(1) @@ -106,10 +107,9 @@ class ModuleValidator(Validator): 'setup.ps1' )) - def __init__(self, path, root=None): + def __init__(self, path): super(ModuleValidator, self).__init__() - self._root = root self.path = path self.basename = os.path.basename(self.path) self.name, _ = os.path.splitext(self.basename) @@ -128,9 +128,7 @@ class ModuleValidator(Validator): @property def object_path(self): - if self._root: - return self.path.replace(self._root, '').lstrip('/') - return self.object_name + return self.path def _python_module(self): if self.path.endswith('.py'): @@ -360,10 +358,9 @@ class ModuleValidator(Validator): class PythonPackageValidator(Validator): - def __init__(self, path, root=None): + def __init__(self, path): super(PythonPackageValidator, self).__init__() - self._root = root self.path = path self.basename = os.path.basename(path) @@ -373,9 +370,7 @@ class PythonPackageValidator(Validator): @property def object_path(self): - if self._root: - return self.path.replace(self._root, '').lstrip('/') - return self.object_name + return self.path def validate(self): super(PythonPackageValidator, self).validate() @@ -410,16 +405,16 @@ def main(): type=re_compile) args = parser.parse_args() - args.modules = os.path.abspath(args.modules.rstrip('/')) + args.modules = args.modules.rstrip('/') exit = [] # Allow testing against a single file if os.path.isfile(args.modules): - path = os.path.abspath(args.modules) + path = args.modules if args.exclude and args.exclude.search(path): sys.exit(0) - mv = ModuleValidator(path, root=args.modules) + mv = ModuleValidator(path) mv.validate() exit.append(mv.report(args.warnings)) sys.exit(sum(exit)) @@ -434,8 +429,7 @@ def main(): path = os.path.join(root, dirname) if args.exclude and args.exclude.search(path): continue - pv = PythonPackageValidator(os.path.abspath(path), - root=args.modules) + pv = PythonPackageValidator(path) pv.validate() exit.append(pv.report(args.warnings)) @@ -443,7 +437,7 @@ def main(): path = os.path.join(root, filename) if args.exclude and args.exclude.search(path): continue - mv = ModuleValidator(os.path.abspath(path), root=args.modules) + mv = ModuleValidator(path) mv.validate() exit.append(mv.report(args.warnings))