def parse_eb(file_path):
# type: (object) -> object file_name) -> dict:
""" interpret easyconfig file with 'exec'. Interperting fails if
undefined constants are within the Easyconfig file.
Add undefined constants to <header>.
"""
header = 'SOURCE_TGZ = "%(name)s-%(version)s.tgz"\n'
header += 'SOURCE_TAR_GZ = "%(name)s-%(version)s.tar.gz"\n'
code = header
eb = imp.new_module("easyconfig")
with open(file_path, "r") as f:
code += f.read()
try:
exec (code, eb.__dict__)
except Exception, e:
print("interperting easyconfig error: %s" % e)
eb = {}
return eb
评论列表
文章目录