This commit is contained in:
2023-09-24 21:31:37 +08:00
commit 47839d32f4
5 changed files with 349 additions and 0 deletions

30
common.py Normal file
View File

@ -0,0 +1,30 @@
import logging
import zipfile
from pathlib import Path, PurePath
from typing import NamedTuple
logger = logging.getLogger(__name__)
class ExtractTask(NamedTuple):
old_path: zipfile.Path
new_path: Path | PurePath
def extract(task: ExtractTask):
logger.debug(f"{task.old_path} -> {task.new_path}")
with task.old_path.open("rb") as src_file:
with Path(task.new_path).open("wb") as target_file:
while True:
if chunk := src_file.read(4096):
target_file.write(chunk)
else:
break
class ArcaeaApkParser:
def __init__(self, zf: zipfile.ZipFile):
self.zf = zf
def parse(self) -> list[ExtractTask]:
raise NotImplementedError()