We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
kinto init fails if config folder does not exist
```
kinto init 
Which backend to use? (1 - postgresql, 2 - redis, default - memory) 
Traceback (most recent call last):
  File "/var/www/kinto.leplat.re/venv/bin/kinto", line 9, in <module>
    load_entry_point('kinto==1.9.0', 'console_scripts', 'kinto')()
  File "/var/www/kinto.leplat.re/venv/local/lib/python2.7/site-packages/kinto/__main__.py", line 44, in main
    init(config_file)
  File "/var/www/kinto.leplat.re/venv/local/lib/python2.7/site-packages/kinto/config/__init__.py", line 61, in init
    permission_url=values['permission_url'])
  File "/var/www/kinto.leplat.re/venv/local/lib/python2.7/site-packages/kinto/config/__init__.py", line 15, in render_template
    with codecs.open(destination, 'w+', encoding='utf-8') as output:
  File "/var/www/kinto.leplat.re/venv/lib/python2.7/codecs.py", line 881, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: 'config/kinto.ini'
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kinto/config/__init__.py`
Content:
```
1 import os
2 import binascii
3 import codecs
4 
5 HERE = os.path.abspath(os.path.dirname(__file__))
6 
7 
8 def render_template(template, destination, **kwargs):
9     template = os.path.join(HERE, template)
10 
11     with codecs.open(template, 'r', encoding='utf-8') as f:
12         raw_template = f.read()
13         rendered = raw_template.format(**kwargs)
14         with codecs.open(destination, 'w+', encoding='utf-8') as output:
15             output.write(rendered)
16 
17 
18 def init(config_file, backend):
19     values = {}
20     values['secret'] = binascii.b2a_hex(os.urandom(32))
21 
22     values['storage_backend'] = "cliquet.storage.%s" % backend
23     values['cache_backend'] = "cliquet.cache.%s" % backend
24     values['permission_backend'] = "cliquet.permission.%s" % backend
25 
26     if backend == 'postgresql':
27         postgresql_url = "postgres://postgres:postgres@localhost/postgres"
28         values['storage_url'] = postgresql_url
29         values['cache_url'] = postgresql_url
30         values['permission_url'] = postgresql_url
31 
32     elif backend == 'redis':
33         redis_url = "redis://localhost:6379"
34         values['storage_url'] = redis_url + "/1"
35         values['cache_url'] = redis_url + "/2"
36         values['permission_url'] = redis_url + "/3"
37 
38     else:
39         values['storage_url'] = ''
40         values['cache_url'] = ''
41         values['permission_url'] = ''
42 
43     render_template("kinto.tpl", config_file, **values)
44
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kinto/config/__init__.py b/kinto/config/__init__.py
--- a/kinto/config/__init__.py
+++ b/kinto/config/__init__.py
@@ -8,6 +8,9 @@
 def render_template(template, destination, **kwargs):
     template = os.path.join(HERE, template)
 
+    folder = os.path.dirname(destination)
+    os.makedirs(folder)
+
     with codecs.open(template, 'r', encoding='utf-8') as f:
         raw_template = f.read()
         rendered = raw_template.format(**kwargs)

{"golden_diff": "diff --git a/kinto/config/__init__.py b/kinto/config/__init__.py\n--- a/kinto/config/__init__.py\n+++ b/kinto/config/__init__.py\n@@ -8,6 +8,9 @@\n def render_template(template, destination, **kwargs):\n     template = os.path.join(HERE, template)\n \n+    folder = os.path.dirname(destination)\n+    os.makedirs(folder)\n+\n     with codecs.open(template, 'r', encoding='utf-8') as f:\n         raw_template = f.read()\n         rendered = raw_template.format(**kwargs)\n", "issue": "kinto init fails if config folder does not exist\n```\nkinto init \nWhich backend to use? (1 - postgresql, 2 - redis, default - memory) \nTraceback (most recent call last):\n  File \"/var/www/kinto.leplat.re/venv/bin/kinto\", line 9, in <module>\n    load_entry_point('kinto==1.9.0', 'console_scripts', 'kinto')()\n  File \"/var/www/kinto.leplat.re/venv/local/lib/python2.7/site-packages/kinto/__main__.py\", line 44, in main\n    init(config_file)\n  File \"/var/www/kinto.leplat.re/venv/local/lib/python2.7/site-packages/kinto/config/__init__.py\", line 61, in init\n    permission_url=values['permission_url'])\n  File \"/var/www/kinto.leplat.re/venv/local/lib/python2.7/site-packages/kinto/config/__init__.py\", line 15, in render_template\n    with codecs.open(destination, 'w+', encoding='utf-8') as output:\n  File \"/var/www/kinto.leplat.re/venv/lib/python2.7/codecs.py\", line 881, in open\n    file = __builtin__.open(filename, mode, buffering)\nIOError: [Errno 2] No such file or directory: 'config/kinto.ini'\n```\n\n", "before_files": [{"content": "import os\nimport binascii\nimport codecs\n\nHERE = os.path.abspath(os.path.dirname(__file__))\n\n\ndef render_template(template, destination, **kwargs):\n    template = os.path.join(HERE, template)\n\n    with codecs.open(template, 'r', encoding='utf-8') as f:\n        raw_template = f.read()\n        rendered = raw_template.format(**kwargs)\n        with codecs.open(destination, 'w+', encoding='utf-8') as output:\n            output.write(rendered)\n\n\ndef init(config_file, backend):\n    values = {}\n    values['secret'] = binascii.b2a_hex(os.urandom(32))\n\n    values['storage_backend'] = \"cliquet.storage.%s\" % backend\n    values['cache_backend'] = \"cliquet.cache.%s\" % backend\n    values['permission_backend'] = \"cliquet.permission.%s\" % backend\n\n    if backend == 'postgresql':\n        postgresql_url = \"postgres://postgres:postgres@localhost/postgres\"\n        values['storage_url'] = postgresql_url\n        values['cache_url'] = postgresql_url\n        values['permission_url'] = postgresql_url\n\n    elif backend == 'redis':\n        redis_url = \"redis://localhost:6379\"\n        values['storage_url'] = redis_url + \"/1\"\n        values['cache_url'] = redis_url + \"/2\"\n        values['permission_url'] = redis_url + \"/3\"\n\n    else:\n        values['storage_url'] = ''\n        values['cache_url'] = ''\n        values['permission_url'] = ''\n\n    render_template(\"kinto.tpl\", config_file, **values)\n", "path": "kinto/config/__init__.py"}], "after_files": [{"content": "import os\nimport binascii\nimport codecs\n\nHERE = os.path.abspath(os.path.dirname(__file__))\n\n\ndef render_template(template, destination, **kwargs):\n    template = os.path.join(HERE, template)\n\n    folder = os.path.dirname(destination)\n    os.makedirs(folder)\n\n    with codecs.open(template, 'r', encoding='utf-8') as f:\n        raw_template = f.read()\n        rendered = raw_template.format(**kwargs)\n        with codecs.open(destination, 'w+', encoding='utf-8') as output:\n            output.write(rendered)\n\n\ndef init(config_file, backend):\n    values = {}\n    values['secret'] = binascii.b2a_hex(os.urandom(32))\n\n    values['storage_backend'] = \"cliquet.storage.%s\" % backend\n    values['cache_backend'] = \"cliquet.cache.%s\" % backend\n    values['permission_backend'] = \"cliquet.permission.%s\" % backend\n\n    if backend == 'postgresql':\n        postgresql_url = \"postgres://postgres:postgres@localhost/postgres\"\n        values['storage_url'] = postgresql_url\n        values['cache_url'] = postgresql_url\n        values['permission_url'] = postgresql_url\n\n    elif backend == 'redis':\n        redis_url = \"redis://localhost:6379\"\n        values['storage_url'] = redis_url + \"/1\"\n        values['cache_url'] = redis_url + \"/2\"\n        values['permission_url'] = redis_url + \"/3\"\n\n    else:\n        values['storage_url'] = ''\n        values['cache_url'] = ''\n        values['permission_url'] = ''\n\n    render_template(\"kinto.tpl\", config_file, **values)\n", "path": "kinto/config/__init__.py"}]}