From: Matt Domsch Date: Fri, 2 Nov 2007 18:33:14 +0000 (-0500) Subject: inf2mondb: add --inflist to pass filename with list of ini files X-Git-Tag: hwdata-0.212-1~6^2~15 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b81e6c83bbeb87c6899e96f103de0c5543e2df93;p=oweals%2Fhwdata.git 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. --- 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