瀏覽代碼

LibGfx/TIFF: Support tag names with capitalized acronym

We now turn 'ICCProfile' into 'icc_profile' instead of 'i_c_c_profile'.
Lucas CHOLLET 1 年之前
父節點
當前提交
5622e7d77c
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Userland/Libraries/LibGfx/TIFFGenerator.py

+ 2 - 1
Userland/Libraries/LibGfx/TIFFGenerator.py

@@ -144,7 +144,8 @@ def retrieve_biggest_type(types: List[TIFFType]) -> TIFFType:
 
 
 
 
 def pascal_case_to_snake_case(name: str) -> str:
 def pascal_case_to_snake_case(name: str) -> str:
-    return re.sub(r'(?<!^)(?=[A-Z])', '_', name).lower()
+    name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
+    return re.sub('([a-z0-9])([A-Z])', r'\1_\2', name).lower()
 
 
 
 
 def generate_getter(tag: Tag) -> str:
 def generate_getter(tag: Tag) -> str: