-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
63 lines (53 loc) · 2.43 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from config import * # 从config.py模块中导入所有内容
from defs import * # 从defs.py模块中导入所有内容
import argparse
def parse_arguments():
parser = argparse.ArgumentParser(
description="EMRA: A tool to process Android ROM and APK files")
parser.add_argument('-d', '--download', metavar='URL',
help='Download ROM from given URL')
parser.add_argument('-e', '--extract-payload', action='store_true',
help='Extract payload.bin from zip files')
parser.add_argument('-p', '--product-img', action='store_true',
help='Extract product.img from payload.bin')
parser.add_argument('-r', '--erofs', action='store_true',
help='Extract files from EROFS product.img')
parser.add_argument('-j', '--json', nargs=2, metavar=('Int', 'String'),
help='Change the dictionary type (two parameters in total), 0/1 => backup/no backup, ph/f/p => phone/fold/tablet')
parser.add_argument('-a', '--apk', action='store_true',
help='Remove specified APKs')
parser.add_argument('-n', '--rename', action='store_true',
help='Rename APK files')
parser.add_argument('-u', '--update-version',
action='store_true', help='Update APK versions')
parser.add_argument('-m', '--update-name',
action='store_true', help='Update APK names')
parser.add_argument('-c', '--clean', action='store_true',
help='Delete unnecessary files and folders')
return parser.parse_args()
def main():
args = parse_arguments()
init_folder()
exclude_apk, apk_version, apk_code, apk_code_name = init_json()
if args.download:
download_rom(args.download)
if args.extract_payload:
extract_payload_bin(zip_files)
if args.product_img:
extract_product_img()
if args.erofs:
extract_erofs_product()
if args.json:
move_json(args.json[0], args.json[1])
if args.apk:
remove_some_apk(exclude_apk)
if args.rename:
rename_apk(apk_files)
if args.update_version:
update_apk_version(apk_version, apk_code, apk_code_name)
if args.update_name:
update_apk_name()
if args.clean:
delete_files_and_folders()
if __name__ == "__main__": # 如果这个脚本文件是被直接运行的
main() # 调用main()函数