def color_interface_line(interface_id): catalog = Catalog() interface = catalog.interface(interface_id) hierarchy = [ cl.__name__ for cl in reversed(inspect.getmro(interface)) if cl in catalog._interfaces.values() ] hierarchy = ' > '.join(hierarchy) return '\033[93m%s\033[91m (%s)\033[0m' % (interface_id, hierarchy)
def list_interfaces(): catalog = Catalog() print '==========' print 'Interfaces' print '==========' for interface_id in sorted(catalog.interfaces()): interface = catalog.interface(interface_id) print color_interface_line(interface_id) print ' defined in:', interface.__module__ print print
def color_interface_line(interface_id): catalog = Catalog() interface = catalog.interface(interface_id) hierarchy = [cl.__name__ for cl in reversed(inspect.getmro(interface)) if cl in catalog._interfaces.values()] hierarchy = ' > '.join(hierarchy) return '\033[93m%s\033[91m (%s)\033[0m' % (interface_id, hierarchy)