def write(cfg_obj, output_file_path):
"""
Only supports writing out a conflagration object with namespaces that
follow the section.key=value pattern that ConfigFile.parse generates
"""
parser = SafeConfigParser()
for k in cfg_obj.__dict__.keys():
parser.add_section(k)
try:
for sub_k, sub_v in cfg_obj.__dict__[k].__dict__.items():
parser.set(k, sub_k, sub_v)
except Exception:
raise Exception(
"Output to config file not supported for conflagrations"
"nested beyond a one dot namespace.")
with open(output_file_path, 'w') as f:
parser.write(f)
评论列表
文章目录