1import pkgutil 2import sys 3import fontTools 4import importlib 5import os 6from pathlib import Path 7 8 9def main(): 10 """Show this help""" 11 path = fontTools.__path__ 12 descriptions = {} 13 for pkg in sorted( 14 mod.name 15 for mod in pkgutil.walk_packages([fontTools.__path__[0]], prefix="fontTools.") 16 ): 17 try: 18 imports = __import__(pkg, globals(), locals(), ["main"]) 19 except ImportError as e: 20 continue 21 try: 22 description = imports.main.__doc__ 23 if description: 24 pkg = pkg.replace("fontTools.", "").replace(".__main__", "") 25 # show the docstring's first line only 26 descriptions[pkg] = description.splitlines()[0] 27 except AttributeError as e: 28 pass 29 for pkg, description in descriptions.items(): 30 print("fonttools %-25s %s" % (pkg, description), file=sys.stderr) 31 32 33if __name__ == "__main__": 34 print("fonttools v%s\n" % fontTools.__version__, file=sys.stderr) 35 main() 36