wininfparser 1.0
module that can create, open, save, edit Windows INF files (Driver Files).
Public Member Functions | Static Public Attributes | List of all members
wininfparser.INFsection Class Reference

Can return values, keys, and section comments of INF files. More...

Public Member Functions

def __init__ (self, AutodetectSizes=False)
 Default constructor. More...
 
def GetSize (self)
 Returns section size. More...
 
def __iter__ (self)
 Lets go through the section content! More...
 
def SetKeyAutoSize (self, bool fKeyAlignment=True, int keyWhitespaces=None, int valueWhitespaces=None, int commentWhitespaces=None)
 automatic alignment of keys according to the maximum length and setting the indent after the key and before the value More...
 
def SetHeader (self, str h)
 Sets the header for the section. More...
 
def SetIndents (self, int keyWhitespaces=None, int valueWhitespaces=None, int commentWhitespaces=None)
 sets section indents: whitespaces after key, whitespaces before value and whitespaces before comment More...
 
def __next__ (self)
 Lets go through the section content! returns k - key returns v - value returns c - comment. More...
 
def Next (self)
 Returns next Section. More...
 
def SetNext (self, n)
 Sets next Section. More...
 
def SetPrevious (self, p)
 Sets previous Section. More...
 
def CheckSection (self)
 Checks if a section can be added to an inf file. More...
 
def Previous (self)
 Returns previous Section. More...
 
def SetType (self, t)
 Sets sction type must be INFsection.comment or INFsection.single_line or INFsection.key_pair. More...
 
def GetType (self)
 Returns Section type. More...
 
def SetIndent (self, int i)
 Sets indent after section. More...
 
def GetIndent (self)
 returns indent after section More...
 
def SetName (self, NewName)
 Sets section name. More...
 
def SetNameComment (self, NewNameComment)
 Sets comment to section name. More...
 
def GetName (self)
 returns section name More...
 
def SetValid (self)
 Sets section to valid state. More...
 
def IsValid (self)
 Checks if section valid. More...
 
def AddEmptyStrings (self)
 Function required for parser inserts empty laines. More...
 
def AddData (self, k, v=None, c=None, fraw=False)
 Adds k,v,c paramentrs to the end of the section. More...
 
def AddComment (self, c=None, fraw=False)
 Adds comment to the end of the section. More...
 
def AddDataP (self, int pos, k, v=None, c=None, fraw=False)
 Adds k,v,c parameters to the selected position of the section. More...
 
def RemoveKey (self, k)
 Removes first matched key of the section. More...
 
def RemoveValue (self, v)
 Removes first matched value of the section. More...
 
def RemoveComment (self, c)
 Removes first matched comment of the section. More...
 
def __getitem__ (self, k)
 Returns key with selected k name. More...
 
def __setitem__ (self, k, v)
 Sets key value pair. More...
 
def GetKeyIndex (self, k, p=0)
 Searches key where (k in key) from position p. More...
 
def GetExactKeyIndex (self, k, p=0)
 Looks for a key where k exactly matches the key from position p. More...
 
def SearchKeyIter (self, k, p=0)
 Searches key where (k in key) from position p this function used to iterate over section and search. More...
 
def SearchValueIter (self, v, p=0)
 Searches value where (v in value) from position p this function used to iterate over section and search. More...
 
def Find (self, str k, int p=0)
 Searches key where (k in key) from position p and return its value. More...
 
def FindKey (self, k, p=0)
 Searches key where (k in key) from position p. More...
 
def FindValueIndex (self, v, p=0)
 Searches value where (v in value) from position p. More...
 
def FindValue (self, v, p=0)
 Searches value where (v in value) from position p. More...
 
def GetValue (self, Index)
 Returns value with selected index. More...
 
def Info (self)
 Prints all section content. More...
 
def Save (self)
 Saves all section content to the string. More...
 

Static Public Attributes

int comment = 1
 
int single_line = 2
 
int key_pair = 3
 

Detailed Description

Can return values, keys, and section comments of INF files.

Allows you to navigate through the contents of a section. Able to add and remove values. Can search for keys and values within a section

variable description Value
comment typicali header section with
comments ony content
1
single_line section that contains only
values
2
key_pair section that contains key
value pairs
3

Constructor & Destructor Documentation

◆ __init__()

def wininfparser.INFsection.__init__ (   self,
  AutodetectSizes = False 
)

Default constructor.

Member Function Documentation

◆ __getitem__()

def wininfparser.INFsection.__getitem__ (   self,
  k 
)

Returns key with selected k name.

Parameters
k(str)
Returns
str

◆ __iter__()

def wininfparser.INFsection.__iter__ (   self)

Lets go through the section content!

Returns
INFsection

◆ __next__()

def wininfparser.INFsection.__next__ (   self)

Lets go through the section content! returns k - key returns v - value returns c - comment.

for k,v,c in VersionSection:
print("Key:{0:12}".format(k), " Value:", v, " Comment:", c)
Returns
str,str,str

◆ __setitem__()

def wininfparser.INFsection.__setitem__ (   self,
  k,
  v 
)

Sets key value pair.

Parameters
k(str)
v(str)

◆ AddComment()

def wininfparser.INFsection.AddComment (   self,
  c = None,
  fraw = False 
)

Adds comment to the end of the section.

Parameters
c(str)

◆ AddData()

def wininfparser.INFsection.AddData (   self,
  k,
  v = None,
  c = None,
  fraw = False 
)

Adds k,v,c paramentrs to the end of the section.

Parameters
kkey (str)
vvalue (str)
ccomment (str)

◆ AddDataP()

def wininfparser.INFsection.AddDataP (   self,
int  pos,
  k,
  v = None,
  c = None,
  fraw = False 
)

Adds k,v,c parameters to the selected position of the section.

Parameters
posposition (int)
kkey (str)
vvalue (str)
ccomment (str)

◆ AddEmptyStrings()

def wininfparser.INFsection.AddEmptyStrings (   self)

Function required for parser inserts empty laines.

◆ CheckSection()

def wininfparser.INFsection.CheckSection (   self)

Checks if a section can be added to an inf file.

Returns
bool

◆ Find()

def wininfparser.INFsection.Find (   self,
str  k,
int   p = 0 
)

Searches key where (k in key) from position p and return its value.

Parameters
k(str)
p(int)
Returns
str (returns a value for a partially or fully matched key)

◆ FindKey()

def wininfparser.INFsection.FindKey (   self,
  k,
  p = 0 
)

Searches key where (k in key) from position p.

Parameters
k(str)
p(int)
Returns
str (full key string)

◆ FindValue()

def wininfparser.INFsection.FindValue (   self,
  v,
  p = 0 
)

Searches value where (v in value) from position p.

Parameters
v(str)
p(int)
Returns
str (full value string)

◆ FindValueIndex()

def wininfparser.INFsection.FindValueIndex (   self,
  v,
  p = 0 
)

Searches value where (v in value) from position p.

Parameters
v(str)
p(int)
Returns
int

◆ GetExactKeyIndex()

def wininfparser.INFsection.GetExactKeyIndex (   self,
  k,
  p = 0 
)

Looks for a key where k exactly matches the key from position p.

Parameters
k(str)
p(int)
Returns
int

◆ GetIndent()

def wininfparser.INFsection.GetIndent (   self)

returns indent after section

Returns
int

◆ GetKeyIndex()

def wininfparser.INFsection.GetKeyIndex (   self,
  k,
  p = 0 
)

Searches key where (k in key) from position p.

Parameters
k(str)
p(int)
Returns
int

◆ GetName()

def wininfparser.INFsection.GetName (   self)

returns section name

Parameters
NewName(str)

◆ GetSize()

def wininfparser.INFsection.GetSize (   self)

Returns section size.

◆ GetType()

def wininfparser.INFsection.GetType (   self)

Returns Section type.

Returns
int (INFsection.comment or INFsection.single_line or INFsection.key_pair)

◆ GetValue()

def wininfparser.INFsection.GetValue (   self,
  Index 
)

Returns value with selected index.

Parameters
Index(int)
Returns
str

◆ Info()

def wininfparser.INFsection.Info (   self)

Prints all section content.

◆ IsValid()

def wininfparser.INFsection.IsValid (   self)

Checks if section valid.

Returns
bool

◆ Next()

def wininfparser.INFsection.Next (   self)

Returns next Section.

Returns
INFsection

◆ Previous()

def wininfparser.INFsection.Previous (   self)

Returns previous Section.

Returns
INFsection

◆ RemoveComment()

def wininfparser.INFsection.RemoveComment (   self,
  c 
)

Removes first matched comment of the section.

Parameters
ccomment (str)

◆ RemoveKey()

def wininfparser.INFsection.RemoveKey (   self,
  k 
)

Removes first matched key of the section.

Parameters
kkey (str)

◆ RemoveValue()

def wininfparser.INFsection.RemoveValue (   self,
  v 
)

Removes first matched value of the section.

Parameters
vvalue (str)

◆ Save()

def wininfparser.INFsection.Save (   self)

Saves all section content to the string.

Returns
str

◆ SearchKeyIter()

def wininfparser.INFsection.SearchKeyIter (   self,
  k,
  p = 0 
)

Searches key where (k in key) from position p this function used to iterate over section and search.

Parameters
k(str)
p(int)
Returns
k,v,c (key,value,comment)

◆ SearchValueIter()

def wininfparser.INFsection.SearchValueIter (   self,
  v,
  p = 0 
)

Searches value where (v in value) from position p this function used to iterate over section and search.

Parameters
v(str)
p(int)
Returns
str (key,value,comment)

◆ SetHeader()

def wininfparser.INFsection.SetHeader (   self,
str  h 
)

Sets the header for the section.

Parameters
h(str)

◆ SetIndent()

def wininfparser.INFsection.SetIndent (   self,
int  i 
)

Sets indent after section.

Parameters
i(int)

◆ SetIndents()

def wininfparser.INFsection.SetIndents (   self,
int   keyWhitespaces = None,
int   valueWhitespaces = None,
int   commentWhitespaces = None 
)

sets section indents: whitespaces after key, whitespaces before value and whitespaces before comment

Parameters
keyWhitespaces(int) number of whitespaces after key
valueWhitespaces(int) number of whitespaces before value
commentWhitespaces(int) number of whitespaces before comment

◆ SetKeyAutoSize()

def wininfparser.INFsection.SetKeyAutoSize (   self,
bool   fKeyAlignment = True,
int   keyWhitespaces = None,
int   valueWhitespaces = None,
int   commentWhitespaces = None 
)

automatic alignment of keys according to the maximum length and setting the indent after the key and before the value

Parameters
keyWhitespaces(int) number of whitespaces after key
valueWhitespaces(int) number of whitespaces before value
commentWhitespaces(int) number of whitespaces before comment
fKeyAlignment(bool)

◆ SetName()

def wininfparser.INFsection.SetName (   self,
  NewName 
)

Sets section name.

Parameters
NewName(str)

◆ SetNameComment()

def wininfparser.INFsection.SetNameComment (   self,
  NewNameComment 
)

Sets comment to section name.

Parameters
NewNameComment(str)

◆ SetNext()

def wininfparser.INFsection.SetNext (   self,
  n 
)

Sets next Section.

Parameters
n(INFsection) must be Invalid

◆ SetPrevious()

def wininfparser.INFsection.SetPrevious (   self,
  p 
)

Sets previous Section.

Parameters
p(INFsection) must be Invalid

◆ SetType()

def wininfparser.INFsection.SetType (   self,
  t 
)

◆ SetValid()

def wininfparser.INFsection.SetValid (   self)

Sets section to valid state.

Member Data Documentation

◆ comment

int wininfparser.INFsection.comment = 1
static

◆ key_pair

int wininfparser.INFsection.key_pair = 3
static

◆ single_line

int wininfparser.INFsection.single_line = 2
static

The documentation for this class was generated from the following file: