def print_help(self): result = [self.format_option_help()] if self.epilog is not None: result.append(self.format_epilog(None)) fail("\n".join(result))
def error(self, error): fail(error)
return self.epilog def print_help(self): result = [self.format_option_help()] if self.epilog is not None: result.append(self.format_epilog(None)) fail("\n".join(result)) if __name__ == "__main__": import sys opt_parser = FailingOptionParser(epilog= """This is the epilog. """) opt_parser.add_option("--foo", help="foo", action="store", type="string", dest="foo") (options, remaining_args) = opt_parser.parse_args(sys.argv) if len(remaining_args) > 1: fail("Found extra arguments: %s" % remaining_args)
# Drop the last "\n", or the header if no options or option groups: return "".join(result[:-1]) # Format the epilog verbatim def format_epilog(self, formatter): return self.epilog def print_help(self): result = [self.format_option_help()] if self.epilog is not None: result.append(self.format_epilog(None)) fail("\n".join(result)) if __name__ == "__main__": import sys opt_parser = FailingOptionParser(epilog="""This is the epilog. """) opt_parser.add_option("--foo", help="foo", action="store", type="string", dest="foo") (options, remaining_args) = opt_parser.parse_args(sys.argv) if len(remaining_args) > 1: fail("Found extra arguments: %s" % remaining_args)