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
评论列表
文章目录