From 642ad393b6076ea5de615e85f8170b86e7b4b0cc Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 14 Apr 2024 02:59:20 +0100 Subject: [PATCH] style: Move __...__ methods after constructors --- devine/core/tracks/audio.py | 22 +++++++++++----------- devine/core/tracks/subtitle.py | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/devine/core/tracks/audio.py b/devine/core/tracks/audio.py index b08396f..481a814 100644 --- a/devine/core/tracks/audio.py +++ b/devine/core/tracks/audio.py @@ -76,6 +76,17 @@ class Audio(Track): self.joc = joc self.descriptive = bool(descriptive) + def __str__(self) -> str: + return " | ".join(filter(bool, [ + "AUD", + f"[{self.codec.value}]", + str(self.channels or "?") + (f" (JOC {self.joc})" if self.joc else ""), + f"{self.bitrate // 1000 if self.bitrate else '?'} kb/s", + str(self.language), + self.get_track_name(), + self.edition + ])) + @staticmethod def parse_channels(channels: Union[str, int, float]) -> float: """ @@ -109,16 +120,5 @@ class Audio(Track): track_name += flag return track_name or None - def __str__(self) -> str: - return " | ".join(filter(bool, [ - "AUD", - f"[{self.codec.value}]", - str(self.channels or "?") + (f" (JOC {self.joc})" if self.joc else ""), - f"{self.bitrate // 1000 if self.bitrate else '?'} kb/s", - str(self.language), - self.get_track_name(), - self.edition - ])) - __all__ = ("Audio",) diff --git a/devine/core/tracks/subtitle.py b/devine/core/tracks/subtitle.py index bfeaa38..fb21f3f 100644 --- a/devine/core/tracks/subtitle.py +++ b/devine/core/tracks/subtitle.py @@ -139,6 +139,14 @@ class Subtitle(Track): # Called after Track has been converted to another format self.OnConverted: Optional[Callable[[Subtitle.Codec], None]] = None + def __str__(self) -> str: + return " | ".join(filter(bool, [ + "SUB", + f"[{self.codec.value}]", + str(self.language), + self.get_track_name() + ])) + def get_track_name(self) -> Optional[str]: """Return the base Track Name.""" track_name = super().get_track_name() or "" @@ -525,13 +533,5 @@ class Subtitle(Track): stdout=subprocess.DEVNULL ) - def __str__(self) -> str: - return " | ".join(filter(bool, [ - "SUB", - f"[{self.codec.value}]", - str(self.language), - self.get_track_name() - ])) - __all__ = ("Subtitle",)