diff options
author | Mantas Mikulėnas <grawity@gmail.com> | 2019-05-06 12:02:35 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-06 14:29:36 +0200 |
commit | c513b7646687b35543f3e5a16640807a84eb1a5b (patch) | |
tree | 187756333d1456c5c01f4c62c4e626439264673a | |
parent | 2c30afa732bee40e253ba42f3b7015b1398676e4 (diff) | |
download | usbutils-c513b7646687b35543f3e5a16640807a84eb1a5b.tar.gz |
lsusb.py: add an actual __repr__() to classes
This simplifies debugging.
Signed-off-by: Mantas Mikulėnas <grawity@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | lsusb.py.in | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lsusb.py.in b/lsusb.py.in index d907711..e7a57fb 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] |