simfile-scripts/docs/get-charts-for-one-game-mode.py
2022-08-20 18:02:25 -07:00

13 lines
426 B
Python

from typing import Iterator
from simfile.types import Chart
# Imperative version
def charts_for_stepstype(charts, stepstype="dance-single") -> Iterator[Chart]:
for chart in charts:
if chart.stepstype == stepstype:
yield chart
# One-liner version
def charts_for_stepstype(charts, stepstype="dance-single") -> Iterator[Chart]:
yield from filter(lambda chart: chart.stepstype == stepstype, charts)