From 9fe0fceced1620c4a4423a48e9da8b988c627cd4 Mon Sep 17 00:00:00 2001 From: Viv Date: Fri, 2 Jun 2023 16:33:41 -0400 Subject: [PATCH] `tja2fumen.py`: Refactor `readStruct` and provide documentation --- tja2fumen/tja2fumen.py | 49 +++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/tja2fumen/tja2fumen.py b/tja2fumen/tja2fumen.py index b0be9bf..21d6f70 100644 --- a/tja2fumen/tja2fumen.py +++ b/tja2fumen/tja2fumen.py @@ -34,18 +34,12 @@ def readFumen(fumenFile, byteOrder=None, debug=False): song = {} - def readStruct(fmt, seek=None): - if seek: - file.seek(seek) - return struct.unpack(order + fmt, file.read(struct.calcsize(order + fmt))) - if byteOrder: order = ">" if byteOrder == "big" else "<" - totalMeasures = readStruct("I", 0x200)[0] + totalMeasures = readStruct(file, order, format_string="I", seek=0x200)[0] else: - order = "" - measuresBig = readStruct(">I", 0x200)[0] - measuresLittle = readStruct("