Implement verbose arg on tree method of Movies and Album

This commit is contained in:
rlaphoenix 2023-02-26 19:04:54 +00:00
parent 375ccd7638
commit 401d0481df
2 changed files with 14 additions and 12 deletions

View File

@ -137,17 +137,18 @@ class Movies(SortedKeyList, ABC):
# TODO: Assumes there's only one movie
return self[0].name + (f" ({self[0].year})" if self[0].year else "")
def tree(self, *_) -> Tree:
def tree(self, verbose: bool = False) -> Tree:
num_movies = len(self)
tree = Tree(
f"{num_movies} Movie{['s', ''][num_movies == 1]}",
guide_style="bright_black"
)
for movie in self:
tree.add(
f"[bold]{movie.name}[/] [bright_black]({movie.year or '?'})",
guide_style="bright_black"
)
if verbose:
for movie in self:
tree.add(
f"[bold]{movie.name}[/] [bright_black]({movie.year or '?'})",
guide_style="bright_black"
)
return tree

View File

@ -132,17 +132,18 @@ class Album(SortedKeyList, ABC):
return super().__str__()
return f"{self[0].artist} - {self[0].album} ({self[0].year or '?'})"
def tree(self, *_) -> Tree:
def tree(self, verbose: bool = False) -> Tree:
num_songs = len(self)
tree = Tree(
f"{num_songs} Song{['s', ''][num_songs == 1]}",
guide_style="bright_black"
)
for song in self:
tree.add(
f"[bold]Track {song.track:02}.[/] [bright_black]({song.name})",
guide_style="bright_black"
)
if verbose:
for song in self:
tree.add(
f"[bold]Track {song.track:02}.[/] [bright_black]({song.name})",
guide_style="bright_black"
)
return tree