init.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:temci 作者: parttimenerd 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号