| 305 | return buf.getvalue() |
| 306 | |
| 307 | def list_packages(root_package): |
| 308 | packages = {} |
| 309 | failed_packages = [] |
| 310 | path, prefix = root_package.__path__, root_package.__name__ + "." |
| 311 | for importer, modname, ispkg in pkgutil.iter_modules(path, prefix): |
| 312 | if not ispkg: |
| 313 | continue |
| 314 | try: |
| 315 | package = __import__(modname, fromlist="dummy") |
| 316 | packages[package.__name__] = package |
| 317 | print('+ Imported {}'.format(modname)) |
| 318 | except Exception as e: |
| 319 | failed_packages.append(modname) |
| 320 | print('- Cannot import {}: {}'.format(modname, e)) |
| 321 | return packages, failed_packages |
| 322 | |
| 323 | def main(): |
| 324 | print('\nGenerating documentation for drivers ...') |