menu.py 文件源码

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

项目:ssha 作者: claranet 项目源码 文件源码
def choose_instance(instances, search):

    labels = [ec2.label(inst) for inst in instances]
    columns_width = _find_each_column_width(labels)

    items = []
    for i, inst in enumerate(instances):
        formatted_labels = [label.ljust(columns_width[j]) for j, label in enumerate(labels[i])]
        items.append(Item(label=' '.join(formatted_labels), value=inst))

    if search:
        search = search.lower()
        items = [item for item in items if search in item.label.lower()]
        if len(items) == 1:
            return items[0].value

    if not items:
        return None

    return curses.wrapper(_display, items)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号