1
0
mirror of synced 2024-11-27 22:40:49 +01:00

Fix Pylint issues

This commit is contained in:
Viv 2023-07-24 03:09:37 +00:00 committed by GitHub
parent e848fc9499
commit e9aa175797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 20 deletions

View File

@ -297,7 +297,7 @@ def convert_tja_to_fumen(tja):
# Create notes based on TJA measure data
branch_points_measure = 0
for idx_d, data in enumerate(measure_tja.data):
for data in measure_tja.data:
# Compute the ms position of the note
pos_ratio = ((data.pos - measure_tja.pos_start)
/ measure_length)
@ -338,9 +338,9 @@ def convert_tja_to_fumen(tja):
if note.type in ["Balloon", "Kusudama"]:
try:
note.hits = course_balloons.pop(0)
except IndexError:
except IndexError as e:
raise ValueError(f"Not enough values for 'BALLOON: "
f"{','.join(course_balloons)}'")
f"{','.join(course_balloons)}'") from e
current_drumroll = note
elif note.type in ["Drumroll", "DRUMROLL"]:
current_drumroll = note

View File

@ -246,7 +246,7 @@ def parse_tja_course_data(course):
del branch[-1]
# Merge measure data and measure events in chronological order
for branch_name, branch in course.branches.items():
for branch in course.branches.values():
for measure in branch:
notes = [TJAData('note', TJA_NOTE_TYPES[note], i)
for i, note in enumerate(measure.notes) if note != '0']
@ -288,7 +288,7 @@ def parse_fumen(fumen_file, exclude_empty_measures=False):
header=FumenHeader(raw_bytes=file.read(520))
)
for measure_number in range(song.header.b512_b515_number_of_measures):
for _ in range(song.header.b512_b515_number_of_measures):
# Parse the measure data using the following `format_string`:
# "ffBBHiiiiiii" (12 format characters, 40 bytes per measure)
# - 'f': BPM (one float (4 bytes))
@ -331,7 +331,7 @@ def parse_fumen(fumen_file, exclude_empty_measures=False):
)
# Iterate through each note in the measure (per branch)
for note_number in range(total_notes):
for _ in range(total_notes):
# Parse the note data using the following `format_string`:
# "ififHHf" (7 format characters, 24 bytes per note cluster)
# - 'i': note type

View File

@ -134,8 +134,6 @@ class FumenNote:
self.score_init = score_init
self.score_diff = score_diff
self.padding = padding
# TODO: Determine how to properly set the item byte
# (https://github.com/vivaria/tja2fumen/issues/17)
self.item = item
# These attributes are only used for drumrolls/balloons
self.duration = duration
@ -150,15 +148,8 @@ class FumenNote:
class FumenHeader:
def __init__(self, raw_bytes=None):
if raw_bytes is None:
self.order = "<"
self._assign_default_header_values()
else:
self.order = self._parse_order(raw_bytes)
self._parse_header_values(raw_bytes)
def _assign_default_header_values(self):
# This byte string corresponds to
# Set default header bytes
self.order = "<"
timing_windows = self.up(b'43\xc8Ag&\x96B"\xe2\xd8B' * 36, "fff" * 36)
self.b000_b431_timing_windows = timing_windows
self.b432_b435_has_branches = 0
@ -183,8 +174,9 @@ class FumenHeader:
self.b508_b511_dummy_data = 12345678
self.b512_b515_number_of_measures = 0
self.b516_b519_unknown_data = 0
def _parse_header_values(self, raw_bytes):
if not raw_bytes:
return
# Parse raw bytes
rb = raw_bytes
self.b000_b431_timing_windows = self.up(rb, "f" * 108,
0, 431)
@ -246,7 +238,8 @@ class FumenHeader:
}
key = f"{difficulty}-{star_to_key[difficulty][stars]}"
pkg_dir = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(pkg_dir, "hp_values.csv"), newline='') as fp:
with open(os.path.join(pkg_dir, "hp_values.csv"),
newline='', encoding="utf-8") as fp:
# Parse row data
rows = [row for row in csv.reader(fp, delimiter=',')]
# Get column numbers by indexing header row