Skip to content

Commit

Permalink
style: Move __...__ methods after constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Apr 14, 2024
1 parent 23485bc commit 642ad39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
22 changes: 11 additions & 11 deletions devine/core/tracks/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ def __init__(self, *args: Any, codec: Audio.Codec, bitrate: Union[str, int, floa
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:
"""
Expand Down Expand Up @@ -109,16 +120,5 @@ def get_track_name(self) -> Optional[str]:
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",)
16 changes: 8 additions & 8 deletions devine/core/tracks/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ def __init__(self, *args: Any, codec: Subtitle.Codec, cc: bool = False, sdh: boo
# 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 ""
Expand Down Expand Up @@ -525,13 +533,5 @@ def reverse_rtl(self) -> None:
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",)

0 comments on commit 642ad39

Please sign in to comment.