style: Remove unsupported style.py commands
Remove the unsupported style.py subcommands (fixwhite, chkwhite), which leaves the chkformat command as the only remaining command. Since the script now only supports one command, remove the sub-command support altogether. Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-by: Nathanael Premillieu <nathananel.premillieu@arm.com> --HG-- extra : rebase_source : 548081a5f5358064bffd941b51dd895cff1e2df8
This commit is contained in:
parent
a3efb6bd1d
commit
511c674cd6
1 changed files with 13 additions and 46 deletions
59
util/style.py
Normal file → Executable file
59
util/style.py
Normal file → Executable file
|
@ -730,56 +730,23 @@ cmdtable = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import getopt
|
import argparse
|
||||||
|
|
||||||
progname = sys.argv[0]
|
parser = argparse.ArgumentParser(
|
||||||
if len(sys.argv) < 2:
|
description="Check a file for style violations")
|
||||||
sys.exit('usage: %s <command> [<command args>]' % progname)
|
|
||||||
|
|
||||||
fixwhite_usage = '%s fixwhite [-t <tabsize> ] <path> [...] \n' % progname
|
parser.add_argument("--verbose", "-v", action="count",
|
||||||
chkformat_usage = '%s chkformat <path> [...] \n' % progname
|
help="Produce verbose output")
|
||||||
chkwhite_usage = '%s chkwhite <path> [...] \n' % progname
|
|
||||||
|
|
||||||
command = sys.argv[1]
|
parser.add_argument("file", metavar="FILE", nargs="+",
|
||||||
if command == 'fixwhite':
|
type=str,
|
||||||
flags = 't:'
|
help="Source file to inspect")
|
||||||
usage = fixwhite_usage
|
|
||||||
elif command == 'chkwhite':
|
|
||||||
flags = 'nv'
|
|
||||||
usage = chkwhite_usage
|
|
||||||
elif command == 'chkformat':
|
|
||||||
flags = 'nv'
|
|
||||||
usage = chkformat_usage
|
|
||||||
else:
|
|
||||||
sys.exit(fixwhite_usage + chkwhite_usage + chkformat_usage)
|
|
||||||
|
|
||||||
opts, args = getopt.getopt(sys.argv[2:], flags)
|
args = parser.parse_args()
|
||||||
|
|
||||||
code = 1
|
stats = ValidationStats()
|
||||||
verbose = 1
|
for filename in args.file:
|
||||||
for opt,arg in opts:
|
validate(filename, stats=stats, verbose=args.verbose, exit_code=1)
|
||||||
if opt == '-n':
|
|
||||||
code = None
|
|
||||||
if opt == '-t':
|
|
||||||
tabsize = int(arg)
|
|
||||||
if opt == '-v':
|
|
||||||
verbose += 1
|
|
||||||
|
|
||||||
if command == 'fixwhite':
|
if args.verbose > 0:
|
||||||
for filename in args:
|
|
||||||
fixwhite(filename, tabsize)
|
|
||||||
elif command == 'chkwhite':
|
|
||||||
for filename in args:
|
|
||||||
for line,num in checkwhite(filename):
|
|
||||||
print 'invalid whitespace: %s:%d' % (filename, num)
|
|
||||||
if verbose:
|
|
||||||
print '>>%s<<' % line[:-1]
|
|
||||||
elif command == 'chkformat':
|
|
||||||
stats = ValidationStats()
|
|
||||||
for filename in args:
|
|
||||||
validate(filename, stats=stats, verbose=verbose, exit_code=code)
|
|
||||||
|
|
||||||
if verbose > 0:
|
|
||||||
stats.dump()
|
stats.dump()
|
||||||
else:
|
|
||||||
sys.exit("command '%s' not found" % command)
|
|
||||||
|
|
Loading…
Reference in a new issue