From e2075bf00244f0829b31b68bd078e0e60bb17a60 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Fri, 17 Jul 2009 18:30:24 +0000 Subject: [PATCH] Only load/parse options when run as the main script. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61443 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/doxygen/scripts/doxymlparser.py | 41 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/docs/doxygen/scripts/doxymlparser.py b/docs/doxygen/scripts/doxymlparser.py index 06c66870c7..5ae698c802 100755 --- a/docs/doxygen/scripts/doxymlparser.py +++ b/docs/doxygen/scripts/doxymlparser.py @@ -27,23 +27,6 @@ import types from common import * from xml.dom import minidom -option_dict = { - "report" : (False, "Print out the classes and methods found by this script."), - "verbose" : (False, "Provide status updates and other information."), - } - -parser = optparse.OptionParser(usage="usage: %prog [options] \n" + __description__, version="%prog 1.0") - -for opt in option_dict: - default = option_dict[opt][0] - - action = "store" - if type(default) == types.BooleanType: - action = "store_true" - parser.add_option("--" + opt, default=default, action=action, dest=opt, help=option_dict[opt][1]) - -options, arguments = parser.parse_args() - class ClassDefinition: def __init__(self): self.name = "" @@ -113,8 +96,9 @@ def doxyMLToText(node): return text class DoxyMLParser: - def __init__(self): + def __init__(self, verbose = False): self.classes = [] + self.verbose = verbose def find_class(self, name): for aclass in self.classes: @@ -204,7 +188,7 @@ class DoxyMLParser: param[child.nodeName] = getTextValue(child) new_method.params.append(param) - if options.verbose: + if self.verbose: print "Adding %s" % (new_method.name + new_method.argsstring) if new_method.name == new_class.name: @@ -215,11 +199,28 @@ class DoxyMLParser: new_class.methods.append(new_method) if __name__ == "__main__": + option_dict = { + "report" : (False, "Print out the classes and methods found by this script."), + "verbose" : (False, "Provide status updates and other information."), + } + + parser = optparse.OptionParser(usage="usage: %prog [options] \n" + __description__, version="%prog 1.0") + + for opt in option_dict: + default = option_dict[opt][0] + + action = "store" + if type(default) == types.BooleanType: + action = "store_true" + parser.add_option("--" + opt, default=default, action=action, dest=opt, help=option_dict[opt][1]) + + options, arguments = parser.parse_args() + if len(arguments) < 1: parser.print_usage() sys.exit(1) - doxyparse = DoxyMLParser() + doxyparse = DoxyMLParser(verbose = options.verbose) for arg in arguments: doxyparse.parse(arg) -- 2.45.2