Print the modules path, so it's easier to go find that module

reviewable/pr18001/r3
Matt Martz 10 years ago committed by John Barker
parent 48ce4b7d70
commit 6b02c1c261

@ -48,7 +48,7 @@ class Validator(object):
"""Print out the test results""" """Print out the test results"""
if self.errors or (warnings and self.warnings): if self.errors or (warnings and self.warnings):
print('=' * 76) print('=' * 76)
print(self.object_name) print(self.object_path)
print('=' * 76) print('=' * 76)
ret = [] ret = []
@ -90,9 +90,10 @@ class ModuleValidator(Validator):
'setup.ps1' 'setup.ps1'
)) ))
def __init__(self, path): def __init__(self, path, root=None):
super(ModuleValidator, self).__init__() super(ModuleValidator, self).__init__()
self._root = root
self.path = path self.path = path
self.basename = os.path.basename(self.path) self.basename = os.path.basename(self.path)
self.name, _ = os.path.splitext(self.basename) self.name, _ = os.path.splitext(self.basename)
@ -109,6 +110,12 @@ class ModuleValidator(Validator):
def object_name(self): def object_name(self):
return self.basename return self.basename
@property
def object_path(self):
if self._root:
return self.path.replace(self._root, '').lstrip('/')
return self.object_name
def _python_module(self): def _python_module(self):
if self.path.endswith('.py'): if self.path.endswith('.py'):
return True return True
@ -318,9 +325,10 @@ class ModuleValidator(Validator):
class PythonPackageValidator(Validator): class PythonPackageValidator(Validator):
def __init__(self, path): def __init__(self, path, root=None):
super(PythonPackageValidator, self).__init__() super(PythonPackageValidator, self).__init__()
self._root = root
self.path = path self.path = path
self.basename = os.path.basename(path) self.basename = os.path.basename(path)
@ -328,6 +336,12 @@ class PythonPackageValidator(Validator):
def object_name(self): def object_name(self):
return self.basename return self.basename
@property
def object_path(self):
if self._root:
return self.path.replace(self._root, '').lstrip('/')
return self.object_name
def validate(self): def validate(self):
super(PythonPackageValidator, self).validate() super(PythonPackageValidator, self).validate()
@ -344,13 +358,13 @@ def main():
action='store_true') action='store_true')
args = parser.parse_args() args = parser.parse_args()
args.modules = args.modules.rstrip('/') args.modules = os.path.abspath(args.modules.rstrip('/'))
exit = [] exit = []
# Allow testing against a single file # Allow testing against a single file
if os.path.isfile(args.modules): if os.path.isfile(args.modules):
mv = ModuleValidator(os.path.abspath(args.modules)) mv = ModuleValidator(os.path.abspath(args.modules), root=args.modules)
mv.validate() mv.validate()
exit.append(mv.report(args.warnings)) exit.append(mv.report(args.warnings))
sys.exit(sum(exit)) sys.exit(sum(exit))
@ -363,13 +377,14 @@ def main():
if root == args.modules and dirname in BLACKLIST_DIRS: if root == args.modules and dirname in BLACKLIST_DIRS:
continue continue
path = os.path.join(root, dirname) path = os.path.join(root, dirname)
pv = PythonPackageValidator(os.path.abspath(path)) pv = PythonPackageValidator(os.path.abspath(path),
root=args.modules)
pv.validate() pv.validate()
exit.append(pv.report(args.warnings)) exit.append(pv.report(args.warnings))
for filename in files: for filename in files:
path = os.path.join(root, filename) path = os.path.join(root, filename)
mv = ModuleValidator(os.path.abspath(path)) mv = ModuleValidator(os.path.abspath(path), root=args.modules)
mv.validate() mv.validate()
exit.append(mv.report(args.warnings)) exit.append(mv.report(args.warnings))

Loading…
Cancel
Save