def get_usage_text(parser, indent=None):
    """
    This small helper function extracts the help information from an ArgumentParser instance
    and indents the text by the number of spaces supplied in the indent-argument.

    :param parser: ArgumentParser object.
    :param indent: Number of spaces to put before each line or None.
    :return: Formatted help string of the supplied parser.
    """
    usage_text = StringIO()
    parser.print_help(usage_text)

    usage_string = usage_text.getvalue()

    if indent is None:
        return usage_string

    return '\n'.join([' ' * indent + line for line in usage_string.split('\n')])
def get_usage_text ( parser , indent = None ) : usage_text = StringIO ( ) parser . print_help ( usage_text ) usage_string = usage_text . getvalue ( ) if indent is None : return usage_string return '\n' . join ( [ ' ' * indent + line for line in usage_string . split ( '\n' ) ] )
This small helper function extracts the help information from an ArgumentParser instance
    and indents the text by the number of spaces supplied in the indent-argument.

    :param parser: ArgumentParser object.
    :param indent: Number of spaces to put before each line or None.
    :return: Formatted help string of the supplied parser.