Skip to content

Commit

Permalink
fix: better repr for file instances
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Mar 1, 2022
1 parent 5d8320f commit 54c46c4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions beet/core/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ def dump(self, origin: FileOrigin, path: FileSystemPath):
else:
Path(origin, path).write_bytes(raw)

def __repr__(self) -> str:
content = (
repr(self._content)
if self._content is not None
else f"source_path={self.source_path!r}"
+ (self.source_start is not None) * f", source_start={self.source_start}"
+ (self.source_stop is not None) * f", source_stop={self.source_stop}"
if self.source_path
else ""
)
return f"{self.__class__.__name__}({content})"


class FileSerialize(Generic[SerializeType]):
"""Descriptor that makes sure that content of the file is serialized."""
Expand Down

0 comments on commit 54c46c4

Please sign in to comment.