We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Choice options are redundant using cookiecutter with latest click package
* Cookiecutter version: 1.6.0 -- installed via `pip install`
* Template project url: n/a
* Python version: 3.7
* Operating System: Windows 10

### Description:

If cookiecutter.json has the following:
```json
{
  "my_choice": ["a","b"]
}
```
Then running cookiecutter gives the following prompt:
```
Select my_choice:
1 - a
2 - b
Choose from 1, 2 (1, 2) [1]:
```

Note how the choices are repeated twice in the last line. This is because the [Click API](https://click.palletsprojects.com/en/7.x/api/) has been updated to 7.0 and automatically shows the choices to the user in parentheses. This is redundant. 

### Solution
The text passed to the `click.prompt` function should be changed to set `show_choices = False` or it should be changed to not show the choices and let the Click API do so instead.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 import os
5 import io
6 import sys
7 
8 from setuptools import setup
9 
10 version = "1.6.0"
11 
12 if sys.argv[-1] == 'publish':
13     os.system('python setup.py sdist upload')
14     os.system('python setup.py bdist_wheel upload')
15     sys.exit()
16 
17 if sys.argv[-1] == 'tag':
18     os.system("git tag -a %s -m 'version %s'" % (version, version))
19     os.system("git push --tags")
20     sys.exit()
21 
22 with io.open('README.rst', 'r', encoding='utf-8') as readme_file:
23     readme = readme_file.read()
24 
25 requirements = [
26     'future>=0.15.2',
27     'binaryornot>=0.2.0',
28     'jinja2>=2.7',
29     'click>=5.0',
30     'whichcraft>=0.4.0',
31     'poyo>=0.1.0',
32     'jinja2-time>=0.1.0',
33     'requests>=2.18.0',
34 ]
35 
36 if sys.argv[-1] == 'readme':
37     print(readme)
38     sys.exit()
39 
40 
41 setup(
42     name='cookiecutter',
43     version=version,
44     description=('A command-line utility that creates projects from project '
45                  'templates, e.g. creating a Python package project from a '
46                  'Python package project template.'),
47     long_description=readme,
48     author='Audrey Roy',
49     author_email='audreyr@gmail.com',
50     url='https://github.com/cookiecutter/cookiecutter',
51     packages=[
52         'cookiecutter',
53     ],
54     package_dir={'cookiecutter': 'cookiecutter'},
55     entry_points={
56         'console_scripts': [
57             'cookiecutter = cookiecutter.__main__:main',
58         ]
59     },
60     include_package_data=True,
61     python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
62     install_requires=requirements,
63     license='BSD',
64     zip_safe=False,
65     classifiers=[
66         'Development Status :: 5 - Production/Stable',
67         'Environment :: Console',
68         'Intended Audience :: Developers',
69         'Natural Language :: English',
70         'License :: OSI Approved :: BSD License',
71         'Programming Language :: Python',
72         'Programming Language :: Python :: 2',
73         'Programming Language :: Python :: 2.7',
74         'Programming Language :: Python :: 3',
75         'Programming Language :: Python :: 3.5',
76         'Programming Language :: Python :: 3.6',
77         'Programming Language :: Python :: 3.7',
78         'Programming Language :: Python :: Implementation :: CPython',
79         'Programming Language :: Python :: Implementation :: PyPy',
80         'Topic :: Software Development',
81     ],
82     keywords=(
83         'cookiecutter, Python, projects, project templates, Jinja2, '
84         'skeleton, scaffolding, project directory, setup.py, package, '
85         'packaging'
86     ),
87 )
88
```

Path: `cookiecutter/prompt.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 """
4 cookiecutter.prompt
5 ---------------------
6 
7 Functions for prompting the user for project info.
8 """
9 
10 from collections import OrderedDict
11 import json
12 
13 import click
14 from past.builtins import basestring
15 
16 from future.utils import iteritems
17 
18 from jinja2.exceptions import UndefinedError
19 
20 from .exceptions import UndefinedVariableInTemplate
21 from .environment import StrictEnvironment
22 
23 
24 def read_user_variable(var_name, default_value):
25     """Prompt the user for the given variable and return the entered value
26     or the given default.
27 
28     :param str var_name: Variable of the context to query the user
29     :param default_value: Value that will be returned if no input happens
30     """
31     # Please see http://click.pocoo.org/4/api/#click.prompt
32     return click.prompt(var_name, default=default_value)
33 
34 
35 def read_user_yes_no(question, default_value):
36     """Prompt the user to reply with 'yes' or 'no' (or equivalent values).
37 
38     Note:
39       Possible choices are 'true', '1', 'yes', 'y' or 'false', '0', 'no', 'n'
40 
41     :param str question: Question to the user
42     :param default_value: Value that will be returned if no input happens
43     """
44     # Please see http://click.pocoo.org/4/api/#click.prompt
45     return click.prompt(
46         question,
47         default=default_value,
48         type=click.BOOL
49     )
50 
51 
52 def read_repo_password(question):
53     """Prompt the user to enter a password
54 
55     :param str question: Question to the user
56     """
57     # Please see http://click.pocoo.org/4/api/#click.prompt
58     return click.prompt(question, hide_input=True)
59 
60 
61 def read_user_choice(var_name, options):
62     """Prompt the user to choose from several options for the given variable.
63 
64     The first item will be returned if no input happens.
65 
66     :param str var_name: Variable as specified in the context
67     :param list options: Sequence of options that are available to select from
68     :return: Exactly one item of ``options`` that has been chosen by the user
69     """
70     # Please see http://click.pocoo.org/4/api/#click.prompt
71     if not isinstance(options, list):
72         raise TypeError
73 
74     if not options:
75         raise ValueError
76 
77     choice_map = OrderedDict(
78         (u'{}'.format(i), value) for i, value in enumerate(options, 1)
79     )
80     choices = choice_map.keys()
81     default = u'1'
82 
83     choice_lines = [u'{} - {}'.format(*c) for c in choice_map.items()]
84     prompt = u'\n'.join((
85         u'Select {}:'.format(var_name),
86         u'\n'.join(choice_lines),
87         u'Choose from {}'.format(u', '.join(choices))
88     ))
89 
90     user_choice = click.prompt(
91         prompt, type=click.Choice(choices), default=default
92     )
93     return choice_map[user_choice]
94 
95 
96 def process_json(user_value):
97     try:
98         user_dict = json.loads(
99             user_value,
100             object_pairs_hook=OrderedDict,
101         )
102     except Exception:
103         # Leave it up to click to ask the user again
104         raise click.UsageError('Unable to decode to JSON.')
105 
106     if not isinstance(user_dict, dict):
107         # Leave it up to click to ask the user again
108         raise click.UsageError('Requires JSON dict.')
109 
110     return user_dict
111 
112 
113 def read_user_dict(var_name, default_value):
114     """Prompt the user to provide a dictionary of data.
115 
116     :param str var_name: Variable as specified in the context
117     :param default_value: Value that will be returned if no input is provided
118     :return: A Python dictionary to use in the context.
119     """
120     # Please see http://click.pocoo.org/4/api/#click.prompt
121     if not isinstance(default_value, dict):
122         raise TypeError
123 
124     default_display = 'default'
125 
126     user_value = click.prompt(
127         var_name,
128         default=default_display,
129         type=click.STRING,
130         value_proc=process_json,
131     )
132 
133     if user_value == default_display:
134         # Return the given default w/o any processing
135         return default_value
136     return user_value
137 
138 
139 def render_variable(env, raw, cookiecutter_dict):
140     """Inside the prompting taken from the cookiecutter.json file, this renders
141     the next variable. For example, if a project_name is "Peanut Butter
142     Cookie", the repo_name could be be rendered with:
143 
144         `{{ cookiecutter.project_name.replace(" ", "_") }}`.
145 
146     This is then presented to the user as the default.
147 
148     :param Environment env: A Jinja2 Environment object.
149     :param str raw: The next value to be prompted for by the user.
150     :param dict cookiecutter_dict: The current context as it's gradually
151         being populated with variables.
152     :return: The rendered value for the default variable.
153     """
154     if raw is None:
155         return None
156     elif isinstance(raw, dict):
157         return {
158             render_variable(env, k, cookiecutter_dict):
159                 render_variable(env, v, cookiecutter_dict)
160             for k, v in raw.items()
161         }
162     elif isinstance(raw, list):
163         return [
164             render_variable(env, v, cookiecutter_dict)
165             for v in raw
166         ]
167     elif not isinstance(raw, basestring):
168         raw = str(raw)
169 
170     template = env.from_string(raw)
171 
172     rendered_template = template.render(cookiecutter=cookiecutter_dict)
173     return rendered_template
174 
175 
176 def prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):
177     """Prompt the user which option to choose from the given. Each of the
178     possible choices is rendered beforehand.
179     """
180     rendered_options = [
181         render_variable(env, raw, cookiecutter_dict) for raw in options
182     ]
183 
184     if no_input:
185         return rendered_options[0]
186     return read_user_choice(key, rendered_options)
187 
188 
189 def prompt_for_config(context, no_input=False):
190     """
191     Prompts the user to enter new config, using context as a source for the
192     field names and sample values.
193 
194     :param no_input: Prompt the user at command line for manual configuration?
195     """
196     cookiecutter_dict = OrderedDict([])
197     env = StrictEnvironment(context=context)
198 
199     # First pass: Handle simple and raw variables, plus choices.
200     # These must be done first because the dictionaries keys and
201     # values might refer to them.
202     for key, raw in iteritems(context[u'cookiecutter']):
203         if key.startswith(u'_'):
204             cookiecutter_dict[key] = raw
205             continue
206 
207         try:
208             if isinstance(raw, list):
209                 # We are dealing with a choice variable
210                 val = prompt_choice_for_config(
211                     cookiecutter_dict, env, key, raw, no_input
212                 )
213                 cookiecutter_dict[key] = val
214             elif not isinstance(raw, dict):
215                 # We are dealing with a regular variable
216                 val = render_variable(env, raw, cookiecutter_dict)
217 
218                 if not no_input:
219                     val = read_user_variable(key, val)
220 
221                 cookiecutter_dict[key] = val
222         except UndefinedError as err:
223             msg = "Unable to render variable '{}'".format(key)
224             raise UndefinedVariableInTemplate(msg, err, context)
225 
226     # Second pass; handle the dictionaries.
227     for key, raw in iteritems(context[u'cookiecutter']):
228 
229         try:
230             if isinstance(raw, dict):
231                 # We are dealing with a dict variable
232                 val = render_variable(env, raw, cookiecutter_dict)
233 
234                 if not no_input:
235                     val = read_user_dict(key, val)
236 
237                 cookiecutter_dict[key] = val
238         except UndefinedError as err:
239             msg = "Unable to render variable '{}'".format(key)
240             raise UndefinedVariableInTemplate(msg, err, context)
241 
242     return cookiecutter_dict
243
```
--- 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/cookiecutter/prompt.py b/cookiecutter/prompt.py
--- a/cookiecutter/prompt.py
+++ b/cookiecutter/prompt.py
@@ -88,7 +88,7 @@
     ))
 
     user_choice = click.prompt(
-        prompt, type=click.Choice(choices), default=default
+        prompt, type=click.Choice(choices), default=default, show_choices=False
     )
     return choice_map[user_choice]
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -26,7 +26,7 @@
     'future>=0.15.2',
     'binaryornot>=0.2.0',
     'jinja2>=2.7',
-    'click>=5.0',
+    'click>=7.0',
     'whichcraft>=0.4.0',
     'poyo>=0.1.0',
     'jinja2-time>=0.1.0',

{"golden_diff": "diff --git a/cookiecutter/prompt.py b/cookiecutter/prompt.py\n--- a/cookiecutter/prompt.py\n+++ b/cookiecutter/prompt.py\n@@ -88,7 +88,7 @@\n     ))\n \n     user_choice = click.prompt(\n-        prompt, type=click.Choice(choices), default=default\n+        prompt, type=click.Choice(choices), default=default, show_choices=False\n     )\n     return choice_map[user_choice]\n \ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -26,7 +26,7 @@\n     'future>=0.15.2',\n     'binaryornot>=0.2.0',\n     'jinja2>=2.7',\n-    'click>=5.0',\n+    'click>=7.0',\n     'whichcraft>=0.4.0',\n     'poyo>=0.1.0',\n     'jinja2-time>=0.1.0',\n", "issue": "Choice options are redundant using cookiecutter with latest click package\n* Cookiecutter version: 1.6.0 -- installed via `pip install`\r\n* Template project url: n/a\r\n* Python version: 3.7\r\n* Operating System: Windows 10\r\n\r\n### Description:\r\n\r\nIf cookiecutter.json has the following:\r\n```json\r\n{\r\n  \"my_choice\": [\"a\",\"b\"]\r\n}\r\n```\r\nThen running cookiecutter gives the following prompt:\r\n```\r\nSelect my_choice:\r\n1 - a\r\n2 - b\r\nChoose from 1, 2 (1, 2) [1]:\r\n```\r\n\r\nNote how the choices are repeated twice in the last line. This is because the [Click API](https://click.palletsprojects.com/en/7.x/api/) has been updated to 7.0 and automatically shows the choices to the user in parentheses. This is redundant. \r\n\r\n### Solution\r\nThe text passed to the `click.prompt` function should be changed to set `show_choices = False` or it should be changed to not show the choices and let the Click API do so instead.\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport os\nimport io\nimport sys\n\nfrom setuptools import setup\n\nversion = \"1.6.0\"\n\nif sys.argv[-1] == 'publish':\n    os.system('python setup.py sdist upload')\n    os.system('python setup.py bdist_wheel upload')\n    sys.exit()\n\nif sys.argv[-1] == 'tag':\n    os.system(\"git tag -a %s -m 'version %s'\" % (version, version))\n    os.system(\"git push --tags\")\n    sys.exit()\n\nwith io.open('README.rst', 'r', encoding='utf-8') as readme_file:\n    readme = readme_file.read()\n\nrequirements = [\n    'future>=0.15.2',\n    'binaryornot>=0.2.0',\n    'jinja2>=2.7',\n    'click>=5.0',\n    'whichcraft>=0.4.0',\n    'poyo>=0.1.0',\n    'jinja2-time>=0.1.0',\n    'requests>=2.18.0',\n]\n\nif sys.argv[-1] == 'readme':\n    print(readme)\n    sys.exit()\n\n\nsetup(\n    name='cookiecutter',\n    version=version,\n    description=('A command-line utility that creates projects from project '\n                 'templates, e.g. creating a Python package project from a '\n                 'Python package project template.'),\n    long_description=readme,\n    author='Audrey Roy',\n    author_email='audreyr@gmail.com',\n    url='https://github.com/cookiecutter/cookiecutter',\n    packages=[\n        'cookiecutter',\n    ],\n    package_dir={'cookiecutter': 'cookiecutter'},\n    entry_points={\n        'console_scripts': [\n            'cookiecutter = cookiecutter.__main__:main',\n        ]\n    },\n    include_package_data=True,\n    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',\n    install_requires=requirements,\n    license='BSD',\n    zip_safe=False,\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Console',\n        'Intended Audience :: Developers',\n        'Natural Language :: English',\n        'License :: OSI Approved :: BSD License',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: Implementation :: CPython',\n        'Programming Language :: Python :: Implementation :: PyPy',\n        'Topic :: Software Development',\n    ],\n    keywords=(\n        'cookiecutter, Python, projects, project templates, Jinja2, '\n        'skeleton, scaffolding, project directory, setup.py, package, '\n        'packaging'\n    ),\n)\n", "path": "setup.py"}, {"content": "# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.prompt\n---------------------\n\nFunctions for prompting the user for project info.\n\"\"\"\n\nfrom collections import OrderedDict\nimport json\n\nimport click\nfrom past.builtins import basestring\n\nfrom future.utils import iteritems\n\nfrom jinja2.exceptions import UndefinedError\n\nfrom .exceptions import UndefinedVariableInTemplate\nfrom .environment import StrictEnvironment\n\n\ndef read_user_variable(var_name, default_value):\n    \"\"\"Prompt the user for the given variable and return the entered value\n    or the given default.\n\n    :param str var_name: Variable of the context to query the user\n    :param default_value: Value that will be returned if no input happens\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    return click.prompt(var_name, default=default_value)\n\n\ndef read_user_yes_no(question, default_value):\n    \"\"\"Prompt the user to reply with 'yes' or 'no' (or equivalent values).\n\n    Note:\n      Possible choices are 'true', '1', 'yes', 'y' or 'false', '0', 'no', 'n'\n\n    :param str question: Question to the user\n    :param default_value: Value that will be returned if no input happens\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    return click.prompt(\n        question,\n        default=default_value,\n        type=click.BOOL\n    )\n\n\ndef read_repo_password(question):\n    \"\"\"Prompt the user to enter a password\n\n    :param str question: Question to the user\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    return click.prompt(question, hide_input=True)\n\n\ndef read_user_choice(var_name, options):\n    \"\"\"Prompt the user to choose from several options for the given variable.\n\n    The first item will be returned if no input happens.\n\n    :param str var_name: Variable as specified in the context\n    :param list options: Sequence of options that are available to select from\n    :return: Exactly one item of ``options`` that has been chosen by the user\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    if not isinstance(options, list):\n        raise TypeError\n\n    if not options:\n        raise ValueError\n\n    choice_map = OrderedDict(\n        (u'{}'.format(i), value) for i, value in enumerate(options, 1)\n    )\n    choices = choice_map.keys()\n    default = u'1'\n\n    choice_lines = [u'{} - {}'.format(*c) for c in choice_map.items()]\n    prompt = u'\\n'.join((\n        u'Select {}:'.format(var_name),\n        u'\\n'.join(choice_lines),\n        u'Choose from {}'.format(u', '.join(choices))\n    ))\n\n    user_choice = click.prompt(\n        prompt, type=click.Choice(choices), default=default\n    )\n    return choice_map[user_choice]\n\n\ndef process_json(user_value):\n    try:\n        user_dict = json.loads(\n            user_value,\n            object_pairs_hook=OrderedDict,\n        )\n    except Exception:\n        # Leave it up to click to ask the user again\n        raise click.UsageError('Unable to decode to JSON.')\n\n    if not isinstance(user_dict, dict):\n        # Leave it up to click to ask the user again\n        raise click.UsageError('Requires JSON dict.')\n\n    return user_dict\n\n\ndef read_user_dict(var_name, default_value):\n    \"\"\"Prompt the user to provide a dictionary of data.\n\n    :param str var_name: Variable as specified in the context\n    :param default_value: Value that will be returned if no input is provided\n    :return: A Python dictionary to use in the context.\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    if not isinstance(default_value, dict):\n        raise TypeError\n\n    default_display = 'default'\n\n    user_value = click.prompt(\n        var_name,\n        default=default_display,\n        type=click.STRING,\n        value_proc=process_json,\n    )\n\n    if user_value == default_display:\n        # Return the given default w/o any processing\n        return default_value\n    return user_value\n\n\ndef render_variable(env, raw, cookiecutter_dict):\n    \"\"\"Inside the prompting taken from the cookiecutter.json file, this renders\n    the next variable. For example, if a project_name is \"Peanut Butter\n    Cookie\", the repo_name could be be rendered with:\n\n        `{{ cookiecutter.project_name.replace(\" \", \"_\") }}`.\n\n    This is then presented to the user as the default.\n\n    :param Environment env: A Jinja2 Environment object.\n    :param str raw: The next value to be prompted for by the user.\n    :param dict cookiecutter_dict: The current context as it's gradually\n        being populated with variables.\n    :return: The rendered value for the default variable.\n    \"\"\"\n    if raw is None:\n        return None\n    elif isinstance(raw, dict):\n        return {\n            render_variable(env, k, cookiecutter_dict):\n                render_variable(env, v, cookiecutter_dict)\n            for k, v in raw.items()\n        }\n    elif isinstance(raw, list):\n        return [\n            render_variable(env, v, cookiecutter_dict)\n            for v in raw\n        ]\n    elif not isinstance(raw, basestring):\n        raw = str(raw)\n\n    template = env.from_string(raw)\n\n    rendered_template = template.render(cookiecutter=cookiecutter_dict)\n    return rendered_template\n\n\ndef prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):\n    \"\"\"Prompt the user which option to choose from the given. Each of the\n    possible choices is rendered beforehand.\n    \"\"\"\n    rendered_options = [\n        render_variable(env, raw, cookiecutter_dict) for raw in options\n    ]\n\n    if no_input:\n        return rendered_options[0]\n    return read_user_choice(key, rendered_options)\n\n\ndef prompt_for_config(context, no_input=False):\n    \"\"\"\n    Prompts the user to enter new config, using context as a source for the\n    field names and sample values.\n\n    :param no_input: Prompt the user at command line for manual configuration?\n    \"\"\"\n    cookiecutter_dict = OrderedDict([])\n    env = StrictEnvironment(context=context)\n\n    # First pass: Handle simple and raw variables, plus choices.\n    # These must be done first because the dictionaries keys and\n    # values might refer to them.\n    for key, raw in iteritems(context[u'cookiecutter']):\n        if key.startswith(u'_'):\n            cookiecutter_dict[key] = raw\n            continue\n\n        try:\n            if isinstance(raw, list):\n                # We are dealing with a choice variable\n                val = prompt_choice_for_config(\n                    cookiecutter_dict, env, key, raw, no_input\n                )\n                cookiecutter_dict[key] = val\n            elif not isinstance(raw, dict):\n                # We are dealing with a regular variable\n                val = render_variable(env, raw, cookiecutter_dict)\n\n                if not no_input:\n                    val = read_user_variable(key, val)\n\n                cookiecutter_dict[key] = val\n        except UndefinedError as err:\n            msg = \"Unable to render variable '{}'\".format(key)\n            raise UndefinedVariableInTemplate(msg, err, context)\n\n    # Second pass; handle the dictionaries.\n    for key, raw in iteritems(context[u'cookiecutter']):\n\n        try:\n            if isinstance(raw, dict):\n                # We are dealing with a dict variable\n                val = render_variable(env, raw, cookiecutter_dict)\n\n                if not no_input:\n                    val = read_user_dict(key, val)\n\n                cookiecutter_dict[key] = val\n        except UndefinedError as err:\n            msg = \"Unable to render variable '{}'\".format(key)\n            raise UndefinedVariableInTemplate(msg, err, context)\n\n    return cookiecutter_dict\n", "path": "cookiecutter/prompt.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport os\nimport io\nimport sys\n\nfrom setuptools import setup\n\nversion = \"1.6.0\"\n\nif sys.argv[-1] == 'publish':\n    os.system('python setup.py sdist upload')\n    os.system('python setup.py bdist_wheel upload')\n    sys.exit()\n\nif sys.argv[-1] == 'tag':\n    os.system(\"git tag -a %s -m 'version %s'\" % (version, version))\n    os.system(\"git push --tags\")\n    sys.exit()\n\nwith io.open('README.rst', 'r', encoding='utf-8') as readme_file:\n    readme = readme_file.read()\n\nrequirements = [\n    'future>=0.15.2',\n    'binaryornot>=0.2.0',\n    'jinja2>=2.7',\n    'click>=7.0',\n    'whichcraft>=0.4.0',\n    'poyo>=0.1.0',\n    'jinja2-time>=0.1.0',\n    'requests>=2.18.0',\n]\n\nif sys.argv[-1] == 'readme':\n    print(readme)\n    sys.exit()\n\n\nsetup(\n    name='cookiecutter',\n    version=version,\n    description=('A command-line utility that creates projects from project '\n                 'templates, e.g. creating a Python package project from a '\n                 'Python package project template.'),\n    long_description=readme,\n    author='Audrey Roy',\n    author_email='audreyr@gmail.com',\n    url='https://github.com/cookiecutter/cookiecutter',\n    packages=[\n        'cookiecutter',\n    ],\n    package_dir={'cookiecutter': 'cookiecutter'},\n    entry_points={\n        'console_scripts': [\n            'cookiecutter = cookiecutter.__main__:main',\n        ]\n    },\n    include_package_data=True,\n    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',\n    install_requires=requirements,\n    license='BSD',\n    zip_safe=False,\n    classifiers=[\n        'Development Status :: 5 - Production/Stable',\n        'Environment :: Console',\n        'Intended Audience :: Developers',\n        'Natural Language :: English',\n        'License :: OSI Approved :: BSD License',\n        'Programming Language :: Python',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 2.7',\n        'Programming Language :: Python :: 3',\n        'Programming Language :: Python :: 3.5',\n        'Programming Language :: Python :: 3.6',\n        'Programming Language :: Python :: 3.7',\n        'Programming Language :: Python :: Implementation :: CPython',\n        'Programming Language :: Python :: Implementation :: PyPy',\n        'Topic :: Software Development',\n    ],\n    keywords=(\n        'cookiecutter, Python, projects, project templates, Jinja2, '\n        'skeleton, scaffolding, project directory, setup.py, package, '\n        'packaging'\n    ),\n)\n", "path": "setup.py"}, {"content": "# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.prompt\n---------------------\n\nFunctions for prompting the user for project info.\n\"\"\"\n\nfrom collections import OrderedDict\nimport json\n\nimport click\nfrom past.builtins import basestring\n\nfrom future.utils import iteritems\n\nfrom jinja2.exceptions import UndefinedError\n\nfrom .exceptions import UndefinedVariableInTemplate\nfrom .environment import StrictEnvironment\n\n\ndef read_user_variable(var_name, default_value):\n    \"\"\"Prompt the user for the given variable and return the entered value\n    or the given default.\n\n    :param str var_name: Variable of the context to query the user\n    :param default_value: Value that will be returned if no input happens\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    return click.prompt(var_name, default=default_value)\n\n\ndef read_user_yes_no(question, default_value):\n    \"\"\"Prompt the user to reply with 'yes' or 'no' (or equivalent values).\n\n    Note:\n      Possible choices are 'true', '1', 'yes', 'y' or 'false', '0', 'no', 'n'\n\n    :param str question: Question to the user\n    :param default_value: Value that will be returned if no input happens\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    return click.prompt(\n        question,\n        default=default_value,\n        type=click.BOOL\n    )\n\n\ndef read_repo_password(question):\n    \"\"\"Prompt the user to enter a password\n\n    :param str question: Question to the user\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    return click.prompt(question, hide_input=True)\n\n\ndef read_user_choice(var_name, options):\n    \"\"\"Prompt the user to choose from several options for the given variable.\n\n    The first item will be returned if no input happens.\n\n    :param str var_name: Variable as specified in the context\n    :param list options: Sequence of options that are available to select from\n    :return: Exactly one item of ``options`` that has been chosen by the user\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    if not isinstance(options, list):\n        raise TypeError\n\n    if not options:\n        raise ValueError\n\n    choice_map = OrderedDict(\n        (u'{}'.format(i), value) for i, value in enumerate(options, 1)\n    )\n    choices = choice_map.keys()\n    default = u'1'\n\n    choice_lines = [u'{} - {}'.format(*c) for c in choice_map.items()]\n    prompt = u'\\n'.join((\n        u'Select {}:'.format(var_name),\n        u'\\n'.join(choice_lines),\n        u'Choose from {}'.format(u', '.join(choices))\n    ))\n\n    user_choice = click.prompt(\n        prompt, type=click.Choice(choices), default=default, show_choices=False\n    )\n    return choice_map[user_choice]\n\n\ndef process_json(user_value):\n    try:\n        user_dict = json.loads(\n            user_value,\n            object_pairs_hook=OrderedDict,\n        )\n    except Exception:\n        # Leave it up to click to ask the user again\n        raise click.UsageError('Unable to decode to JSON.')\n\n    if not isinstance(user_dict, dict):\n        # Leave it up to click to ask the user again\n        raise click.UsageError('Requires JSON dict.')\n\n    return user_dict\n\n\ndef read_user_dict(var_name, default_value):\n    \"\"\"Prompt the user to provide a dictionary of data.\n\n    :param str var_name: Variable as specified in the context\n    :param default_value: Value that will be returned if no input is provided\n    :return: A Python dictionary to use in the context.\n    \"\"\"\n    # Please see http://click.pocoo.org/4/api/#click.prompt\n    if not isinstance(default_value, dict):\n        raise TypeError\n\n    default_display = 'default'\n\n    user_value = click.prompt(\n        var_name,\n        default=default_display,\n        type=click.STRING,\n        value_proc=process_json,\n    )\n\n    if user_value == default_display:\n        # Return the given default w/o any processing\n        return default_value\n    return user_value\n\n\ndef render_variable(env, raw, cookiecutter_dict):\n    \"\"\"Inside the prompting taken from the cookiecutter.json file, this renders\n    the next variable. For example, if a project_name is \"Peanut Butter\n    Cookie\", the repo_name could be be rendered with:\n\n        `{{ cookiecutter.project_name.replace(\" \", \"_\") }}`.\n\n    This is then presented to the user as the default.\n\n    :param Environment env: A Jinja2 Environment object.\n    :param str raw: The next value to be prompted for by the user.\n    :param dict cookiecutter_dict: The current context as it's gradually\n        being populated with variables.\n    :return: The rendered value for the default variable.\n    \"\"\"\n    if raw is None:\n        return None\n    elif isinstance(raw, dict):\n        return {\n            render_variable(env, k, cookiecutter_dict):\n                render_variable(env, v, cookiecutter_dict)\n            for k, v in raw.items()\n        }\n    elif isinstance(raw, list):\n        return [\n            render_variable(env, v, cookiecutter_dict)\n            for v in raw\n        ]\n    elif not isinstance(raw, basestring):\n        raw = str(raw)\n\n    template = env.from_string(raw)\n\n    rendered_template = template.render(cookiecutter=cookiecutter_dict)\n    return rendered_template\n\n\ndef prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):\n    \"\"\"Prompt the user which option to choose from the given. Each of the\n    possible choices is rendered beforehand.\n    \"\"\"\n    rendered_options = [\n        render_variable(env, raw, cookiecutter_dict) for raw in options\n    ]\n\n    if no_input:\n        return rendered_options[0]\n    return read_user_choice(key, rendered_options)\n\n\ndef prompt_for_config(context, no_input=False):\n    \"\"\"\n    Prompts the user to enter new config, using context as a source for the\n    field names and sample values.\n\n    :param no_input: Prompt the user at command line for manual configuration?\n    \"\"\"\n    cookiecutter_dict = OrderedDict([])\n    env = StrictEnvironment(context=context)\n\n    # First pass: Handle simple and raw variables, plus choices.\n    # These must be done first because the dictionaries keys and\n    # values might refer to them.\n    for key, raw in iteritems(context[u'cookiecutter']):\n        if key.startswith(u'_'):\n            cookiecutter_dict[key] = raw\n            continue\n\n        try:\n            if isinstance(raw, list):\n                # We are dealing with a choice variable\n                val = prompt_choice_for_config(\n                    cookiecutter_dict, env, key, raw, no_input\n                )\n                cookiecutter_dict[key] = val\n            elif not isinstance(raw, dict):\n                # We are dealing with a regular variable\n                val = render_variable(env, raw, cookiecutter_dict)\n\n                if not no_input:\n                    val = read_user_variable(key, val)\n\n                cookiecutter_dict[key] = val\n        except UndefinedError as err:\n            msg = \"Unable to render variable '{}'\".format(key)\n            raise UndefinedVariableInTemplate(msg, err, context)\n\n    # Second pass; handle the dictionaries.\n    for key, raw in iteritems(context[u'cookiecutter']):\n\n        try:\n            if isinstance(raw, dict):\n                # We are dealing with a dict variable\n                val = render_variable(env, raw, cookiecutter_dict)\n\n                if not no_input:\n                    val = read_user_dict(key, val)\n\n                cookiecutter_dict[key] = val\n        except UndefinedError as err:\n            msg = \"Unable to render variable '{}'\".format(key)\n            raise UndefinedVariableInTemplate(msg, err, context)\n\n    return cookiecutter_dict\n", "path": "cookiecutter/prompt.py"}]}