out.py 文件源码

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

项目:txt2evernote 作者: Xunius 项目源码 文件源码
def printList(listItems, title="", showSelector=False,
              showByStep=20, showUrl=False):

    if title:
        separator("=", title)

    total = len(listItems)
    printLine("Total found: %d" % total)
    for key, item in enumerate(listItems):
        key += 1

        printLine("%s : %s%s%s" % (
            str(key).rjust(3, " "),
            printDate(item.created).ljust(18, " ") if hasattr(item, 'created') else '',
            item.title if hasattr(item, 'title') else item.name,
            " " + (">>> " + config.NOTE_URL % item.guid) if showUrl else '',))

        if key % showByStep == 0 and key < total:
            printLine("-- More --", "\r")
            tools.getch()
            printLine(" " * 12, "\r")

    if showSelector:
        printLine("  0 : -Cancel-")
        try:
            while True:
                num = rawInput(": ")
                if tools.checkIsInt(num) and 1 <= int(num) <= total:
                    return listItems[int(num) - 1]
                if num == '0':
                    exit(1)
                failureMessage('Incorrect number "%s", '
                               'please try again:\n' % num)
        except (KeyboardInterrupt, SystemExit), e:
            if e.message:
                tools.exit(e.message)
            else:
                tools.exit
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号