Keep functions, but move them into the if main section

This commit is contained in:
jkeating@localhost.localdomain 2006-10-10 21:19:16 -04:00 committed by Jesse Keating
parent c057593be6
commit 90de6d97a5

View File

@ -26,30 +26,40 @@ def create_yumobj(yumconf):
def main(): def main():
# This is used for testing the module # This is used for testing the module
usage = "usage: %s [options]" % sys.argv[0] (opts, args) = get_arguments()
parser = OptionParser(usage=usage)
parser.add_option("--destdir", default=".", dest="destdir",
help='destination directory (defaults to current directory)')
parser.add_option("--comps", default="comps.xml", dest="comps",
help='comps file to use')
parser.add_option("--yumconf", default="yum.conf", dest="yumconf",
help='yum config file to use')
(opts, args) = parser.parse_args()
try: try:
compsobj = yum.comps.Comps() compsobj = yum.comps.Comps()
compsobj.add(opts.comps) compsobj.add(opts.comps)
pkglist = [] print get_packagelist(compsobj)
for group in compsobj.groups:
pkglist += group.packages
print pkglist
except IOError: except IOError:
print >> sys.stderr, "gather.py: No such file:\'%s\'" % opts.comps print >> sys.stderr, "gather.py: No such file:\'%s\'" % opts.comps
sys.exit(1) sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':
main() def get_arguments():
# hack job for now, I'm sure this could be better for our uses
usage = "usage: %s [options]" % sys.argv[0]
parser = OptionParser(usage=usage)
parser.add_option("--destdir", default=".", dest="destdir",
help='destination directory (defaults to current directory)')
parser.add_option("--comps", default="comps.xml", dest="comps",
help='comps file to use')
parser.add_option("--yumconf", default="yum.conf", dest="yumconf",
help='yum config file to use')
(opts, args) = parser.parse_args()
#if len(opts) < 1:
# parser.print_help()
# sys.exit(0)
return (opts, args)
def get_packagelist(myComps):
# Get the list of packages from the comps file
pkglist = []
for group in myComps.groups:
pkglist += group.packages
return pkglist
main()