Print list of available network interfaces in human readable form :param print_result: print the results if True, else return it :param hidden: if True, also displays invalid interfaces
(self, print_result=True, hidden=False, **kwargs)
| 329 | self.data[ifname] = NetworkInterface(InterfaceProvider(), data) |
| 330 | |
| 331 | def show(self, print_result=True, hidden=False, **kwargs): |
| 332 | # type: (bool, bool, **Any) -> Optional[str] |
| 333 | """ |
| 334 | Print list of available network interfaces in human readable form |
| 335 | |
| 336 | :param print_result: print the results if True, else return it |
| 337 | :param hidden: if True, also displays invalid interfaces |
| 338 | """ |
| 339 | res = defaultdict(list) |
| 340 | for iface_name in sorted(self.data): |
| 341 | dev = self.data[iface_name] |
| 342 | if not hidden and not dev.is_valid(): |
| 343 | continue |
| 344 | prov = dev.provider |
| 345 | res[(prov.headers, prov.header_sort)].append( |
| 346 | (prov.name,) + prov._format(dev, **kwargs) |
| 347 | ) |
| 348 | output = "" |
| 349 | for key in res: |
| 350 | hdrs, sortBy = key |
| 351 | output += pretty_list( |
| 352 | res[key], |
| 353 | [("Source",) + hdrs], |
| 354 | sortBy=sortBy |
| 355 | ) + "\n" |
| 356 | output = output[:-1] |
| 357 | if print_result: |
| 358 | print(output) |
| 359 | return None |
| 360 | else: |
| 361 | return output |
| 362 | |
| 363 | def __repr__(self): |
| 364 | # type: () -> str |
no test coverage detected