1
0
mirror of synced 2024-12-05 03:27:54 +01:00

Fix memon pre-conversion sanity checks

This commit is contained in:
Stepland 2021-05-01 13:41:01 +02:00
parent 23b507f36a
commit ceafaad4c3
2 changed files with 17 additions and 9 deletions

View File

@ -1,3 +1,7 @@
# v0.1.3
## Fixed
- memon : Fix TypeError that would occur when trying to convert to memon
# v0.1.2 # v0.1.2
## Fixed ## Fixed
- jubeat analyser - jubeat analyser

View File

@ -268,21 +268,25 @@ def _raise_if_unfit_for_v0(song: Song, version: str) -> None:
"""Raises an exception if the Song object is ill-formed or contains information """Raises an exception if the Song object is ill-formed or contains information
that cannot be represented in a memon v0.x.y file (includes legacy)""" that cannot be represented in a memon v0.x.y file (includes legacy)"""
if (
len(set(chart.timing for chart in song.charts.values() if chart is not None))
> 1
):
raise ValueError(
f"memon:{version} cannot represent a song with per-chart timing"
)
if song.global_timing is None and all( if song.global_timing is None and all(
chart.timing is None for chart in song.charts.values() chart.timing is None for chart in song.charts.values()
): ):
raise ValueError("The song has no timing information") raise ValueError("The song has no timing information")
timing = _get_timing(song) chart_timings = [
chart.timing
for chart in song.charts.values()
if chart.timing is not None
]
if chart_timings:
first_one = chart_timings[0]
if any(t != first_one for t in chart_timings):
raise ValueError(
f"memon:{version} cannot represent a song with per-chart timing"
)
timing = _get_timing(song)
number_of_timing_events = len(timing.events) number_of_timing_events = len(timing.events)
if number_of_timing_events != 1: if number_of_timing_events != 1:
if number_of_timing_events == 0: if number_of_timing_events == 0: