mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 22:15:24 +02:00
Lint: inflect for pluralizing
This commit is contained in:
parent
73120a5492
commit
50d840acea
@ -3,10 +3,13 @@
|
|||||||
# This code is governed by the BSD license found in the LICENSE file.
|
# This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import inflect
|
||||||
|
import os
|
||||||
import pip
|
import pip
|
||||||
import pip.req
|
import pip.req
|
||||||
|
import sys
|
||||||
|
|
||||||
|
ie = inflect.engine()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
__import__('yaml')
|
__import__('yaml')
|
||||||
@ -48,7 +51,7 @@ checks = [
|
|||||||
CheckHarnessFeatures(),
|
CheckHarnessFeatures(),
|
||||||
CheckLicense(),
|
CheckLicense(),
|
||||||
CheckNegative()
|
CheckNegative()
|
||||||
]
|
]
|
||||||
|
|
||||||
def lint(file_names):
|
def lint(file_names):
|
||||||
errors = dict()
|
errors = dict()
|
||||||
@ -76,7 +79,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
files = [path for _path in args.path for path in collect_files(_path)]
|
files = [path for _path in args.path for path in collect_files(_path)]
|
||||||
file_count = len(files)
|
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)
|
all_errors = lint(files)
|
||||||
unexpected_errors = dict(all_errors)
|
unexpected_errors = dict(all_errors)
|
||||||
@ -88,15 +91,13 @@ if __name__ == '__main__':
|
|||||||
del unexpected_errors[file_name]
|
del unexpected_errors[file_name]
|
||||||
|
|
||||||
error_count = len(unexpected_errors)
|
error_count = len(unexpected_errors)
|
||||||
s = 's' if error_count != 1 else ''
|
print 'Linting complete. %s %s found.' % (error_count, ie.plural('error', error_count))
|
||||||
|
|
||||||
print 'Linting complete. %s error%s found.' % (error_count, s)
|
|
||||||
|
|
||||||
if error_count == 0:
|
if error_count == 0:
|
||||||
sys.exit(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():
|
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)
|
sys.exit(1)
|
||||||
|
@ -1 +1,2 @@
|
|||||||
PyYAML==3.11
|
PyYAML==3.11
|
||||||
|
inflect==0.2.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user