INNER CODE UNIT · Python
modules_in_pkg
Yelp/paasta · paasta_tools/cli/cli.py:46
def modules_in_pkg(pkg):
"""Return the list of modules in a python package (a module with a
__init__.py file.)
:return: a list of strings such as `['list', 'check']` that correspond to
the module names in the package.
"""
for _, module_name, _ in pkgutil.walk_packages(pkg.__path__):
yield module_name
class PrintsHelpOnErrorArgumentParser(argparse.ArgumentParser):
"""Overriding the error method allows us to print the whole help page,
otherwise the python arg parser prints a not-so-useful usage message that
is way too terse"""
def error(self, message):
print(f"Argument parse error: {message}\n")