31 lines
756 B
Python
31 lines
756 B
Python
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()
|