diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2018-01-11 10:20:37 -0500 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2018-01-11 10:20:37 -0500 |
commit | 50d840aceab7afffc7dcbf9732e8d65a7cadb459 (patch) | |
tree | e9428954da288382033f990e880ea11fa82a5964 /tools | |
parent | 73120a5492ce274d551d2a215e65ba30085be7ef (diff) | |
download | qtdeclarative-testsuites-50d840aceab7afffc7dcbf9732e8d65a7cadb459.tar.gz |
Lint: inflect for pluralizing
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/lint/lint.py | 29 | ||||
-rw-r--r-- | tools/lint/requirements.txt | 1 |
2 files changed, 16 insertions, 14 deletions
diff --git a/tools/lint/lint.py b/tools/lint/lint.py index 92ccec5ab..979616a58 100755 --- a/tools/lint/lint.py +++ b/tools/lint/lint.py @@ -3,10 +3,13 @@ # This code is governed by the BSD license found in the LICENSE file. import argparse -import sys +import inflect +import os import pip import pip.req +import sys +ie = inflect.engine() try: __import__('yaml') @@ -42,13 +45,13 @@ parser.add_argument('path', help='file name or directory of files to lint') checks = [ - CheckEsid(), - CheckFrontmatter(), - CheckFeatures('features.txt'), - CheckHarnessFeatures(), - CheckLicense(), - CheckNegative() - ] + CheckEsid(), + CheckFrontmatter(), + CheckFeatures('features.txt'), + CheckHarnessFeatures(), + CheckLicense(), + CheckNegative() +] def lint(file_names): errors = dict() @@ -76,7 +79,7 @@ if __name__ == '__main__': files = [path for _path in args.path for path in collect_files(_path)] file_count = len(files) - print 'Linting %s file%s.' % (file_count, 's' if file_count != 1 else '') + print 'Linting %s %s' % (file_count, ie.plural('file', file_count)) all_errors = lint(files) unexpected_errors = dict(all_errors) @@ -88,15 +91,13 @@ if __name__ == '__main__': del unexpected_errors[file_name] error_count = len(unexpected_errors) - s = 's' if error_count != 1 else '' - - print 'Linting complete. %s error%s found.' % (error_count, s) + print 'Linting complete. %s %s found.' % (error_count, ie.plural('error', error_count)) if error_count == 0: sys.exit(0) - for file_name, failures in unexpected_errors.iteritems(): + for file_name, failures in iter(sorted(unexpected_errors.iteritems())): for ID, message in failures.iteritems(): - eprint('%s: %s - %s' % (file_name, ID, message)) + eprint('%s: %s - %s' % (os.path.abspath(file_name), ID, message)) sys.exit(1) diff --git a/tools/lint/requirements.txt b/tools/lint/requirements.txt index efb082d8d..8ad732290 100644 --- a/tools/lint/requirements.txt +++ b/tools/lint/requirements.txt @@ -1 +1,2 @@ PyYAML==3.11 +inflect==0.2.5 |