More editor extract.py improvements and fixes

This commit is contained in:
Haoyu Qiu 2022-03-20 20:21:05 +08:00
parent 9e44fb166d
commit 1bf30d7be0
2 changed files with 29 additions and 12 deletions

View file

@ -83,6 +83,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["aabb"] = "AABB"; capitalize_string_remaps["aabb"] = "AABB";
capitalize_string_remaps["adb"] = "ADB"; capitalize_string_remaps["adb"] = "ADB";
capitalize_string_remaps["ao"] = "AO"; capitalize_string_remaps["ao"] = "AO";
capitalize_string_remaps["apk"] = "APK";
capitalize_string_remaps["arvr"] = "ARVR"; capitalize_string_remaps["arvr"] = "ARVR";
capitalize_string_remaps["bg"] = "BG"; capitalize_string_remaps["bg"] = "BG";
capitalize_string_remaps["bp"] = "BP"; capitalize_string_remaps["bp"] = "BP";
@ -119,15 +120,21 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["hsv"] = "HSV"; capitalize_string_remaps["hsv"] = "HSV";
capitalize_string_remaps["http"] = "HTTP"; capitalize_string_remaps["http"] = "HTTP";
capitalize_string_remaps["id"] = "ID"; capitalize_string_remaps["id"] = "ID";
capitalize_string_remaps["ik"] = "IK";
capitalize_string_remaps["igd"] = "IGD"; capitalize_string_remaps["igd"] = "IGD";
capitalize_string_remaps["ik"] = "IK";
capitalize_string_remaps["image@2x"] = "Image @2x";
capitalize_string_remaps["image@3x"] = "Image @3x";
capitalize_string_remaps["ios"] = "iOS"; capitalize_string_remaps["ios"] = "iOS";
capitalize_string_remaps["iod"] = "IOD"; capitalize_string_remaps["iod"] = "IOD";
capitalize_string_remaps["ip"] = "IP"; capitalize_string_remaps["ip"] = "IP";
capitalize_string_remaps["ipad"] = "iPad";
capitalize_string_remaps["iphone"] = "iPhone";
capitalize_string_remaps["ipv6"] = "IPv6"; capitalize_string_remaps["ipv6"] = "IPv6";
capitalize_string_remaps["jit"] = "JIT";
capitalize_string_remaps["k1"] = "K1"; capitalize_string_remaps["k1"] = "K1";
capitalize_string_remaps["k2"] = "K2"; capitalize_string_remaps["k2"] = "K2";
capitalize_string_remaps["kb"] = "(KB)"; // Unit. capitalize_string_remaps["kb"] = "(KB)"; // Unit.
capitalize_string_remaps["ldr"] = "LDR";
capitalize_string_remaps["lod"] = "LOD"; capitalize_string_remaps["lod"] = "LOD";
capitalize_string_remaps["lowpass"] = "Low-pass"; capitalize_string_remaps["lowpass"] = "Low-pass";
capitalize_string_remaps["macos"] = "macOS"; capitalize_string_remaps["macos"] = "macOS";
@ -137,13 +144,16 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
//capitalize_string_remaps["msec"] = "(msec)"; // Unit. //capitalize_string_remaps["msec"] = "(msec)"; // Unit.
capitalize_string_remaps["msaa"] = "MSAA"; capitalize_string_remaps["msaa"] = "MSAA";
capitalize_string_remaps["normalmap"] = "Normal Map"; capitalize_string_remaps["normalmap"] = "Normal Map";
capitalize_string_remaps["ok"] = "OK";
capitalize_string_remaps["opengl"] = "OpenGL"; capitalize_string_remaps["opengl"] = "OpenGL";
capitalize_string_remaps["opentype"] = "OpenType"; capitalize_string_remaps["opentype"] = "OpenType";
capitalize_string_remaps["openxr"] = "OpenXR"; capitalize_string_remaps["openxr"] = "OpenXR";
capitalize_string_remaps["pck"] = "PCK";
capitalize_string_remaps["png"] = "PNG"; capitalize_string_remaps["png"] = "PNG";
capitalize_string_remaps["po2"] = "(Power of 2)"; // Unit. capitalize_string_remaps["po2"] = "(Power of 2)"; // Unit.
capitalize_string_remaps["pvs"] = "PVS"; capitalize_string_remaps["pvs"] = "PVS";
capitalize_string_remaps["pvrtc"] = "PVRTC"; capitalize_string_remaps["pvrtc"] = "PVRTC";
capitalize_string_remaps["rgb"] = "RGB";
capitalize_string_remaps["rid"] = "RID"; capitalize_string_remaps["rid"] = "RID";
capitalize_string_remaps["rmb"] = "RMB"; capitalize_string_remaps["rmb"] = "RMB";
capitalize_string_remaps["rpc"] = "RPC"; capitalize_string_remaps["rpc"] = "RPC";
@ -152,18 +162,21 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["sdfgi"] = "SDFGI"; capitalize_string_remaps["sdfgi"] = "SDFGI";
capitalize_string_remaps["sdk"] = "SDK"; capitalize_string_remaps["sdk"] = "SDK";
capitalize_string_remaps["sec"] = "(sec)"; // Unit. capitalize_string_remaps["sec"] = "(sec)"; // Unit.
capitalize_string_remaps["srgb"] = "sRGB";
capitalize_string_remaps["ssao"] = "SSAO"; capitalize_string_remaps["ssao"] = "SSAO";
capitalize_string_remaps["ssh"] = "SSH"; capitalize_string_remaps["ssh"] = "SSH";
capitalize_string_remaps["ssil"] = "SSIL"; capitalize_string_remaps["ssil"] = "SSIL";
capitalize_string_remaps["ssl"] = "SSL"; capitalize_string_remaps["ssl"] = "SSL";
capitalize_string_remaps["stderr"] = "stderr"; capitalize_string_remaps["stderr"] = "stderr";
capitalize_string_remaps["stdout"] = "stdout"; capitalize_string_remaps["stdout"] = "stdout";
capitalize_string_remaps["svg"] = "SVG";
capitalize_string_remaps["tcp"] = "TCP"; capitalize_string_remaps["tcp"] = "TCP";
capitalize_string_remaps["ui"] = "UI"; capitalize_string_remaps["ui"] = "UI";
capitalize_string_remaps["url"] = "URL"; capitalize_string_remaps["url"] = "URL";
capitalize_string_remaps["urls"] = "URLs"; capitalize_string_remaps["urls"] = "URLs";
capitalize_string_remaps["us"] = "(µs)"; // Unit. capitalize_string_remaps["us"] = String::utf8("(µs)"); // Unit.
capitalize_string_remaps["usec"] = "(µsec)"; // Unit. capitalize_string_remaps["usec"] = String::utf8("(µsec)"); // Unit.
capitalize_string_remaps["uuid"] = "UUID";
capitalize_string_remaps["uv"] = "UV"; capitalize_string_remaps["uv"] = "UV";
capitalize_string_remaps["uv1"] = "UV1"; capitalize_string_remaps["uv1"] = "UV1";
capitalize_string_remaps["uv2"] = "UV2"; capitalize_string_remaps["uv2"] = "UV2";
@ -174,6 +187,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["webp"] = "WebP"; capitalize_string_remaps["webp"] = "WebP";
capitalize_string_remaps["webrtc"] = "WebRTC"; capitalize_string_remaps["webrtc"] = "WebRTC";
capitalize_string_remaps["websocket"] = "WebSocket"; capitalize_string_remaps["websocket"] = "WebSocket";
capitalize_string_remaps["wifi"] = "Wi-Fi";
capitalize_string_remaps["xr"] = "XR"; capitalize_string_remaps["xr"] = "XR";
capitalize_string_remaps["xy"] = "XY"; capitalize_string_remaps["xy"] = "XY";
capitalize_string_remaps["xz"] = "XZ"; capitalize_string_remaps["xz"] = "XZ";

View file

@ -34,12 +34,12 @@ matches.sort()
remaps = {} remaps = {}
remap_re = re.compile(r'capitalize_string_remaps\["(.+)"\] = "(.+)";') remap_re = re.compile(r'^\t*capitalize_string_remaps\["(?P<from>.+)"\] = (String::utf8\()?"(?P<to>.+)"')
with open("editor/editor_property_name_processor.cpp") as f: with open("editor/editor_property_name_processor.cpp") as f:
for line in f: for line in f:
m = remap_re.search(line) m = remap_re.search(line)
if m: if m:
remaps[m.group(1)] = m.group(2) remaps[m.group("from")] = m.group("to")
unique_str = [] unique_str = []
@ -70,16 +70,19 @@ class ExtractType(enum.IntEnum):
GROUP = 3 GROUP = 3
# Regex "(?P<name>(?:[^"\\]|\\.)*)" creates a group named `name` that matches a string. # Regex "(?P<name>([^"\\]|\\.)*)" creates a group named `name` that matches a string.
message_patterns = { message_patterns = {
re.compile(r'RTR\("(?P<message>(?:[^"\\]|\\.)*)"\)'): ExtractType.TEXT, re.compile(r'RTR\("(?P<message>([^"\\]|\\.)*)"\)'): ExtractType.TEXT,
re.compile(r'TTR\("(?P<message>(?:[^"\\]|\\.)*)"(?:, "(?P<context>(?:[^"\\]|\\.)*)")?\)'): ExtractType.TEXT, re.compile(r'TTR\("(?P<message>([^"\\]|\\.)*)"(, "(?P<context>([^"\\]|\\.)*)")?\)'): ExtractType.TEXT,
re.compile(r'TTRC\("(?P<message>(?:[^"\\]|\\.)*)"\)'): ExtractType.TEXT, re.compile(r'TTRC\("(?P<message>([^"\\]|\\.)*)"\)'): ExtractType.TEXT,
re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, re.compile(r'_initial_set\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
re.compile(r'GLOBAL_DEF(?:_RST)?\("(?P<message>[^".]+?)",'): ExtractType.PROPERTY_PATH, re.compile(r'GLOBAL_DEF(_RST)?(_NOVAL)?\("(?P<message>[^".]+?)",'): ExtractType.PROPERTY_PATH,
re.compile(r'EDITOR_DEF(?:_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH, re.compile(r'EDITOR_DEF(_RST)?\("(?P<message>[^"]+?)",'): ExtractType.PROPERTY_PATH,
re.compile( re.compile(
r'ADD_PROPERTY\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]' r'(ADD_PROPERTYI?|ImportOption|ExportOption)\(PropertyInfo\(Variant::[_A-Z0-9]+, "(?P<message>[^"]+?)"[,)]'
): ExtractType.PROPERTY_PATH,
re.compile(
r"(?!#define )LIMPL_PROPERTY(_RANGE)?\(Variant::[_A-Z0-9]+, (?P<message>[^,]+?),"
): ExtractType.PROPERTY_PATH, ): ExtractType.PROPERTY_PATH,
re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP, re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP,
} }