From 55027038a089d2485dbc70dd09aed7f1284f6091 Mon Sep 17 00:00:00 2001 From: T1MOXA Date: Thu, 12 Jul 2018 14:21:56 +0300 Subject: [PATCH 1/3] Fix Encoding Error Fix Encoding Error Like: ``` Traceback (most recent call last): File "MethodMap\methodmapize.py", line 23, in code = f.read() File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\encodings\cp1251.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 78259: character maps to ``` --- methodmapize.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/methodmapize.py b/methodmapize.py index 1b2e41d..2a768bc 100644 --- a/methodmapize.py +++ b/methodmapize.py @@ -19,7 +19,7 @@ continue code = '' - with open(sys.argv[i], 'r') as f: + with open(sys.argv[i], 'r', encoding='utf-8') as f: code = f.read() print('Methodmapizing {}'.format(sys.argv[i])) @@ -332,5 +332,5 @@ # _: int retagging #code = re.sub(r"_:([a-zA-Z0-9_]+(\[[a-zA-Z0-9_]+\])*)", r"view_as(\1)", code) - with open(sys.argv[i] + '.m', 'w') as f: - f.write(code) \ No newline at end of file + with open(sys.argv[i] + '.m', 'w', encoding='utf-8') as f: + f.write(code) From 824323c9a4bee8524597e36d572f635d30167882 Mon Sep 17 00:00:00 2001 From: T1MOXA Date: Thu, 16 Aug 2018 00:23:17 +0300 Subject: [PATCH 2/3] Fix Typo Before: `if (GetArraySize(hArr) != 1)` > `if (hArr\.Length != 1)` After: `if (GetArraySize(hArr) != 1)` > `if (hArr.Length != 1)` --- methodmapize.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/methodmapize.py b/methodmapize.py index 2a768bc..827ba6c 100644 --- a/methodmapize.py +++ b/methodmapize.py @@ -33,8 +33,8 @@ code = re.sub(r"GetAdminFlag\s*\(\s*([^\,]+)\s*,\s*", r"\1.HasFlag(", code) code = re.sub(r"AdminInheritGroup\s*\(\s*([^\,]+)\s*,\s*", r"\1.InheritGroup(", code) code = re.sub(r"SetAdminPassword\s*\(\s*([^\,]+)\s*,\s*", r"\1.SetPassword(", code) - code = re.sub(r"GetAdminGroupCount\s*\(\s*([^\)]+)\s*\)", r"\1\.GroupCount", code) - code = re.sub(r"GetAdminImmunityLevel\s*\(\s*([^\)]+)\s*\)", r"\1\.ImmunityLevel", code) + code = re.sub(r"GetAdminGroupCount\s*\(\s*([^\)]+)\s*\)", r"\1.GroupCount", code) + code = re.sub(r"GetAdminImmunityLevel\s*\(\s*([^\)]+)\s*\)", r"\1.ImmunityLevel", code) code = re.sub(r"SetAdminImmunityLevel\s*\(\s*([^\,]+)\s*,\s*([^\)]+)\s*\)", r"\1.ImmunityLevel = \2", code) # GroupId @@ -45,8 +45,8 @@ code = re.sub(r"GetAdmGroupImmunity\s*\(\s*([^\,]+)\s*,\s*", r"\1.GetGroupImmunity(", code) code = re.sub(r"GetAdmGroupAddFlag\s*\(\s*([^\,]+)\s*,\s*", r"\1.HasFlag(", code) code = re.sub(r"SetAdmGroupAddFlag\s*\(\s*([^\,]+)\s*,\s*", r"\1.SetFlag(", code) - code = re.sub(r"GetAdmGroupImmuneCount\s*\(\s*([^\)]+)\s*\)", r"\1\.GroupImmunitiesCount", code) - code = re.sub(r"GetAdmGroupImmunityLevel\s*\(\s*([^\)]+)\s*\)", r"\1\.ImmunityLevel", code) + code = re.sub(r"GetAdmGroupImmuneCount\s*\(\s*([^\)]+)\s*\)", r"\1.GroupImmunitiesCount", code) + code = re.sub(r"GetAdmGroupImmunityLevel\s*\(\s*([^\)]+)\s*\)", r"\1.ImmunityLevel", code) code = re.sub(r"SetAdmGroupImmunityLevel\s*\(\s*([^\,]+)\s*,\s*([^\)]+)\s*\)", r"\1.ImmunityLevel = \2", code) # ArrayList @@ -57,7 +57,7 @@ code = re.sub(r"FindValueInArray\s*\(\s*([^\,]+)\s*,\s*", r"\1.FindValue(", code) code = re.sub(r"GetArrayArray\s*\(\s*([^\,]+)\s*,\s*", r"\1.GetArray(", code) code = re.sub(r"GetArrayCell\s*\(\s*([^\,]+)\s*,\s*", r"\1.Get(", code) - code = re.sub(r"GetArraySize\s*\(\s*([^\)]+)\s*\)", r"\1\.Length", code) + code = re.sub(r"GetArraySize\s*\(\s*([^\)]+)\s*\)", r"\1.Length", code) code = re.sub(r"GetArrayString\s*\(\s*([^\,]+)\s*,\s*", r"\1.GetString(", code) code = re.sub(r"PushArrayArray\s*\(\s*([^\,]+)\s*,\s*", r"\1.PushArray(", code) code = re.sub(r"PushArrayCell\s*\(\s*([^\,]+)\s*,\s*", r"\1.Push(", code) From 24517dadd9d30b97a66fd54187eda12341a830d4 Mon Sep 17 00:00:00 2001 From: T1MOXA Date: Thu, 16 Aug 2018 00:24:10 +0300 Subject: [PATCH 3/3] Bump version to 1.2 --- methodmapize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/methodmapize.py b/methodmapize.py index 827ba6c..bba84e8 100644 --- a/methodmapize.py +++ b/methodmapize.py @@ -2,7 +2,7 @@ # Methodmapizer for SourcePawn 1.7+ # Replaces all native calls with their equivalent methodmap call. # By Peace-Maker -# Version 1.0 +# Version 1.2 import sys import re