Skip to content

Commit 792bbd9

Browse files
author
Zarcher
committed
update
add translate use Poetry instead fix magisk module template fetch fix line break error in WIN
1 parent 8063e1c commit 792bbd9

19 files changed

+568
-369
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,11 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# IDE
107+
.vscode
108+
.idea
109+
110+
# peotry
111+
112+
poetry.lock

ConfigCheck.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

ImgProcess.py

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import platform
66
import shutil
77
import subprocess
8-
from dataclasses import dataclass
98
from typing import Any, Dict, List, Optional, Tuple, Union
109

1110
from colorama import Fore
@@ -14,33 +13,6 @@
1413
from tqdm import tqdm
1514

1615

17-
def check_env() -> bool:
18-
"""
19-
check the system environment, tool's Availability such as 'gifsicle', 'pngquant'
20-
:return: bool
21-
"""
22-
e = platform.uname()
23-
24-
if e.system == 'Linux':
25-
cmds = ['gifsicle', 'pngquant']
26-
for cmd in cmds:
27-
if shutil.which(cmd) is None:
28-
print(f'<{cmd}> doesn\'t seem to be installed, please check!')
29-
return False
30-
31-
elif e.system == 'Windows':
32-
cmds = ['.\\bin\\gifsicle\\gifsicle.exe', '.\\bin\\pngquant\\pngquant.exe']
33-
for cmd in cmds:
34-
if shutil.which(cmd) is None:
35-
print(f'<{cmd}> doesn\'t seem to exist, please check!')
36-
return False
37-
else:
38-
print(f'Platform <{e.system}> has not been supported!')
39-
return False
40-
41-
return True
42-
43-
4416
def gif2png(gif_path: str, to_dir_path: str, temp_im_path: str = './temp.gif') -> None:
4517
"""
4618
Iterate the GIF, extracting each frame.
@@ -199,17 +171,17 @@ def auto_bg_color(im_path: str):
199171
return (0, 0, 0, 255)
200172

201173

202-
@dataclass
203-
class PasteConf:
174+
class PasteConf():
204175
"""
205176
paste configuration class
206177
"""
207-
im_path: Optional[str]
208-
resize_mode: str
209-
target_w: int
210-
target_h: int
211-
c_pos_x: int
212-
c_pos_y: int
178+
def __init__(self, im_path: Optional[str], resize_mode: str, target_w: int, target_h: int, c_pos_x: int, c_pos_y: int):
179+
self.im_path = im_path
180+
self.resize_mode = resize_mode
181+
self.target_w = target_w
182+
self.target_h = target_h
183+
self.c_pos_x = c_pos_x
184+
self.c_pos_y = c_pos_y
213185

214186

215187
def _paste(bg: Image, p_conf: PasteConf) -> None:

PackageMake.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def desc_file_creat(desc_path: str, desc_conf: Dict) -> IO:
2626
height = desc_conf.get('height')
2727
fps = desc_conf.get('fps')
2828

29-
with open(desc_path, mode="w+") as desc_f:
29+
with open(desc_path, mode="w+", newline='\n') as desc_f:
3030
content = "{} {} {}\n".format(width, height, fps)
3131
for part in desc_conf.get('parts'):
3232
content += "{} {} {} {}\n".format(part['type'], part['count'], part['pause'], part['path'])
@@ -54,12 +54,18 @@ def template_prepare(template_dir_path: str, template_file_name: str, download_u
5454
:param unzip_dir_path: path to unzip
5555
:return: None
5656
"""
57+
# TODO: 更新 updater-binary
5758
template_file_path = os.path.join(template_dir_path, template_file_name)
5859
if not os.path.exists(template_file_path):
5960
utils.download_file(download_url, template_file_path)
6061
utils.unzipfile(template_file_path, unzip_dir_path)
6162

6263

64+
def update_binary_modify(update_binary_file_path: str, module_installer_sh_url: str):
65+
utils.download_file(module_installer_sh_url, update_binary_file_path)
66+
pass
67+
68+
6369
def module_prop_modify(module_prop_file_path: str, module_prop_conf: Dict) -> None:
6470
"""
6571
<module.prop> modify
@@ -72,7 +78,6 @@ def module_prop_modify(module_prop_file_path: str, module_prop_conf: Dict) -> No
7278
'versionCode': '2018103101'
7379
'author': 'Zarcher'
7480
'description': 'A Boot Animation Magisk Module'
75-
'minMagisk': '17000'
7681
}
7782
:return: None
7883
"""
@@ -82,11 +87,10 @@ def module_prop_modify(module_prop_file_path: str, module_prop_conf: Dict) -> No
8287
f"version={module_prop_conf.get('version')}\n",
8388
f"versionCode={module_prop_conf.get('versionCode')}\n",
8489
f"author={module_prop_conf.get('author')}\n",
85-
f"description={module_prop_conf.get('description')}\n",
86-
f"minMagisk={module_prop_conf.get('minMagisk')}\n"
90+
f"description={module_prop_conf.get('description')}\n"
8791
]
8892
content = ''.join(content_list)
89-
with open(module_prop_file_path, 'w+') as mp_f:
93+
with open(module_prop_file_path, 'w+', newline='\n') as mp_f:
9094
mp_f.write(content)
9195

9296

@@ -117,9 +121,9 @@ def module_config_modify(module_config_file_path: str, module_config_conf: Optio
117121
re.compile('REPLACE="\n"')
118122
]
119123

120-
with open(module_config_file_path, 'r') as f:
124+
with open(module_config_file_path, 'r', newline='\n') as f:
121125
content = f.read()
122-
with open(module_config_file_path, 'w') as f:
126+
with open(module_config_file_path, 'w', newline='\n') as f:
123127
for patt, sub_content in zip(patts, sub_contents):
124128
# print(re.findall(patt, content))
125129
content = re.sub(patt, sub_content, content)

README.md

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ A tool to combine the images (png, jpg ...) and motion images (gif) to make Andr
88

99
### Python and Python Dependencies
1010

11-
Please ensure that **Python version >= 3.7** because new features such as dataclass are used.
12-
13-
```txt
14-
# Python dependencies
15-
16-
pillow >= 5.3.0
17-
tqdm >= 4.28.1
18-
requests >= 2.20.1
19-
colorama >= 0.4.1
20-
click >= 7.0
21-
pyyaml >= 3.13
11+
```auto
12+
python >= 3.6
13+
14+
pillow >= 5.3.0
15+
tqdm >= 4.28.1
16+
requests >= 2.20.1
17+
colorama >= 0.4.1
18+
click >= 7.0
19+
pyyaml >= 3.13
20+
printtags >= 1.4
2221
```
2322

24-
Please check these dependencies, or install them using `pip install-r requirements.txt`.
23+
This project uses `poetry` for dependency management. Run `poetry install` in the script root directory to install the virtual environment and dependencies, and run `poetry run python run.py` to run the script.
2524

2625
### Other Dependencies
2726

@@ -43,35 +42,29 @@ This script also uses third-party software such as [gifsicle](https://www.lcdf.o
4342

4443
## Getting Started
4544

46-
Get the script. Download or use `git`
47-
48-
```sh
49-
git clone https://github.com/Zarcher0/BootAnimationMaker.git
50-
```
51-
52-
Open Terminal(PowerShell) in the script folder
45+
* Get the script. Download or use `git clone`
5346

54-
Prepare the images witch to be made into animations. Then it is suggested to place them in a subfolder under the script folder, and create a new `config.yml` file in it. Its format refers to [config_template.yml](config_template.yml).
47+
```sh
48+
git clone https://github.com/Zarcher0/BootAnimationMaker.git
49+
```
5550

56-
Then run `run.py'.
51+
* Prepare the material which to made animations. Put them into a subfolder(new) under the script root directory, and create a new `config.yml` file in it. Its format refers to [config_template.yml](config_template_CN.yml).
5752

58-
```sh
59-
python run.py # The default configuration file path is "./config.yml"
53+
* In root folder of the script, Then run `python run.py --config xxxx` or `poetry run python run.py --config xxxx` (if uses poetry).
6054

61-
# Or use "--config" to specify a configuration path
55+
> when run `python run.py`, the default configuration file path is `./config.yml`use `--config` to specify a configuration path `python run.py --config xxxxx`
6256

63-
python run.py --config xxxxx
64-
```
65-
66-
See the `example` folder for several reference examples.
57+
Look at the `example` folder for several reference examples.
6758

6859
For example, to run `example/1`
6960

7061
```sh
7162
python run.py --config ./example/1/config.yml
7263
```
7364

74-
After generating you can find the Magisk module and preview gif in `./export` directory.
65+
After generating you can find the Magisk module and its preview gif in `./export` directory.
66+
67+
![Screenshot0](./example/Screenshot0.png)
7568

7669
> Note: If the image path in the `config.yml` file is a relative path, the default is relative to the running environment. It is recommended to use an absolute path to avoid errors.
7770

0 commit comments

Comments
 (0)