Fix read_user_dict for default values
@@ -84,12 +84,7 @@ def read_user_choice(var_name, options):
return choice_map[user_choice]
-def create_value_proc(default_display, default_value):
def process_json(user_value):
- if user_value == default_display:
- # Return the given default w/o any processing
- return default_value
-
try:
user_dict = json.loads(
user_value,
@@ -105,8 +100,6 @@ def create_value_proc(default_display, default_value):
return user_dict
- return process_json
-
def read_user_dict(var_name, default_value):
"""Prompt the user to provide a dictionary of data.
@@ -121,16 +114,18 @@ def read_user_dict(var_name, default_value):
default_display = 'default'
- return click.prompt(
+ user_value = click.prompt(
var_name,
default=default_display,
type=click.STRING,
- value_proc=create_value_proc(
- default_display,
- default_value,
- ),
+ value_proc=process_json,
)
+ if user_value == default_display:
+ # Return the given default w/o any processing
+ return default_value
+ return user_value
+
def render_variable(env, raw, cookiecutter_dict):
"""Inside the prompting taken from the cookiecutter.json file, this renders
