10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-14 18:13:57 +01:00
quantum_package/scripts/compilation/read_compilation_cfg.py

40 lines
808 B
Python
Raw Normal View History

2015-05-26 16:08:52 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import ConfigParser
import sys
from cache import cache
qpackage_root = os.environ['QPACKAGE_ROOT']
Config = ConfigParser.ConfigParser()
pwd = os.path.join(qpackage_root, "scripts/compilation/compilation.cfg")
Config.read(pwd)
@cache
def get_l_option_section():
return [o for o in ['OPENMP', 'PROFILE', 'DEBUG'] if Config.getboolean("OPTION", o)]
@cache
def get_compilation_option(name):
l_option_section = get_l_option_section()
l = []
for section in ["COMMON"] + l_option_section:
try:
l.extend(Config.get(section, name).split())
except ConfigParser.NoOptionError:
pass
return " ".join(l)
if __name__ == '__main__':
name = sys.argv[1]
print get_compilation_option(name)