[PATCH 28/34] lsusb.py: add an actual __repr__() to classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This simplifies debugging.

Signed-off-by: Mantas Mikulėnas <grawity@xxxxxxxxx>
---
 lsusb.py.in | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lsusb.py.in b/lsusb.py.in
index 5720cd2..577eb0a 100644
--- a/lsusb.py.in
+++ b/lsusb.py.in
@@ -258,6 +258,9 @@ class UsbEndpoint:
 		self.attr = int(readattr(self.path, "bmAttributes"), 16)
 		self.max = int(readattr(self.path, "wMaxPacketSize"), 16)
 
+	def __repr__(self):
+		return "<UsbEndpoint[%r]>" % self.fname
+
 	def __str__(self):
 		indent = self.level + len(self.parent.fname)
 		return "%-17s  %s(EP) %02x: %s %s attr %02x len %02x max %03x%s\n" % \
@@ -302,6 +305,9 @@ class UsbInterface:
 					ep = UsbEndpoint(self, dirent, self.level+1)
 					self.eps.append(ep)
 
+	def __repr__(self):
+		return "<UsbInterface[%r]>" % self.fname
+
 	def __str__(self):
 		plural = (" " if self.noep == 1 else "s")
 		strg = "%-17s (IF) %02x:%02x:%02x %iEP%s (%s) %s%s %s%s%s\n" % \
@@ -405,6 +411,9 @@ class UsbDevice:
 		self.interfaces.sort(key=usbsortkey)
 		self.children.sort(key=usbsortkey)
 
+	def __repr__(self):
+		return "<UsbDevice[%r]>" % self.fname
+
 	def __str__(self):
 		if self.iclass == HUB_ICLASS:
 			col = cols[2]
-- 
2.21.0




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux