mirror of
https://github.com/beetbox/beets.git
synced 2025-12-16 05:34:47 +01:00
Dedupe "changed" colorize calls
This commit is contained in:
parent
04380676e1
commit
f8c2008f29
1 changed files with 9 additions and 9 deletions
|
|
@ -21,6 +21,7 @@ import re
|
|||
import textwrap
|
||||
from collections import Counter
|
||||
from collections.abc import Sequence
|
||||
from functools import cached_property
|
||||
from itertools import chain
|
||||
from platform import python_version
|
||||
from typing import Any, NamedTuple
|
||||
|
|
@ -303,6 +304,10 @@ class ChangeRepresentation:
|
|||
TrackMatch object, accordingly.
|
||||
"""
|
||||
|
||||
@cached_property
|
||||
def changed_prefix(self) -> str:
|
||||
return ui.colorize("changed", "\u2260")
|
||||
|
||||
cur_artist = None
|
||||
# cur_album set if album, cur_title set if singleton
|
||||
cur_album = None
|
||||
|
|
@ -394,7 +399,6 @@ class ChangeRepresentation:
|
|||
"""Print out the details of the match, including changes in album name
|
||||
and artist name.
|
||||
"""
|
||||
changed_prefix = ui.colorize("changed", "\u2260")
|
||||
# Artist.
|
||||
artist_l, artist_r = self.cur_artist or "", self.match.info.artist
|
||||
if artist_r == VARIOUS_ARTISTS:
|
||||
|
|
@ -402,9 +406,8 @@ class ChangeRepresentation:
|
|||
artist_l, artist_r = "", ""
|
||||
if artist_l != artist_r:
|
||||
artist_l, artist_r = ui.colordiff(artist_l, artist_r)
|
||||
# Prefix with U+2260: Not Equal To
|
||||
left = {
|
||||
"prefix": f"{changed_prefix} Artist: ",
|
||||
"prefix": f"{self.changed_prefix} Artist: ",
|
||||
"contents": artist_l,
|
||||
"suffix": "",
|
||||
}
|
||||
|
|
@ -422,9 +425,8 @@ class ChangeRepresentation:
|
|||
and self.match.info.album != VARIOUS_ARTISTS
|
||||
):
|
||||
album_l, album_r = ui.colordiff(album_l, album_r)
|
||||
# Prefix with U+2260: Not Equal To
|
||||
left = {
|
||||
"prefix": f"{changed_prefix} Album: ",
|
||||
"prefix": f"{self.changed_prefix} Album: ",
|
||||
"contents": album_l,
|
||||
"suffix": "",
|
||||
}
|
||||
|
|
@ -437,9 +439,8 @@ class ChangeRepresentation:
|
|||
title_l, title_r = self.cur_title or "", self.match.info.title
|
||||
if self.cur_title != self.match.info.title:
|
||||
title_l, title_r = ui.colordiff(title_l, title_r)
|
||||
# Prefix with U+2260: Not Equal To
|
||||
left = {
|
||||
"prefix": f"{changed_prefix} Title: ",
|
||||
"prefix": f"{self.changed_prefix} Title: ",
|
||||
"contents": title_l,
|
||||
"suffix": "",
|
||||
}
|
||||
|
|
@ -568,9 +569,8 @@ class ChangeRepresentation:
|
|||
# the case, thus the 'info' dictionary is unneeded.
|
||||
# penalties = penalty_string(self.match.distance.tracks[track_info])
|
||||
|
||||
prefix = ui.colorize("changed", "\u2260 ") if changed else "* "
|
||||
lhs = {
|
||||
"prefix": f"{prefix}{lhs_track} ",
|
||||
"prefix": f"{self.changed_prefix if changed else '*'} {lhs_track} ",
|
||||
"contents": lhs_title,
|
||||
"suffix": f" {lhs_length}",
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue