def update_conf(conf, d):
    """
    Updates conf.py based on the values in dict `d`.
    """
    orig = open(conf).read()
    add = 'globals().update(%s)\n' % str(d)
    imports = d.pop('imports', None)
    with open(conf, 'w') as fout:
        if imports is not None:
            if not isinstance(imports, list):
                imports = [imports]
            for imp in imports:
                fout.write(imp + '\n')
        fout.write(orig)
        fout.write(add)
