some Python script cleanups based on PyCharm inspection (nw)

This commit is contained in:
Oliver Stöneberg 2015-03-05 16:24:05 +01:00
parent 20cfa98b20
commit ad02fe3b8b
3 changed files with 20 additions and 20 deletions

View File

@ -26,22 +26,22 @@ def parse_file(srcfile):
srcptr+=1 srcptr+=1
continue continue
if c==' ': if c==' ':
continue; continue
if in_comment==1 and c=='*' and line[srcptr]=='/' : if in_comment==1 and c=='*' and line[srcptr]=='/' :
srcptr+=1 srcptr+=1
in_comment = 0; in_comment = 0
continue continue
if (in_comment): if in_comment:
continue continue
if c=='/' and line[srcptr]=='*' : if c=='/' and line[srcptr]=='*' :
srcptr+=1 srcptr+=1
in_comment = 1; in_comment = 1
continue continue
if c=='/' and line[srcptr]=='/' : if c=='/' and line[srcptr]=='/' :
break break
drivname += c drivname += c
drivname = drivname.strip() drivname = drivname.strip()
if (len(drivname)>0): if len(drivname)>0:
if drivname[0]=='#': if drivname[0]=='#':
sys.stderr.write("Importing drivers from '%s'\n" % drivname[1:]) sys.stderr.write("Importing drivers from '%s'\n" % drivname[1:])
parse_file(drivname[1:]) parse_file(drivname[1:])
@ -54,16 +54,16 @@ def parse_file(srcfile):
return 0 return 0
if (len(sys.argv) < 2) : if len(sys.argv) < 2:
print('Usage:') print('Usage:')
print(' makelist <source.lst>') print(' makelist <source.lst>')
sys.exit(0) sys.exit(0)
if (parse_file(sys.argv[1])) : if parse_file(sys.argv[1]) :
sys.exit(1) sys.exit(1)
# output a count # output a count
if (len(drivlist)==0) : if len(drivlist)==0 :
sys.stderr.write("No drivers found\n") sys.stderr.write("No drivers found\n")
sys.exit(1) sys.exit(1)
@ -73,8 +73,8 @@ sys.stderr.write("%d drivers found\n" % len(drivlist))
drivlist.append("___empty") drivlist.append("___empty")
# start with a header # start with a header
print('#include "emu.h"\n'); print('#include "emu.h"\n')
print('#include "drivenum.h"\n'); print('#include "drivenum.h"\n')
#output the list of externs first #output the list of externs first
for drv in sorted(drivlist): for drv in sorted(drivlist):
@ -86,8 +86,8 @@ print("const game_driver * const driver_list::s_drivers_sorted[%d] =" % len(driv
print("{") print("{")
for drv in sorted(drivlist): for drv in sorted(drivlist):
print("\t&GAME_NAME(%s)," % drv) print("\t&GAME_NAME(%s)," % drv)
print("};"); print("};")
print(""); print("")
# also output a global count # also output a global count
print("int driver_list::s_driver_count = %d;\n" % len(drivlist)) print("int driver_list::s_driver_count = %d;\n" % len(drivlist))

View File

@ -23,13 +23,13 @@ def parse_args():
elif flags and (sys.argv[i] == '-p'): elif flags and (sys.argv[i] == '-p'):
format = 'plist' format = 'plist'
elif flags and (sys.argv[i] == '-b'): elif flags and (sys.argv[i] == '-b'):
i += 1; i += 1
if (i >= len(sys.argv)) or (sys.argv[i] not in ('mame', 'mess', 'ume')): if (i >= len(sys.argv)) or (sys.argv[i] not in ('mame', 'mess', 'ume')):
usage() usage()
else: else:
target = sys.argv[i] target = sys.argv[i]
elif flags and (sys.argv[i] == '-o'): elif flags and (sys.argv[i] == '-o'):
i += 1; i += 1
if (i >= len(sys.argv)) or (output is not None): if (i >= len(sys.argv)) or (output is not None):
usage() usage()
else: else:

View File

@ -58,8 +58,8 @@ def runViewJedTests(tests, jedUtilApp):
for test in tests: for test in tests:
command = [jedUtilApp, "-view", test.jedFile, test.name] command = [jedUtilApp, "-view", test.jedFile, test.name]
if VERBOSE: if VERBOSE:
print "Viewing the JED file: %s" % (test.jedFile) print "Viewing the JED file: %s" % test.jedFile
print "Command: %s" % ((" ").join(command)) print "Command: %s" % " ".join(command)
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout,stderr) = process.communicate() (stdout,stderr) = process.communicate()
@ -84,7 +84,7 @@ def main():
else: else:
jedUtilApp = os.path.normpath(os.path.join(currentDirectory, "..", "..", "..", "jedutil")) jedUtilApp = os.path.normpath(os.path.join(currentDirectory, "..", "..", "..", "jedutil"))
if (VERBOSE): if VERBOSE:
print "JED Path: %s" % jedsPath print "JED Path: %s" % jedsPath
print "Baseline Path: %s" % baselinePath print "Baseline Path: %s" % baselinePath
print "Output Path: %s" % outputPath print "Output Path: %s" % outputPath
@ -109,7 +109,7 @@ def main():
# Setup the output paths # Setup the output paths
if (VERBOSE): if VERBOSE:
print "Cleaning the output directory" print "Cleaning the output directory"
print print
if os.path.exists(outputPath): if os.path.exists(outputPath):