Files
A1SwapModPacker/a1_swap_mod_packer/archive.py
T
2026-04-28 14:39:54 +08:00

17 lines
499 B
Python

from __future__ import annotations
import re
import zipfile
GCODE_MEMBER_RE = re.compile(r"^Metadata/plate_(\d+)\.gcode$")
MD5_MEMBER_RE = re.compile(r"^Metadata/plate_(\d+)\.gcode\.md5$")
def list_gcode_members(archive: zipfile.ZipFile) -> list[str]:
members: list[tuple[int, str]] = []
for name in archive.namelist():
match = GCODE_MEMBER_RE.match(name)
if match:
members.append((int(match.group(1)), name))
return [name for _, name in sorted(members)]