config.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:Auspex 作者: BBN-Q 项目源码 文件源码
def load_meas_file(filename=None):
    global LogDir, KernelDir, AWGDir, meas_file

    if filename:
        meas_file = filename
    else:
        meas_file = find_meas_file()

    with open(meas_file, 'r') as fid:
        Loader.add_constructor('!include', Loader.include)
        load = Loader(fid)
        code = load.get_single_data()
        load.dispose()

    # Get the config values out of the measure_file.
    if not 'config' in code.keys():
        raise KeyError("Could not find config section of the yaml file.")

    if 'AWGDir' in code['config'].keys():
        AWGDir = os.path.abspath(code['config']['AWGDir'])
    else:
        raise KeyError("Could not find AWGDir in the YAML config section")

    if 'KernelDir' in code['config'].keys():
        KernelDir = os.path.abspath(code['config']['KernelDir'])
    else:
        raise KeyError("Could not find KernelDir in the YAML config section")

    if 'LogDir' in code['config'].keys():
        LogDir = os.path.abspath(code['config']['LogDir'])
    else:
        raise KeyError("Could not find LogDir in the YAML config section")

    # Create directories if necessary
    for d in [KernelDir, LogDir]:
        if not os.path.isdir(d):
            os.mkdir(d)

    return code
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号