fix env make.conf #3

master
serkus01 2 years ago
parent 62dfdd2ad3
commit c8489057b3

@ -9,8 +9,11 @@ class PortageConfig():
'EMERGE_DEFAULT_OPTS', 'CFLAGS', 'CXXFLAGS', 'MAKEOPTS'] 'EMERGE_DEFAULT_OPTS', 'CFLAGS', 'CXXFLAGS', 'MAKEOPTS']
self.MakeConfig={} self.MakeConfig={}
def getLines(self, filename): def getLines(self, filename):
with open (filename, 'r') as f: if os.path.exists(filename):
lines = f.read().split("\n") with open (filename, 'r') as f:
lines = f.read().split("\n")
else:
print("path is not Found")
return lines return lines
def parseMakeConf(self): def parseMakeConf(self):
@ -18,20 +21,24 @@ class PortageConfig():
Lines = self.getLines(self.Config['Portage']['make.conf']) Lines = self.getLines(self.Config['Portage']['make.conf'])
for line in Lines: for line in Lines:
if not line.startswith('#'): if not line.startswith('#') and len(line.split("="))>1:
line.replace('"', "")
if StateBox == 'Null' and not line.endswith('"'): if StateBox == 'Null' and not line.endswith('"'):
StateBox = line.split('=')[0] StateBox = line.split('=')[0]
MakeConfig[StateBox] = line.split('=')[1].split(" ") self.MakeConfig[StateBox] =[]
self.MakeConfig[StateBox] = line.split('=')[1].split(" ")
for i in line.split('=')[1].split(" "): for i in line.split('=')[1].split(" "):
MakeConfig[StateBox].append(i) self.MakeConfig[split('=')[0]].append(i)
elif StateBox != 'Null' and not line.endswith('"'): elif StateBox !='Null' and not line.endswith('"'):
StateBox ='Null' StateBox = line.split('=')[1]
for i in line.split('=')[1].split(" "): for i in line.split('=')[1].split(" "):
MakeConfig[StateBox].append(i) self.MakeConfig[line.split('=')[0]].append(i)
elif StateBox == 'Null' and line.endswith('"'): elif StateBox == 'Null' and line.endswith('"'):
MakeConfig[StateBox] = line.split(" ") #line.replace('"', "")
self.MakeConfig[line.split('=')[0]] = line.split('="')[1].split(" ")
print(MakeConfig) print(self.MakeConfig)
def parsePackageUse(self): def parsePackageUse(self):
Lines = self.getlines(self.Config.Portage['package.use']) Lines = self.getlines(self.Config.Portage['package.use'])

Loading…
Cancel
Save