From 401d0481dfe4c2945368b050931fb3724b7e747f Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 26 Feb 2023 19:04:54 +0000 Subject: [PATCH] Implement verbose arg on tree method of Movies and Album --- devine/core/titles/movie.py | 13 +++++++------ devine/core/titles/song.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/devine/core/titles/movie.py b/devine/core/titles/movie.py index 4c4a4f3..633ec52 100644 --- a/devine/core/titles/movie.py +++ b/devine/core/titles/movie.py @@ -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 diff --git a/devine/core/titles/song.py b/devine/core/titles/song.py index 48236b8..70e27d0 100644 --- a/devine/core/titles/song.py +++ b/devine/core/titles/song.py @@ -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