Merge the two identical chart-position formatters of the CSV exporter
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -814,20 +814,7 @@ class CSVExporter:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __song_positions(cls, song: Song) -> str:
|
def __song_positions(cls, song: Song) -> str:
|
||||||
"""Format the chart positions of a song for the songs.csv
|
"""Format the chart positions of a song.
|
||||||
value.
|
|
||||||
|
|
||||||
:param song: The song with its chart entries loaded.
|
|
||||||
:return: The "YEAR#RANK" tokens, ordered by year then rank,
|
|
||||||
joined by "/".
|
|
||||||
"""
|
|
||||||
entries: list[ChartEntry] = cls.__sorted_chart_entries(song)
|
|
||||||
return "/".join(f"{x.year}#{x.rank}" for x in entries)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def __formatted_song_positions(cls, song: Song) -> str:
|
|
||||||
"""Format the chart positions of a song for the artists.csv
|
|
||||||
value.
|
|
||||||
|
|
||||||
:param song: The song with its chart entries loaded.
|
:param song: The song with its chart entries loaded.
|
||||||
:return: The "YEAR#RANK" tokens, ordered by year then rank,
|
:return: The "YEAR#RANK" tokens, ordered by year then rank,
|
||||||
@@ -869,7 +856,7 @@ class CSVExporter:
|
|||||||
(x.song for x in artist.song_artists),
|
(x.song for x in artist.song_artists),
|
||||||
key=lambda x: x.title.casefold())
|
key=lambda x: x.title.casefold())
|
||||||
entries: list[str] = [
|
entries: list[str] = [
|
||||||
f"{song.title} ({cls.__formatted_song_positions(song)})"
|
f"{song.title} ({cls.__song_positions(song)})"
|
||||||
for song in songs]
|
for song in songs]
|
||||||
return "|".join(entries)
|
return "|".join(entries)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user