1
0
mirror of synced 2025-02-03 05:07:17 +01:00

Standarize I/O for read/writeFumen functions

This commit is contained in:
Viv 2023-06-29 20:56:34 -04:00
parent 1ea10e0635
commit 73b1fed5a7
3 changed files with 4 additions and 6 deletions

View File

@ -39,7 +39,7 @@ def main(argv=None):
# Write fumen data to files
for fumenData, outputName in zip(parsedSongsFumen.values(), outputFilenames):
writeFumen(open(outputName, "wb"), fumenData)
writeFumen(outputName, fumenData)
if return_vars:
return parsedSongsTJA, parsedSongsFumen, outputFilenames

View File

@ -286,10 +286,7 @@ def readFumen(fumenFile, exclude_empty_measures=False):
For more information on any of the terms used in this function (e.g. scoreInit, scoreDiff),
please refer to KatieFrog's excellent guide: https://gist.github.com/KatieFrogs/e000f406bbc70a12f3c34a07303eec8b
"""
if type(fumenFile) is str:
file = open(fumenFile, "rb")
else:
file = fumenFile
size = os.fstat(file.fileno()).st_size
# Fetch the header bytes

View File

@ -2,11 +2,12 @@ from tja2fumen.utils import writeStruct, putBool
from tja2fumen.constants import branchNames, typeNotes
def writeFumen(file, song):
def writeFumen(path_out, song):
# Fetch the byte order (little/big endian)
order = song['order']
# Write the header
file = open(path_out, "wb")
file.write(song['headerPadding']) # Write header padding bytes
file.write(song['headerMetadata']) # Write header metadata bytes