We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 19e8c8c commit 32d233cCopy full SHA for 32d233c
linuxpy/video/device.py
@@ -1654,6 +1654,17 @@ def __repr__(self) -> str:
1654
f"format={self.pixel_format.name}, frame_nb={self.frame_nb}, timestamp={self.timestamp}>"
1655
)
1656
1657
+ def __format__(self, spec):
1658
+ if spec in {"", "s"}:
1659
+ return str(self)
1660
+ elif spec == "r":
1661
+ return repr(self)
1662
+ elif spec == "f":
1663
+ return f"{self.width}x{self.height} {self.pixel_format.name}"
1664
+ elif spec == "l":
1665
+ return f"#{self.frame_nb} {self.timestamp} {self:f}"
1666
+ return str(getattr(self, spec))
1667
+
1668
@property
1669
def width(self):
1670
return self.format.width
0 commit comments