Обновление вывода информации о патчах, добавление патча лайков/дизлайков

This commit is contained in:
2025-10-11 18:40:44 +03:00
parent b646dbf6fe
commit 28c60aa7a3
27 changed files with 313 additions and 114 deletions
+13 -5
View File
@@ -1,8 +1,9 @@
from lxml import etree
from typing_extensions import Optional
from copy import deepcopy
from lxml import etree
def insert_after_public(anchor_name: str, elem_name: str):
def insert_after_public(anchor_name: str, elem_name: str) -> Optional[int]:
file_path = "./decompiled/res/values/public.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
@@ -19,6 +20,8 @@ def insert_after_public(anchor_name: str, elem_name: str):
anchor = (elem, attrs)
types[attrs["type"]] = types.get(attrs["type"], []) + [int(attrs["id"], 16)]
assert anchor != None
free_ids = set()
group = types[anchor[1]["type"]]
for i in range(min(group), max(group) + 1):
@@ -47,7 +50,7 @@ def insert_after_public(anchor_name: str, elem_name: str):
return new_id
def insert_after_id(anchor_name: str, elem_name: str):
def insert_after_id(anchor_name: str, elem_name: str) -> None:
file_path = "./decompiled/res/values/ids.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
@@ -62,13 +65,15 @@ def insert_after_id(anchor_name: str, elem_name: str):
assert anchor == None
anchor = (elem, attrs)
assert anchor != None
new_elem = deepcopy(anchor[0])
new_elem.set("name", elem_name)
anchor[0].addnext(new_elem)
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
def change_color(name: str, value: str):
def change_color(name: str, value: str) -> None:
file_path = "./decompiled/res/values/colors.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
@@ -86,7 +91,8 @@ def change_color(name: str, value: str):
assert replacements >= 1
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
def insert_after_color(anchor_name: str, elem_name: str, elem_value: str):
def insert_after_color(anchor_name: str, elem_name: str, elem_value: str) -> None:
file_path = "./decompiled/res/values/colors.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
@@ -101,6 +107,8 @@ def insert_after_color(anchor_name: str, elem_name: str, elem_value: str):
assert anchor == None
anchor = (elem, attrs)
assert anchor != None
new_elem = deepcopy(anchor[0])
new_elem.set("name", elem_name)
anchor[0].addnext(new_elem)