Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
arutar authored Nov 9, 2023
1 parent 8bc2c56 commit 1fe7bdb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions wininfparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def CheckSection(self):
## Returns previous Section
# @return INFsection
def Previous(self):
self.__PreviousSection
return self.__PreviousSection

## Sets sction type must be INFsection.comment or INFsection.single_line or INFsection.key_pair
def SetType(self,t):
Expand Down Expand Up @@ -390,15 +390,16 @@ def AddData(self,k,v=None,c=None,fraw=False):
if k: k=k.rstrip()
self.__KeyList.append(k)

if v is not None :
if len(self.__KeyList) == 1 or len(self.__ValueList):
v = v.lstrip()
if self.__EmptyCount:
self.__ValueList=['' for i in range(self.__EmptyCount)]
self.__EmptyCount=0
self.__ValueList.append(v)
else:
print("There was an error trying to write a key and value to a section that contains only keys!")
if v is not None:
v = v.lstrip()
if self.__EmptyCount:
self.__ValueList=['' for i in range(self.__EmptyCount)]
self.__EmptyCount=0
if len(self.__KeyList) - 1 != len(self.__ValueList):
print("Warning the section [{}]: will be converted to key value type!".format(self.__Name))
self.__ValueList = ['' for i in range(len(self.__KeyList) - 1 - len(self.__ValueList))]
self.__ValueList.append(v)

elif len(self.__ValueList) and v is None:
self.__ValueList.append('')

Expand Down Expand Up @@ -832,6 +833,7 @@ def RemoveSection(self, Section: INFsection):
if p is not None:
if n is not None:
p.SetNext(n)
n.SetPrevious(p)
else:
p.SetNext(None)
self.__Tail=p
Expand Down

0 comments on commit 1fe7bdb

Please sign in to comment.