diff options
| author | oy <Tom_Adams@web.de> | 2011-01-29 18:55:21 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-01-29 18:55:21 +0100 |
| commit | 9c6843946c7edd4d52afe28356b4b253efbd0294 (patch) | |
| tree | 5521ac7adade03f4dccb6c580282e48bbb1be5c5 /scripts/cmd5.py | |
| parent | be68a4f516d75c62cd7a505f8a5da297c9ff1d41 (diff) | |
| download | zcatch-9c6843946c7edd4d52afe28356b4b253efbd0294.tar.gz zcatch-9c6843946c7edd4d52afe28356b4b253efbd0294.zip | |
added Python 2.5 - Python 3.2 support by Sworddragon
Diffstat (limited to 'scripts/cmd5.py')
| -rw-r--r-- | scripts/cmd5.py | 20 |
1 files changed, 10 insertions, 10 deletions
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": |