#-*- codding:UTF-8 -*- #!/usr/bin/env python import os, sys, json from utils import load_config def parseMakeConf(): Config = load_config() 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") for line in lines: if not line.startswith('#'): if StateBox is 'Null' and not line.endswith('"'): StateBox = line.split('=')[0] MakeConfig[StateBox] = line.split('=')] = [] elif StateBox is not 'Null' and not line.endswith('"') StateBox ='Null' else: pass else: pass print(MakeConfig) if __name__ == '__main__': parseMakeConfig()