def prompt_attributes_dict(default_description: str = None) -> t.Dict[str, str]:
"""
Prompts for the contents of the attributes dict.
:param default_description: default value for the description attribute
:return: attributes dict
"""
attributes = {}
descr_msg = "Give a description for the current block: "
if default_description is not None:
attributes["description"] = default_prompt(descr_msg, default_description,
completer=WordCompleter([default_description]))
else:
attributes["description"] = prompt(descr_msg, validator=NonEmptyValidator())
try:
while prompt_yesno("Do you want to set or add another attribute? ", default=False):
name = prompt("Attribute name: ", validator=NonEmptyValidator(),
completer=WordCompleter(sorted(list(attributes.keys())), meta_dict=attributes))
default = attributes[name] if name in attributes else ""
attributes[name] = prompt("Attribute value: ", default=default, validator=NonEmptyValidator())
except KeyboardInterrupt:
pass
return attributes
评论列表
文章目录