The class knows how to format itself, so it should know how to indent itself, like the other two classes do. Signed-off-by: Mantas Mikulėnas <grawity@xxxxxxxxx> --- lsusb.py.in | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lsusb.py.in b/lsusb.py.in index 09363d3..b65cd80 100644 --- a/lsusb.py.in +++ b/lsusb.py.in @@ -238,9 +238,9 @@ def find_dev(driver, usbname): class UsbEndpoint: "Container for USB endpoint info" - def __init__(self, parent, fname, indent=18): + def __init__(self, parent, fname, level): self.parent = parent - self.indent = indent + self.level = level self.fname = fname self.epaddr = 0 self.len = 0 @@ -266,8 +266,9 @@ class UsbEndpoint: self.max = int(readattr(fullpath, "wMaxPacketSize"), 16) 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" % \ - (" " * self.indent, cols[5], self.epaddr, self.type, + (" " * indent, cols[5], self.epaddr, self.type, self.ival, self.attr, self.len, self.max, cols[0]) @@ -309,7 +310,7 @@ class UsbInterface: if showeps: for dirent in os.listdir(prefix + fullpath): if dirent[:3] == "ep_": - ep = UsbEndpoint(self, dirent, self.level + len(self.fname)) + ep = UsbEndpoint(self, dirent, self.level+1) self.eps.append(ep) def __str__(self): @@ -442,7 +443,7 @@ class UsbDevice: else: strg += "\n" if showeps: - ep = UsbEndpoint(self, "ep_00", self.level+len(self.fname)) + ep = UsbEndpoint(self, "ep_00", self.level+1) strg += str(ep) if showint: for iface in self.interfaces: -- 2.21.0