-
Notifications
You must be signed in to change notification settings - Fork 9
/
magisk_font_changer.py
54 lines (51 loc) · 1.65 KB
/
magisk_font_changer.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
# -*- coding: utf-8 -*-
import os
debug = 0;
insert_line = 72 - 1 # from line - 1 to insert
last_line = 0
file_dir = "./system/fonts"
config_file_path = "./config.sh"
place_holder1 = "./system/fonts/placeholder"
place_holder2 = "./system/etc/placeholder"
files_list = []
insert_str = "data"
process_flag = "#This file has benn processed by Magisk Font Changer -- Python\n"
def file_name(file_dir):
for root, dirs, files in os.walk(file_dir):
if debug :
print("path:")
print(root)#current dir's path
print("sub path :")
print(dirs)#sub floders path in this path
print("files: " + str(type(files)))
print(files)#all files in current path
files_list.append(files)
print("Start Processing")
os.remove(place_holder1)
os.remove(place_holder2)
file_name(file_dir)
if len(files_list[0]) == 0:
print("Fonts files have NOT copy to ./system/fonts folder, please check\n")
exit()
insert_path = []
for file in files_list[0]:
insert_path.append("/system/fonts/" + str(file)+'\n')
insert_path.append("/system/etc/fonts.xml"+'\n')
#copy config.sh to config_file
config_file = open(config_file_path)
lines = []
for line in config_file:
lines.append(line)
config_file.close()
if(process_flag in lines):
print("ERROR: This file has been processed, please check ./config.sh\n Operation Abort\n")
exit()
lines.insert(insert_line - 2, process_flag)
for i in range(len(insert_path)):
last_line = insert_line + i
lines.insert(insert_line + i, insert_path[i])
s = ''.join(lines)
fp = open(config_file_path, 'w+')
fp.write(s)
fp.close()
print("All done")