Улучшение cli и удобства создания патчей
Сборка мода / build (push) Successful in 2m16s

This commit is contained in:
2025-12-28 17:47:56 +03:00
parent ec047cd3a5
commit 70337ee3ec
35 changed files with 2200 additions and 1111 deletions
+92 -94
View File
@@ -6,116 +6,114 @@
}
"""
priority = -1
# imports
__author__ = "wowlikon <wowlikon@gmail.com>"
__version__ = "1.0.0"
import os
from tqdm import tqdm
from typing import Any, Dict
from lxml import etree
from typing import Dict, Any
from pydantic import Field
from utils.config import PatchConfig
from utils.config import PatchTemplate
#Config
class Config(PatchConfig):
class Patch(PatchTemplate):
priority: int = Field(frozen=True, exclude=True, default=-1)
package_name: str = Field("com.wowlikon.anixart", description="Название пакета")
# Patch
def rename_dir(src, dst):
os.makedirs(os.path.dirname(dst), exist_ok=True)
os.rename(src, dst)
def rename_dir(self, src, dst):
os.makedirs(os.path.dirname(dst), exist_ok=True)
os.rename(src, dst)
def apply(self, base: Dict[str, Any]) -> bool:
for root, dirs, files in os.walk("./decompiled"):
for filename in files:
file_path = os.path.join(root, filename)
def apply(config: Config, base: Dict[str, Any]) -> bool:
for root, dirs, files in os.walk("./decompiled"):
for filename in files:
file_path = os.path.join(root, filename)
if os.path.isfile(file_path):
try: # Изменяем имя пакета в файлах
with open(file_path, "r", encoding="utf-8") as file:
file_contents = file.read()
if os.path.isfile(file_path):
try: # Изменяем имя пакета в файлах
with open(file_path, "r", encoding="utf-8") as file:
file_contents = file.read()
new_contents = file_contents.replace(
"com.swiftsoft.anixartd", self.package_name
)
new_contents = new_contents.replace(
"com/swiftsoft/anixartd",
self.package_name.replace(".", "/"),
).replace(
"com/swiftsoft",
"/".join(self.package_name.split(".")[:2]),
)
with open(file_path, "w", encoding="utf-8") as file:
file.write(new_contents)
except:
pass
new_contents = file_contents.replace(
"com.swiftsoft.anixartd", config.package_name
)
new_contents = new_contents.replace(
"com/swiftsoft/anixartd",
config.package_name.replace(".", "/"),
).replace(
"com/swiftsoft",
"/".join(config.package_name.split(".")[:2]),
)
with open(file_path, "w", encoding="utf-8") as file:
file.write(new_contents)
except:
pass
# Изменяем названия папок
if os.path.exists("./decompiled/smali/com/swiftsoft/anixartd"):
self.rename_dir(
"./decompiled/smali/com/swiftsoft/anixartd",
os.path.join(
"./decompiled", "smali", self.package_name.replace(".", "/")
),
)
if os.path.exists("./decompiled/smali_classes2/com/swiftsoft/anixartd"):
self.rename_dir(
"./decompiled/smali_classes2/com/swiftsoft/anixartd",
os.path.join(
"./decompiled",
"smali_classes2",
self.package_name.replace(".", "/"),
),
)
if os.path.exists("./decompiled/smali_classes4/com/swiftsoft"):
self.rename_dir(
"./decompiled/smali_classes4/com/swiftsoft",
os.path.join(
"./decompiled",
"smali_classes4",
"/".join(self.package_name.split(".")[:2]),
),
)
# Изменяем названия папок
if os.path.exists("./decompiled/smali/com/swiftsoft/anixartd"):
rename_dir(
"./decompiled/smali/com/swiftsoft/anixartd",
os.path.join(
"./decompiled", "smali", config.package_name.replace(".", "/")
),
)
if os.path.exists("./decompiled/smali_classes2/com/swiftsoft/anixartd"):
rename_dir(
"./decompiled/smali_classes2/com/swiftsoft/anixartd",
os.path.join(
"./decompiled",
"smali_classes2",
config.package_name.replace(".", "/"),
),
)
if os.path.exists("./decompiled/smali_classes4/com/swiftsoft"):
rename_dir(
"./decompiled/smali_classes4/com/swiftsoft",
os.path.join(
"./decompiled",
"smali_classes4",
"/".join(config.package_name.split(".")[:2]),
),
)
# rename_dir(
# "./decompiled/smali_classes3/com/swiftsoft/anixartd",
# os.path.join(
# "./decompiled",
# "smali_classes3",
# config["new_package_name"].replace(".", "/"),
# ),
# )
# rename_dir(
# "./decompiled/smali_classes3/com/swiftsoft/anixartd",
# os.path.join(
# "./decompiled",
# "smali_classes3",
# config["new_package_name"].replace(".", "/"),
# ),
# )
# Замена названия пакета для smali_classes4
for root, dirs, files in os.walk("./decompiled/smali_classes4/"):
for filename in files:
file_path = os.path.join(root, filename)
# Замена названия пакета для smali_classes4
for root, dirs, files in os.walk("./decompiled/smali_classes4/"):
for filename in files:
file_path = os.path.join(root, filename)
if os.path.isfile(file_path):
try:
with open(file_path, "r", encoding="utf-8") as file:
file_contents = file.read()
if os.path.isfile(file_path):
try:
with open(file_path, "r", encoding="utf-8") as file:
file_contents = file.read()
new_contents = file_contents.replace(
"com/swiftsoft",
"/".join(self.package_name.split(".")[:-1]),
)
with open(file_path, "w", encoding="utf-8") as file:
file.write(new_contents)
except:
pass
new_contents = file_contents.replace(
"com/swiftsoft",
"/".join(config.package_name.split(".")[:-1]),
)
with open(file_path, "w", encoding="utf-8") as file:
file.write(new_contents)
except:
pass
# Скрытие входа по Google и VK (НЕ РАБОТАЮТ В МОДАХ)
file_path = "./decompiled/res/layout/fragment_sign_in.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
root = tree.getroot()
# Скрытие входа по Google и VK (НЕ РАБОТАЮТ В МОДАХ)
file_path = "./decompiled/res/layout/fragment_sign_in.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
root = tree.getroot()
last_linear = root.xpath("//LinearLayout/LinearLayout[4]")[0]
last_linear.set(f"{{{base['xml_ns']['android']}}}visibility", "gone")
last_linear = root.xpath("//LinearLayout/LinearLayout[4]")[0]
last_linear.set(f"{{{base['xml_ns']['android']}}}visibility", "gone")
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
tree.write(file_path, pretty_print=True, xml_declaration=True, encoding="utf-8")
return True
return True