Standarize I/O for read/writeFumen functions
This commit is contained in:
parent
1ea10e0635
commit
73b1fed5a7
@ -39,7 +39,7 @@ def main(argv=None):
|
|||||||
|
|
||||||
# Write fumen data to files
|
# Write fumen data to files
|
||||||
for fumenData, outputName in zip(parsedSongsFumen.values(), outputFilenames):
|
for fumenData, outputName in zip(parsedSongsFumen.values(), outputFilenames):
|
||||||
writeFumen(open(outputName, "wb"), fumenData)
|
writeFumen(outputName, fumenData)
|
||||||
|
|
||||||
if return_vars:
|
if return_vars:
|
||||||
return parsedSongsTJA, parsedSongsFumen, outputFilenames
|
return parsedSongsTJA, parsedSongsFumen, outputFilenames
|
||||||
|
@ -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),
|
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
|
please refer to KatieFrog's excellent guide: https://gist.github.com/KatieFrogs/e000f406bbc70a12f3c34a07303eec8b
|
||||||
"""
|
"""
|
||||||
if type(fumenFile) is str:
|
|
||||||
file = open(fumenFile, "rb")
|
file = open(fumenFile, "rb")
|
||||||
else:
|
|
||||||
file = fumenFile
|
|
||||||
size = os.fstat(file.fileno()).st_size
|
size = os.fstat(file.fileno()).st_size
|
||||||
|
|
||||||
# Fetch the header bytes
|
# Fetch the header bytes
|
||||||
|
@ -2,11 +2,12 @@ from tja2fumen.utils import writeStruct, putBool
|
|||||||
from tja2fumen.constants import branchNames, typeNotes
|
from tja2fumen.constants import branchNames, typeNotes
|
||||||
|
|
||||||
|
|
||||||
def writeFumen(file, song):
|
def writeFumen(path_out, song):
|
||||||
# Fetch the byte order (little/big endian)
|
# Fetch the byte order (little/big endian)
|
||||||
order = song['order']
|
order = song['order']
|
||||||
|
|
||||||
# Write the header
|
# Write the header
|
||||||
|
file = open(path_out, "wb")
|
||||||
file.write(song['headerPadding']) # Write header padding bytes
|
file.write(song['headerPadding']) # Write header padding bytes
|
||||||
file.write(song['headerMetadata']) # Write header metadata bytes
|
file.write(song['headerMetadata']) # Write header metadata bytes
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user