diff --git a/utils/parsePortage.py b/utils/parsePortage.py index a50edc6..4a59df8 100644 --- a/utils/parsePortage.py +++ b/utils/parsePortage.py @@ -1,43 +1,42 @@ #-*- codding:UTF-8 -*- #!/usr/bin/env python import os, sys, json -from utils import load_config -def parseMakeConf(): - Config = load_config() +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={} - TargetParse =['USE', 'USE_EXPAN', 'VIDEO_CARDS', 'ACCEPT_CHOSTS', 'ACCEPT_LICENSE','CCACHE_DIR', 'CCACHE_SIZE', - 'EMERGE_DEFAULT_OPTS', 'CFLAGS', 'CXXFLAGS', 'MAKEOPTS'] - - StateBox = 'Null' - MakeConfig={} - with open (Config.Portage['make.conf'], 'r') as f: - lines = f.read().split("\n") + def parseMakeConf(self): + StateBox = 'Null' + with open (Config.Portage['make.conf'], 'r') as f: + lines = f.read().split("\n") - for line in lines: - if not line.startswith('#'): - if StateBox is 'Null' and not line.endswith('"'): - StateBox = line.split('=')[0] - MakeConfig[StateBox] = line.split('=')] = [] - for i in line.split('=')] = line.split(" ") + for line in lines: + if not line.startswith('#'): + if StateBox is 'Null' and not line.endswith('"'): + StateBox = line.split('=')[0] + MakeConfig[StateBox] = line.split('=')] = [] + for i in line.split('=')] = line.split(" ") + MakeConfig[StateBox].append(i) + elif StateBox is not 'Null' and not line.endswith('"') + StateBox ='Null' + for i in line.split('=')] = line.split(" ") MakeConfig[StateBox].append(i) - elif StateBox is not 'Null' and not line.endswith('"') - StateBox ='Null' - for i in line.split('=')] = line.split(" ") - MakeConfig[StateBox].append(i) - elif StateBox is 'Null' and line.endswith('"'): - MakeConfig[StateBox] = line.split(" ") - - print(MakeConfig) + elif StateBox is 'Null' and line.endswith('"'): + MakeConfig[StateBox] = line.split(" ") + + print(MakeConfig) -def parsePackageUse(): - with open (Config.Portage['package.use'], 'r') as f: - lines = f.read().split("\n") -def parsePackageMask(): - with open (Config.Portage['package.mask'], 'r') as f: - lines = f.read().split("\n") -def def parsePackageKeywords(): - with open (Config.Portage['package.keywords'], 'r') as f: - lines = f.read().split("\n") + def parsePackageUse(self): + pass + def parsePackageMaskself(self): + pass + def def parsePackageKeywords(self): + pass if __name__ == '__main__': - parseMakeConfig() + test = TestConfig() + test.parseMakeConfig()