about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-01-29 18:55:21 +0100
committeroy <Tom_Adams@web.de>2011-01-29 18:55:21 +0100
commit9c6843946c7edd4d52afe28356b4b253efbd0294 (patch)
tree5521ac7adade03f4dccb6c580282e48bbb1be5c5
parentbe68a4f516d75c62cd7a505f8a5da297c9ff1d41 (diff)
downloadzcatch-9c6843946c7edd4d52afe28356b4b253efbd0294.tar.gz
zcatch-9c6843946c7edd4d52afe28356b4b253efbd0294.zip
added Python 2.5 - Python 3.2 support by Sworddragon
-rw-r--r--datasrc/compile.py4
-rw-r--r--scripts/cmd5.py20
-rw-r--r--scripts/update_localization.py18
3 files changed, 21 insertions, 21 deletions
diff --git a/datasrc/compile.py b/datasrc/compile.py
index 0cca5498..0ae3bbc7 100644
--- a/datasrc/compile.py
+++ b/datasrc/compile.py
@@ -69,8 +69,8 @@ if gen_client_content_header or gen_server_content_header:
 	order = []
 	for line in contentlines:
 		line = line.strip()
-		if line[:6] == "class " and '(Struct)' in line:
-			order += [line.split()[1].split("(")[0]]
+		if line[:6] == "class ".encode() and "(Struct)".encode() in line:
+			order += [line.split()[1].split("(".encode())[0].decode("ascii")]
 	for name in order:
 		EmitTypeDeclaration(content.__dict__[name])
 
diff --git a/scripts/cmd5.py b/scripts/cmd5.py
index 11a18137..cd0043d5 100644
--- a/scripts/cmd5.py
+++ b/scripts/cmd5.py
@@ -3,15 +3,15 @@ import hashlib, sys, re
 alphanum = "0123456789abcdefghijklmnopqrstuvwzyxABCDEFGHIJKLMNOPQRSTUVWXYZ_"
 
 def cstrip(lines):
-	d = ""	
+	d = "".encode()
 	for l in lines:
-		l = re.sub("#.*", "", l)
-		l = re.sub("//.*", "", l)
-		d += l + " "
-	d = re.sub("\/\*.*?\*/", "", d) # remove /* */ comments
-	d = d.replace("\t", " ") # tab to space
-	d = re.sub("  *", " ", d) # remove double spaces
-	d = re.sub("", "", d) # remove /* */ comments
+		l = re.sub("#.*".encode(), "".encode(), l)
+		l = re.sub("//.*".encode(), "".encode(), l)
+		d += l + " ".encode()
+	d = re.sub("\/\*.*?\*/".encode(), "".encode(), d) # remove /* */ comments
+	d = d.replace("\t".encode(), " ".encode()) # tab to space
+	d = re.sub("  *".encode(), " ".encode(), d) # remove double spaces
+	d = re.sub("".encode(), "".encode(), d) # remove /* */ comments
 	
 	d = d.strip()
 	
@@ -24,11 +24,11 @@ def cstrip(lines):
 		i += 1
 	return d
 
-f = ""
+f = "".encode()
 for filename in sys.argv[1:]:
 	f += cstrip([l.strip() for l in open(filename, "rb")])
 
-hash = hashlib.md5(f.encode()).hexdigest().lower()[16:]
+hash = hashlib.md5(f).hexdigest().lower()[16:]
 # TODO: refactor hash that is equal to the 0.5 hash, remove when we 
 # TODO: remove when we don't need it any more
 if hash == "f16c2456fc487748":
diff --git a/scripts/update_localization.py b/scripts/update_localization.py
index 61fb6c5b..d6848411 100644
--- a/scripts/update_localization.py
+++ b/scripts/update_localization.py
@@ -8,8 +8,8 @@ source_exts = [".c", ".cpp", ".h"]
 def parse_source():
 	stringtable = {}
 	def process_line(line):
-		if b'Localize("' in line:
-			fields = line.split(b'Localize("', 1)[1].split(b'"', 1)
+		if 'Localize("'.encode() in line:
+			fields = line.split('Localize("'.encode(), 1)[1].split('"'.encode(), 1)
 			stringtable[fields[0]] = ""
 			process_line(fields[1])
 
@@ -35,7 +35,7 @@ def load_languagefile(filename):
 
 	for i in range(0, len(lines)-1):
 		l = lines[i].strip()
-		if len(l) and not l[0:1] == b"=" and not l[0:1] == b"#":
+		if len(l) and not l[0:1] == "=".encode() and not l[0:1] == "#".encode():
 			stringtable[l] = lines[i+1][3:].rstrip()
 
 	return stringtable
@@ -52,23 +52,23 @@ def generate_languagefile(outputfilename, srctable, loctable):
 		srctable_keys.append(key)
 	srctable_keys.sort()
 
-	content = b"\n##### translated strings #####\n\n"
+	content = "\n##### translated strings #####\n\n".encode()
 	for k in srctable_keys:
 		if k in loctable and len(loctable[k]):
-			content += k + b"\n== " + loctable[k] + b"\n\n"
+			content += k + "\n== ".encode() + loctable[k] + "\n\n".encode()
 			num_items += 1
 
-	content += b"##### needs translation #####\n\n"
+	content += "##### needs translation #####\n\n".encode()
 	for k in srctable_keys:
 		if not k in loctable or len(loctable[k]) == 0:
-			content += k + b"\n== \n\n"
+			content += k + "\n== \n\n".encode()
 			num_items += 1
 			new_items += 1
 
-	content += b"##### old translations #####\n\n"
+	content += "##### old translations #####\n\n".encode()
 	for k in loctable:
 		if not k in srctable:
-			content += k + b"\n== " + loctable[k] + b"\n\n"
+			content += k + "\n== ".encode() + loctable[k] + "\n\n".encode()
 			num_items += 1
 			old_items += 1