From 4ae6fa7b2e477430413517b96179c05fedca8d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 7 Aug 2026 09:27:42 +0800 Subject: [PATCH] Merge the two identical chart-position formatters of the CSV exporter Co-Authored-By: Claude Opus 5 (1M context) --- .../pop_fem_audit_tools/commands/build_db.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tools/src/pop_fem_audit_tools/commands/build_db.py b/tools/src/pop_fem_audit_tools/commands/build_db.py index 7a4ec9a..0f3ea68 100644 --- a/tools/src/pop_fem_audit_tools/commands/build_db.py +++ b/tools/src/pop_fem_audit_tools/commands/build_db.py @@ -814,20 +814,7 @@ class CSVExporter: @classmethod def __song_positions(cls, song: Song) -> str: - """Format the chart positions of a song for the songs.csv - 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. + """Format the chart positions of a song. :param song: The song with its chart entries loaded. :return: The "YEAR#RANK" tokens, ordered by year then rank, @@ -869,7 +856,7 @@ class CSVExporter: (x.song for x in artist.song_artists), key=lambda x: x.title.casefold()) entries: list[str] = [ - f"{song.title} ({cls.__formatted_song_positions(song)})" + f"{song.title} ({cls.__song_positions(song)})" for song in songs] return "|".join(entries)