#!/usr/bin/python # # inf2mondb.py: convert MicroSoft .inf files for monitors to MonitorDB # # originally by Matt Wilson # option parsing and database comparison by Fred New # ini parsing completely rewritten by Matt Domsch 2006 # # Copyright 2002 Red Hat, Inc. # Copyright 2006 Dell, Inc. # # This software may be freely redistributed under the terms of the GNU # library public license. # # You should have received a copy of the GNU Library Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ """ import sys import string import re import ConfigParser # this is a class to deal with various file line endings and leading whitespace # converts all \r line endings to \n. # It also strips leading whitespace. # NOTE: be sure to always return _something_, even if it is just "\n", or we # break the file API. (nothing == eof) class myFile(object): def __init__(self, *args): self.fd = open(*args) def close(self): return self.fd.close() def readline(self, *args): line = self.fd.readline(*args) line = line.replace('\r', '\n') line = line.replace('\n\n', '\n') line = line.lstrip(" \t") return line # we will use this to override default option parsing in ConfigParser to handle # Microsoft-style "INI" files. (Which do not necessarily have " = value " after # the option name OPTCRE = re.compile( r'(?P