mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-06 03:03:50 +05:00
feat: initial commit
This commit is contained in:
commit
b6c058c40f
16 changed files with 400 additions and 0 deletions
0
patches/__init__.py
Normal file
0
patches/__init__.py
Normal file
3
patches/change_package_name.config.json
Normal file
3
patches/change_package_name.config.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"new_package_name": "com.radiquum.anixart"
|
||||
}
|
61
patches/change_package_name.py
Normal file
61
patches/change_package_name.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
"""Remove and Compress unnecessary resources"""
|
||||
|
||||
priority = -10
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from typing import TypedDict
|
||||
|
||||
class PatchConfig_ChangePackageName(TypedDict):
|
||||
src: str
|
||||
new_package_name: str
|
||||
|
||||
def rename_dir(src, dst):
|
||||
os.makedirs(dst, exist_ok=True)
|
||||
os.rename(src, dst)
|
||||
|
||||
def apply(config: dict) -> bool:
|
||||
assert config["new_package_name"] is not None, "new_package_name is not configured"
|
||||
|
||||
for root, dirs, files in os.walk(f"{config['src']}"):
|
||||
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()
|
||||
|
||||
new_contents = file_contents.replace(
|
||||
"com.swiftsoft.anixartd", config["new_package_name"]
|
||||
)
|
||||
new_contents = new_contents.replace(
|
||||
"com/swiftsoft/anixartd",
|
||||
config["new_package_name"].replace(".", "/"),
|
||||
)
|
||||
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
file.write(new_contents)
|
||||
except:
|
||||
pass
|
||||
|
||||
if os.path.exists(f"{config['src']}/smali/com/swiftsoft/anixartd"):
|
||||
rename_dir(
|
||||
f"{config['src']}/smali/com/swiftsoft/anixartd",
|
||||
os.path.join(
|
||||
f"{config['src']}", "smali", config["new_package_name"].replace(".", "/")
|
||||
),
|
||||
)
|
||||
|
||||
if os.path.exists(f"{config['src']}/smali_classes2/com/swiftsoft/anixartd"):
|
||||
rename_dir(
|
||||
f"{config['src']}/smali_classes2/com/swiftsoft/anixartd",
|
||||
os.path.join(
|
||||
f"{config['src']}",
|
||||
"smali_classes2",
|
||||
config["new_package_name"].replace(".", "/"),
|
||||
),
|
||||
)
|
||||
|
||||
return True
|
3
patches/compress.config.json
Normal file
3
patches/compress.config.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"keep_dirs": ["META-INF", "kotlin"]
|
||||
}
|
25
patches/compress.py
Normal file
25
patches/compress.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
"""Remove and Compress unnecessary resources"""
|
||||
|
||||
priority = 0
|
||||
from tqdm import tqdm
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from typing import TypedDict
|
||||
|
||||
class PatchConfig_Compress(TypedDict):
|
||||
src: str
|
||||
keep_dirs: list[str]
|
||||
|
||||
def apply(config: PatchConfig_Compress) -> bool:
|
||||
for item in os.listdir(f"{config['src']}/unknown/"):
|
||||
item_path = os.path.join(f"{config['src']}/unknown/", item)
|
||||
|
||||
if os.path.isfile(item_path):
|
||||
os.remove(item_path)
|
||||
tqdm.write(f"removed file: {item_path}")
|
||||
elif os.path.isdir(item_path):
|
||||
if item not in config["keep_dirs"]:
|
||||
shutil.rmtree(item_path)
|
||||
tqdm.write(f"removed directory: {item_path}")
|
||||
return True
|
Loading…
Add table
Add a link
Reference in a new issue