From b81e6c83bbeb87c6899e96f103de0c5543e2df93 Mon Sep 17 00:00:00 2001 From: Matt Domsch Date: Fri, 2 Nov 2007 13:33:14 -0500 Subject: [PATCH] inf2mondb: add --inflist to pass filename with list of ini files This avoids problems with shell expands in paths to ini files that include spaces and other odd characters. Files listed in inflist are parsed before the rest of the args on the command line. --- inf2mondb.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/inf2mondb.py b/inf2mondb.py index 343182d..6ad3370 100755 --- a/inf2mondb.py +++ b/inf2mondb.py @@ -95,18 +95,30 @@ def main(): "monitors database. " "The default is " + defaultDB + ".", metavar="FILE") + parser.add_option("-i", "--inflist", + dest="inflist", + default=None, + help="Read list of inf files from inflist", + metavar="FILE") (options, args) = parser.parse_args() - if len(args) < 1: - usage() - ini = ConfigParser.ConfigParser() ini.optionxform = __builtins__.str ini.OPTCRE = OPTCRE - f = myFile(args[0]) - ini.readfp(f) - f.close() + if options.inflist is not None: + f = open(options.inflist) + lines = f.readlines() + f.close + for a in lines: + f = myFile(a.strip()) + ini.readfp(f) + f.close + + for a in args: + f = myFile(a) + ini.readfp(f) + f.close() # First, build a dictionary of monitors we already know about. # When we get ready to print the monitors we found in the .inf -- 2.25.1