hvordan man analyserer windows inf-filer til python?

Indlæg af Hanne Mølgaard Plasc

Problem



Vær venlig at hjælpe mig.
Eksempel inf-fil:


;=============================================================================
;
; Copyright (c) Intel Corporation (2002).
;
; INTEL MAKES NO WARRANTY OF ANY KIND REGARDING THE CODE.  THIS CODE IS
; LICENSED ON AN "AS IS" BASIS AND INTEL WILL NOT PROVIDE ANY SUPPORT,
; ASSISTANCE, INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL DOES NOT
; PROVIDE ANY UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY
; DISCLAIMS ANY WARRANTY OF MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR ANY
; PARTICULAR PURPOSE, OR ANY OTHER WARRANTY.  Intel disclaims all liability,
; including liability for infringement of any proprietary rights, relating to
; use of the code. No license, express or implied, by estoppel or otherwise,
; to any intellectual property rights is granted herein.
;
;=============================================================================

; Installation inf for the Intel Corporation graphics adapter.

[Version]
Signature="$WINDOWS NT$"
Provider=\%Intel\%
ClassGUID={4D36E968-E325-11CE-BFC1-08002BE10318}
Class=Display
CatalogFile=i830mnt5.cat

DriverVer=08/20/2004,6.14.10.3889

[DestinationDirs]
DefaultDestDir   = 11
ialm.Miniport  = 12  ; drivers
ialm.Display   = 11  ; system32
Help.Copy = 11
CUI.Copy = 11
Uninstall\_Copy = 11

OpenGL.Copy    = 11  ; OpenGL Drivers in System32

;
; Driver information
;

[Manufacturer]
\%Intel\%   = Intel.Mfg

[Intel.Mfg]
;830
;\%i830M\% = i830M, PCIVEN\_8086&DEV\_3577
\%i830M\% = i830M, PCIVEN\_8086&DEV\_3577&SUBSYS\_00C81028
\%i830M\% = i830M, PCIVEN\_8086&DEV\_3577&SUBSYS\_01221028
\%i830M\% = i830M, PCIVEN\_8086&DEV\_3577&SUBSYS\_00B81028
\%i830M\% = i830M, PCIVEN\_8086&DEV\_3577&SUBSYS\_00B91028
\%i830M\% = i830M, PCIVEN\_8086&DEV\_3577&SUBSYS\_00F51028

;845
;\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_013D1028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01471028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_03011028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_013A1028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01481028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01381028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01261028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01271028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01331028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_014B1028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01601028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01611028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01291028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_01461028
\%iBKDG\% = i845G, PCIVEN\_8086&DEV\_2562&SUBSYS\_03031028

;845GM
\%iBKDGM\% = i845GM, PCIVEN\_8086&DEV\_2562&SUBSYS\_01491028


hvordan man analyserer og formateret '\% iBKDGM\%=i845GM, PCI \ VEN\_8086 &DEV\_2562 &SUBSYS\_01491028' denne linje?

Bedste reference


Du kan prøve den indbyggede ConfigParser


http://docs.python.org/library/configparser.html[2]


Samt ConfigObj


http://code.google.com/p/configobj/[3]


Begge hævder at kunne håndtere Windows INI-filer.