help.py 1.0 KB

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