walac/pyusb — pull request #46 by swinman (2014-05-21 17:30:40+00:00)
Title: Easy interactive v2

There are a few differences between this and what you suggested on previous pull request
1) Interface.endpoints returns a list instead of a generator - lists naturally have much better ```__repr__``` and also have ```__get_item__``` whereas this is not the case with generators (at least in python 2)

2) I don't change ```__repr__``` for Interfaces etc. but instead provide various properties for formatted descriptors. .descriptor is the full descriptor for the current object (not recursive), .descriptor_full is the recursive full descriptor for the current item (including all below descriptors), and .descriptor_summary is also recursive but only shows one line for each of the below objects (eg an interface will show 1 line for each endpoint). The ```__str__``` special method shows the same 1 line summary as .descriptor_summary (but is not recursive).

The issue of printing / show is resolved here by re-implementing the ```__repr__``` of a string for the descriptors so that they format newline properly on the terminal (but otherwise are exactly the same as returning regular strings).

The verbose flag in show_device_info can be set to True or "very"... I don't particularly like this behavior but I think both the 1 line, summary and full representations are all useful so some sort of a 3-way flag I think makes sense