Coder Social home page Coder Social logo

arutar / wininfparser Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 451 KB

Win inf parser. Windows INF files parser for python. Windows inf file parser. wininfparser

License: GNU General Public License v3.0

Python 100.00%
driver inf inf-parser inf-parser-python python windows

wininfparser's People

Contributors

arutar avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

wininfparser's Issues

Infinite loop parsing incorrect INF

Hello again, thanks for the last fix.

I stumbled upon another faulty INF that I managed to cut down to this:

#!/usr/bin/python3
import wininfparser
import tempfile

with tempfile.NamedTemporaryFile() as t:
    t.write(b"""[a]
b==c
""")
    t.flush()
    x = wininfparser.WinINF()
    x.ParseFile(t.name)

Please note that I'm not trying to find issues, I'm just parsing older INFs using your code.
I completely understand that handling all edge cases may not be your priority.

RemoveSection() also removes all sections above the target one

Using the example "Intel.inf", if you use RemoveSection('Manufacturer') all sections above it will also be removed.

Sample code:

from wininfparser import WinINF, INFsection
source_inf = r".\Intel.inf"
dest_inf = r".\Mod-Intel.inf"

InfFile = WinINF()
InfFile.ParseFile(source_inf)

s = InfFile["Manufacturer"]
if s is not None:
    InfFile.RemoveSection(s)
    InfFile.Save(dest_inf)

This results in a file that looks like:

[Intel.Mfg]
;830
;%i830M% = i830M, PCI\VEN_8086&DEV_3577
%i830M% = i830M, PCI\VEN_8086&DEV_3577&SUBSYS_00C81028
%i830M% = i830M, PCI\VEN_8086&DEV_3577&SUBSYS_01221028
%i830M% = i830M, PCI\VEN_8086&DEV_3577&SUBSYS_00B81028
%i830M% = i830M, PCI\VEN_8086&DEV_3577&SUBSYS_00B91028
%i830M% = i830M, PCI\VEN_8086&DEV_3577&SUBSYS_00F51028

;845
;%iBKDG% = i845G, PCI\VEN_8086&DEV_2562
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_013D1028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01471028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_03011028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_013A1028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01481028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01381028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01261028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01271028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01331028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_014B1028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01601028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01611028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01291028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_01461028
%iBKDG% = i845G, PCI\VEN_8086&DEV_2562&SUBSYS_03031028

;845GM
%iBKDGM% = i845GM, PCI\VEN_8086&DEV_2562&SUBSYS_01491028

Infinite loop parsing malformed inf

Try to parse an inf consisting of a line of multiple equals signs and you'll get stuck.

Example

#!/usr/bin/python3
import wininfparser
import tempfile

with tempfile.NamedTemporaryFile() as t:
    t.write(b"=============================================================================\n")
    t.flush()
    x = wininfparser.WinINF()
    x.ParseFile(t.name)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.