init
This commit is contained in:
30
common.py
Normal file
30
common.py
Normal 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()
|
||||
Reference in New Issue
Block a user