Fix print()

git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@21036 282e977c-c81d-0410-88c4-b93c2d0d6712
master
partmedia 2019-11-27 23:25:27 +00:00
parent 9917f3454b
commit fc35ab5998
1 changed files with 19 additions and 19 deletions

View File

@ -20,7 +20,7 @@ def checkactionfile(filename, condition):
args = condition[1:]
checkstatus = 0
if not os.path.isfile(filename):
print "Error: No script to support action: ", condition[0], "Expected: ", filename
print("Error: No script to support action: ", condition[0], "Expected: ", filename)
return False
else:
actf = open(filename,"r")
@ -35,34 +35,34 @@ def checkactionfile(filename, condition):
elif actline.find("## MINARGS") != -1:
num = actline.split()[2]
if not num.isdigit():
print "ERROR: Action definition for script ", filename, " MINARGS not defined"
print("ERROR: Action definition for script ", filename, " MINARGS not defined")
return False
else:
if len(args)<int(num):
print "ERROR: Insufficiant options passed to script ", filename, "expected ", int(num), " recieved ", len(args)
print("ERROR: Insufficiant options passed to script ", filename, "expected ", int(num), " recieved ", len(args))
return False
elif actline.find("## MAXARGS") != -1:
num = actline.split()[2]
if not num.isdigit():
print "ERROR: Action definition for script ", filename, " MAXARGS not defined"
print("ERROR: Action definition for script ", filename, " MAXARGS not defined")
return False
elif int(num) == 0:
# zero means there is no upper limit to the number of arguments
pass
else:
if len(args)>int(num):
print "ERROR: Too many options passed to script ", filename, "expected ", int(num), " recieved ", len(args)
print("ERROR: Too many options passed to script ", filename, "expected ", int(num), " recieved ", len(args))
return False
elif actline.find("##") != 1:
# This is a regexp for one of the arguments
if argnum < len(args):
argmatch = re.compile(actline.split()[1])
if not argmatch.match(args[argnum]):
print "ERROR: Argument ", argnum+2, "of rule: ", condition, " doesn't match regexp ", actline.split()[1]
print("ERROR: Argument ", argnum+2, "of rule: ", condition, " doesn't match regexp ", actline.split()[1])
return False
argnum+=1
if checkstatus != 2:
print "Warning: No dialogcheck block for file ", filename, " Unable to check condition ", condition
print("Warning: No dialogcheck block for file ", filename, " Unable to check condition ", condition)
return True
return True
@ -76,22 +76,22 @@ def checkdialoguefile(msgfile, location):
try:
f = open(msgfile,"rb")
except:
print "ERROR: Can't open file, ", msgfile
print("ERROR: Can't open file, ", msgfile)
errors +=1
else:
try:
params = cjson.decode(f.read())
except:
print "ERROR: Failed to parse file, ", msgfile, "not a valid json file"
print("ERROR: Failed to parse file, ", msgfile, "not a valid json file")
errors +=1
f.close()
if "location" in params:
if not location == '':
print "Warning: Location defined multiple times in included files"
print("Warning: Location defined multiple times in included files")
warnings+=1
location = params["location"]
if location =='':
print "Warning: no location was specified"
print("Warning: no location was specified")
warnings +=1
rulenumber =0
for jsonRule in params["rules"]:
@ -108,7 +108,7 @@ def checkdialoguefile(msgfile, location):
action = condition[0]
path = os.path.join("pre/", action + ".py")
if not checkactionfile(path, condition):
print "ERROR: verification of action file ", path, " failed for rule ", rulenumber, " condition ", condition
print("ERROR: verification of action file ", path, " failed for rule ", rulenumber, " condition ", condition)
errors+=1
elif action == "msg":
@ -116,7 +116,7 @@ def checkdialoguefile(msgfile, location):
if len(line) > MAX_MSG_LENGTH:
# We won't print out the entire line, because it's very
# very long, but we'll print the first 70 characters in order to help identify it
print "WARNING: A Dialog Line for rule", rulenumber, "is too long. (", len(line), "characters, maximum is", MAX_MSG_LENGTH, ") \nLine begins:", line[:70]
print("WARNING: A Dialog Line for rule", rulenumber, "is too long. (", len(line), "characters, maximum is", MAX_MSG_LENGTH, ") \nLine begins:", line[:70])
warnings+=1
msg+=1
elif action == "post":
@ -125,7 +125,7 @@ def checkdialoguefile(msgfile, location):
action = condition[0]
path = os.path.join("post/", action + ".py")
if not checkactionfile(path, condition):
print "ERROR: verification of action file ", path, " failed for rule ", rulenumber, " condition ", condition
print("ERROR: verification of action file ", path, " failed for rule ", rulenumber, " condition ", condition)
errors +=1
elif action == "match":
@ -143,12 +143,12 @@ def checkdialoguefile(msgfile, location):
inclname = os.path.join(os.path.dirname(msgfile), condition)
extrafiles.append(inclname)
else:
print "Warning: Ignoring unknown rule:", action
print("Warning: Ignoring unknown rule:", action)
warnings+=1
if (include == 1 and msg+post+match == 0) or (msg == 1 and post == 1 and match ==1 and pre == 1):
pass
else:
print "ERROR: Rule created with an invalid combination of actions, actions are: ", jsonRule.keys()
print("ERROR: Rule created with an invalid combination of actions, actions are: ", list(jsonRule.keys()))
errors +=1
newfiles =0
newrules =0
@ -157,7 +157,7 @@ def checkdialoguefile(msgfile, location):
if len(extrafiles) > 0:
for extrapath in extrafiles:
newfiles, newrules, newwarnings, newerrors = checkdialoguefile(extrapath, location)
print "checked ", newrules, "rules from file", extrapath, "Found ", newerrors, " errors and ", newwarnings,"warnings"
print("checked ", newrules, "rules from file", extrapath, "Found ", newerrors, " errors and ", newwarnings,"warnings")
warnings +=newwarnings
rulenumber+=newrules
errors+=newerrors
@ -165,8 +165,8 @@ def checkdialoguefile(msgfile, location):
return (1+newfiles, rulenumber, warnings, errors)
if len(sys.argv) < 2:
print "usage: python dialog_check.py path/to/dialogfile.msg"
print("usage: python dialog_check.py path/to/dialogfile.msg")
exit()
for arg in sys.argv[1:]:
newfiles, rulecount, newwarnings, newerrors = checkdialoguefile(arg, '')
print "checked ", rulecount, "rules from file", arg, "Found ", newerrors, " errors and ", newwarnings,"warnings"
print("checked ", rulecount, "rules from file", arg, "Found ", newerrors, " errors and ", newwarnings,"warnings")