MCPcopy
hub / github.com/cookiecutter/cookiecutter / read_user_dict

Function read_user_dict

cookiecutter/prompt.py:174–193  ·  view source on GitHub ↗

Prompt the user to provide a dictionary of data. :param var_name: Variable as specified in the context :param default_value: Value that will be returned if no input is provided :return: A Python dictionary to use in the context.

(var_name: str, default_value, prompts=None, prefix: str = "")

Source from the content-addressed store, hash-verified

172
173
174def read_user_dict(var_name: str, default_value, prompts=None, prefix: str = ""):
175 """Prompt the user to provide a dictionary of data.
176
177 :param var_name: Variable as specified in the context
178 :param default_value: Value that will be returned if no input is provided
179 :return: A Python dictionary to use in the context.
180 """
181 if not isinstance(default_value, dict):
182 raise TypeError
183
184 question = (
185 prompts[var_name]
186 if prompts and var_name in prompts and prompts[var_name]
187 else var_name
188 )
189 return JsonPrompt.ask(
190 f"{prefix}{question} [cyan bold]({DEFAULT_DISPLAY})[/]",
191 default=default_value,
192 show_default=False,
193 )
194
195
196_Raw: TypeAlias = bool | dict["_Raw", "_Raw"] | list["_Raw"] | str | None

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…