From 69afca2d3bbbfb32376d7c8926389b332af94fc7 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 10 Jul 2006 19:12:45 +0000 Subject: [PATCH] Move code out of global scope. svn path=/main/trunk/; revision=3832 --- bin/emaint | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/emaint b/bin/emaint index 4bf27e6ae..fc1548527 100755 --- a/bin/emaint +++ b/bin/emaint @@ -2,7 +2,6 @@ import sys sys.path.insert(0, "/usr/lib/portage/pym") -from copy import copy from optparse import OptionParser, OptionValueError import re @@ -104,16 +103,16 @@ class VdbKeyHandler(object): return errors -# this sucks, should track this in a different manner. -#modules = {"world" : WorldHandler, -# "vdbkeys": VdbKeyHandler} -modules = {"world" : WorldHandler} +def emaint_main(myargv): -module_names = modules.keys() -module_names.sort() -module_names.insert(0, "all") + # TODO: Create a system that allows external modules to be added without + # the need for hard coding. + modules = {"world" : WorldHandler} + + module_names = modules.keys() + module_names.sort() + module_names.insert(0, "all") -if __name__ == "__main__": def exclusive(option, *args, **kw): var = kw.get("var", None) if var is None: @@ -138,7 +137,7 @@ if __name__ == "__main__": parser.action = None - (options, args) = parser.parse_args() + (options, args) = parser.parse_args(args=myargv) if len(args) != 1: parser.error("Incorrect number of arguments") if args[0] not in module_names: @@ -174,3 +173,6 @@ if __name__ == "__main__": print "\n" print "Finished" + +if __name__ == "__main__": + emaint_main(sys.argv[1:]) -- 2.26.2