def fill_template(template_path, params):
    try:
        res = make_patterns(params)
        with open(template_path, 'r+') as template:
            raw = template.read()
        with open(template_path, 'w') as template:
            replaced = raw
            for pattern, new in res:
                replaced = pattern.sub(new, replaced)
            template.write(replaced)
    except (IOError, __HOLE__) as e:
        error_log("fill_template", "Could not fill template {0}: {1}".format(template_path, e))
dataset/ETHPy150Open binder-project/binder/binder/utils.py/fill_template