From 9413dd57c2a1e8383547b0c371908bd57b9610fd Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Mon, 17 Feb 2020 13:59:14 -0500 Subject: [PATCH] checkdoxygen.py cleanup - introduce filename as a variable - print usage/error if not called with one argument --- contrib/utilities/checkdoxygen.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/contrib/utilities/checkdoxygen.py b/contrib/utilities/checkdoxygen.py index 4a43942d97..19ceef7017 100755 --- a/contrib/utilities/checkdoxygen.py +++ b/contrib/utilities/checkdoxygen.py @@ -18,11 +18,11 @@ def check_doxygen_groups(lines): elif "@}" in l: count = count -1 if count < 0: - sys.exit("Error in file '%s' in line %d"%(args[0], lineno)) + sys.exit("Error in file '%s' in line %d"%(filename, lineno)) lineno = lineno + 1 if count != 0: - sys.exit("Error: missing closing braces in file '%s'"%(args[0])) + sys.exit("Error: missing closing braces in file '%s'"%(filename)) return @@ -36,16 +36,16 @@ def check_empty_lines_in_tables(lines): elif "" in l: count = count -1 if count < 0: - sys.exit("Error in file '%s' in line %d"%(args[0], lineno)) + sys.exit("Error in file '%s' in line %d"%(filename, lineno)) if count == 1: if l.strip() == "": - sys.exit("Error: empty line inside html table in file '%s' in line %d"%(args[0], lineno)) + sys.exit("Error: empty line inside html table in file '%s' in line %d"%(filename, lineno)) lineno = lineno + 1 if count != 0: - sys.exit("Error: mismatched html table tags in file '%s'"%(args[0])) + sys.exit("Error: mismatched html table tags in file '%s'"%(filename)) return @@ -65,11 +65,11 @@ def check_multiple_defined_headers(lines): thisheader = thisheader.split('' # detect @sect[1-5]{ ... } @@ -82,7 +82,7 @@ def check_multiple_defined_headers(lines): thisheader = ''.join(ch for ch in thisheader if ch.isalnum()) # remove nonalphanumeric if thisheader in headers: - sys.exit("Error: repeated header title '%s' in file group '%s'"%(thisheader,args[0])) + sys.exit("Error: repeated header title '%s' in file group '%s'"%(thisheader,filename)) else: headers.append(thisheader) @@ -90,9 +90,13 @@ def check_multiple_defined_headers(lines): args = sys.argv -args.pop(0) +if len(args)!=2: + print("Usage: %s "%(sys.argv[0])) + sys.exit("Error: please pass exactly one filename to this script") -f = open(args[0]) +filename = args[1] + +f = open(filename) lines = f.readlines() f.close() @@ -100,13 +104,13 @@ check_doxygen_groups(lines) check_empty_lines_in_tables(lines) # if it's intro.dox, combine it with step-**.cc and results.dox and check headers -if 'intro.dox' in args[0]: +if 'intro.dox' in filename: # get stepname.cc - stepname = args[0].split('/doc',1)[0] + stepname = filename.split('/doc',1)[0] stepname = stepname + '/' + stepname.split('/',1)[1] + '.cc' # get results.dox - resultsname = args[0].split('intro.dox',1)[0] + 'results.dox' + resultsname = filename.split('intro.dox',1)[0] + 'results.dox' # try to open the '.cc' file, otherwise try to open a '.cu' file try: -- 2.39.5