diff options
| -rw-r--r-- | include/Face.py | 39 | ||||
| -rw-r--r-- | include/HFacer.py | 11 | 
2 files changed, 24 insertions, 26 deletions
| diff --git a/include/Face.py b/include/Face.py index 08ac7a936..319ce41e5 100644 --- a/include/Face.py +++ b/include/Face.py @@ -1,36 +1,35 @@  # Module for reading and parsing Scintilla.iface file -import string  def sanitiseLine(line):  	if line[-1:] == '\n': line = line[:-1] -	if string.find(line, "##") != -1: -		line = line[:string.find(line, "##")] -	line = string.strip(line) +	if line.find("##") != -1: +		line = line[:line.find("##")] +	line = line.strip()  	return line  def decodeFunction(featureVal): -	retType, rest = string.split(featureVal, " ", 1) -	nameIdent, params = string.split(rest, "(") -	name, value = string.split(nameIdent, "=") -	params, rest = string.split(params, ")") -	param1, param2 = string.split(params, ",")[0:2] +	retType, rest = featureVal.split(" ", 1) +	nameIdent, params = rest.split("(") +	name, value = nameIdent.split("=") +	params, rest = params.split(")") +	param1, param2 = params.split(",")[0:2]  	return retType, name, value, param1, param2  def decodeEvent(featureVal): -	retType, rest = string.split(featureVal, " ", 1) -	nameIdent, params = string.split(rest, "(") -	name, value = string.split(nameIdent, "=") +	retType, rest = featureVal.split(" ", 1) +	nameIdent, params = rest.split("(") +	name, value = nameIdent.split("=")  	return retType, name, value  def decodeParam(p): -	param = string.strip(p) +	param = p.strip()  	type = ""  	name = ""  	value = ""  	if " " in param: -		type, nv = string.split(param, " ") +		type, nv = param.split(" ")  		if "=" in nv: -			name, value = string.split(nv, "=") +			name, value = nv.split("=")  		else:  			name = nv  	return type, name, value @@ -59,7 +58,7 @@ class Face:  						currentComment.append(line[2:])  				else:  					currentCommentFinished = 1 -					featureType, featureVal = string.split(line, " ", 1) +					featureType, featureVal = line.split(" ", 1)  					if featureType in ["fun", "get", "set"]:  						retType, name, value, param1, param2 = decodeFunction(featureVal)  						p1 = decodeParam(param1) @@ -72,7 +71,7 @@ class Face:  							"Param2Type": p2[0],	"Param2Name": p2[1], "Param2Value": p2[2],  							"Category": currentCategory, "Comment": currentComment  						} -						if self.values.has_key(value): +						if value in self.values:  							raise "Duplicate value " + value + " " + name  						self.values[value] = 1  						self.order.append(name) @@ -84,21 +83,21 @@ class Face:  							"Value": value,   							"Category": currentCategory, "Comment": currentComment  						} -						if self.events.has_key(value): +						if value in self.events:  							raise "Duplicate event " + value + " " + name  						self.events[value] = 1  						self.order.append(name)  					elif featureType == "cat":  						currentCategory = featureVal  					elif featureType == "val": -						name, value = string.split(featureVal, "=", 1) +						name, value = featureVal.split("=", 1)  						self.features[name] = {   							"FeatureType": featureType,   							"Category": currentCategory,   							"Value": value }  						self.order.append(name)  					elif featureType == "enu" or featureType == "lex": -						name, value = string.split(featureVal, "=", 1) +						name, value = featureVal.split("=", 1)  						self.features[name] = {   							"FeatureType": featureType,   							"Category": currentCategory,  diff --git a/include/HFacer.py b/include/HFacer.py index 1b4d62746..62a827326 100644 --- a/include/HFacer.py +++ b/include/HFacer.py @@ -4,13 +4,12 @@  # comment and a /* --Autogenerated*/ comment which is generated by the printHFile and printLexHFile  # functions. After the temporary file is created, it is copied back to the original file name. -import string  import sys  import os  import Face  def Contains(s,sub): -	return string.find(s, sub) != -1 +	return s.find(sub) != -1  def printLexHFile(f,out):  	for name in f.order: @@ -24,10 +23,10 @@ def printHFile(f,out):  		v = f.features[name]  		if v["Category"] != "Deprecated":  			if v["FeatureType"] in ["fun", "get", "set"]: -				featureDefineName = "SCI_" + string.upper(name) +				featureDefineName = "SCI_" + name.upper()  				out.write("#define " + featureDefineName + " " + v["Value"] + "\n")  			elif v["FeatureType"] in ["evt"]: -				featureDefineName = "SCN_" + string.upper(name) +				featureDefineName = "SCN_" + name.upper()  				out.write("#define " + featureDefineName + " " + v["Value"] + "\n")  			elif v["FeatureType"] in ["val"]:  				if not (Contains(name, "SCE_") or Contains(name, "SCLEX_")): @@ -46,7 +45,7 @@ def CopyWithInsertion(input, output, genfn, definition):  			output.write(line)  def contents(filename): -	f = file(filename) +	f = open(filename)  	t = f.read()  	f.close()  	return t @@ -71,6 +70,6 @@ try:  	f.ReadFromFile("Scintilla.iface")  	Regenerate("Scintilla.h", printHFile, f)  	Regenerate("SciLexer.h", printLexHFile, f) -	print "Maximum ID is", max([x for x in f.values if int(x) < 3000]) +	print("Maximum ID is %s" % max([x for x in f.values if int(x) < 3000]))  except:  	raise | 
