示例#1
0
def load_config_for_embed_ipython(profile_name='debug'):
    """Load the a config file from the default ipython_dir.
    """
    ipython_dir = get_ipython_dir()
    profile_dir = os.path.join(ipython_dir, f'profile_{profile_name}')
    app = TerminalIPythonApp()
    app.config_file_paths.append(profile_dir)
    app.load_config_file()
    config = app.config
    # XXX: setting the profile in config seems to have no effect for InteractiveShellEmbed.
    # TODO: learn more about IPython internals...
    # fix history location with a little workaround
    if 'hist_file' not in config.HistoryAccessor:
        config.HistoryManager.hist_file = os.path.join(profile_dir, 'history.sqlite')
    return config