diff --git a/utils/parsePortage.py b/utils/parsePortage.py index 3729fdd..5ead1ed 100644 --- a/utils/parsePortage.py +++ b/utils/parsePortage.py @@ -9,8 +9,11 @@ class PortageConfig(): 'EMERGE_DEFAULT_OPTS', 'CFLAGS', 'CXXFLAGS', 'MAKEOPTS'] self.MakeConfig={} def getLines(self, filename): - with open (filename, 'r') as f: - lines = f.read().split("\n") + if os.path.exists(filename): + with open (filename, 'r') as f: + lines = f.read().split("\n") + else: + print("path is not Found") return lines def parseMakeConf(self): @@ -18,20 +21,24 @@ class PortageConfig(): Lines = self.getLines(self.Config['Portage']['make.conf']) 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('"'): - StateBox = line.split('=')[0] - MakeConfig[StateBox] = line.split('=')[1].split(" ") + StateBox = line.split('=')[0] + self.MakeConfig[StateBox] =[] + + self.MakeConfig[StateBox] = line.split('=')[1].split(" ") for i in line.split('=')[1].split(" "): - MakeConfig[StateBox].append(i) - elif StateBox != 'Null' and not line.endswith('"'): - StateBox ='Null' + self.MakeConfig[split('=')[0]].append(i) + elif StateBox !='Null' and not line.endswith('"'): + StateBox = line.split('=')[1] for i in line.split('=')[1].split(" "): - MakeConfig[StateBox].append(i) + self.MakeConfig[line.split('=')[0]].append(i) 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): Lines = self.getlines(self.Config.Portage['package.use'])