You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.8 KiB

#-*- codding:UTF-8 -*-
#!/usr/bin/env python
import os, sys, json
from utils import load_config
class PortageConfig():
def __init__(self):
self.Config = load_config()
self.TargetParse =['USE', 'USE_EXPAN', 'VIDEO_CARDS', 'ACCEPT_CHOSTS', 'ACCEPT_LICENSE','CCACHE_DIR', 'CCACHE_SIZE',
'EMERGE_DEFAULT_OPTS', 'CFLAGS', 'CXXFLAGS', 'MAKEOPTS']
self.MakeConfig={}
def getLines(self, filename):
with open (filename, 'r') as f:
lines = f.read().split("\n")
return lines
def parseMakeConf(self):
StateBox = 'Null'
Lines = self.getLines(self.Config['Portage']['make.conf'])
for line in Lines:
if not line.startswith('#'):
if StateBox == 'Null' and not line.endswith('"'):
StateBox = line.split('=')[0]
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'
for i in line.split('=')[1].split(" "):
MakeConfig[StateBox].append(i)
elif StateBox == 'Null' and line.endswith('"'):
MakeConfig[StateBox] = line.split(" ")
print(MakeConfig)
def parsePackageUse(self):
Lines = self.getlines(self.Config.Portage['package.use'])
def parsePackageMasks(self):
Lines = self.getlines(self.Config.Portage['package.mask'])
def parsePackageKeywords(self):
Lines = self.getlines(self.Config.Portage['package.keywords'])
if __name__ == '__main__':
test = PortageConfig()
test.parseMakeConf()