def _searchNote(self, note): note = tools.strip(note) # load search result result = self.getStorage().getSearch() if result and tools.checkIsInt(note) and 1 <= int(note) <= len(result.notes): note = result.notes[int(note) - 1] else: request = self._createSearchRequest(search=note) logging.debug("Search notes: %s" % request) result = self.getEvernote().findNotes(request, 20) logging.debug("Search notes result: %s" % str(result)) if result.totalNotes == 0: out.failureMessage("Notes have not been found.") return tools.exitErr() elif result.totalNotes == 1 or self.selectFirstOnUpdate: note = result.notes[0] else: logging.debug("Choose notes: %s" % str(result.notes)) note = out.SelectSearchResult(result.notes) logging.debug("Selected note: %s" % str(note)) return note
def _searchNote(self, note): note = tools.strip(note) # load search result result = self.getStorage().getNote(note) if result: note = result else: result = self.getStorage().getSearch() if result and tools.checkIsInt(note) and 1 <= int(note) <= len( result.notes): note = result.notes[int(note) - 1] else: request = self._createSearchRequest(search=note) logging.debug("Search notes: %s" % request) result = self.getEvernote().findNotes(request, 20) logging.debug("Search notes result: %s" % str(result)) if result.totalNotes == 0: out.failureMessage("Notes have not been found.") return tools.exitErr() elif result.totalNotes == 1 or self.selectFirstOnUpdate: note = result.notes[0] else: logging.debug("Choose notes: %s" % str(result.notes)) note = out.SelectSearchResult(result.notes) logging.debug("Selected note: %s" % str(note)) note = self.getEvernote().getNote(note.guid) return note
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(12, " ") 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): tools.exit()
def printList( listItems, title="", showSelector=False, showByStep=0, showUrl=False, showTags=False, showNotebook=False, showGUID=False, ): if title: separator("=", title) total = len(listItems) printLine("Found %d item%s" % (total, ("s" if total != 1 else ""))) for key, item in enumerate(listItems): key += 1 printLine("%s : %s%s%s%s%s%s" % ( item.guid if showGUID and hasattr(item, "guid") else str(key).rjust(3, " "), printDate(item.created).ljust(11, " ") if hasattr(item, "created") else "", printDate(item.updated).ljust(11, " ") if hasattr(item, "updated") else "", item.notebookName.ljust(18, " ") if showNotebook and hasattr(item, "notebookName") else "", item.title if hasattr(item, "title") else item.name if hasattr(item, "name") else item.shareName, "".join(map(lambda s: " #" + s, item.tagGuids)) if showTags and hasattr(item, "tagGuids") and item.tagGuids else "", " " + (">>> " + config.NOTE_WEBCLIENT_URL % item.guid) if showUrl else "", )) if showByStep != 0 and 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" or num == "q": 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
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
def printList(listItems, title="", showSelector=False, showByStep=0, showUrl=False, showTags=False, showNotebook=False, showGUID=False): if title: separator("=", title) total = len(listItems) printLine("Found %d item%s" % (total, ('s' if total != 1 else ''))) for key, item in enumerate(listItems): key += 1 printLine("%s : %s%s%s%s%s%s" % ( item.guid if showGUID and hasattr(item, 'guid') else str(key).rjust(3, " "), printDate(item.created).ljust(11, " ") if hasattr(item, 'created') else '', printDate(item.updated).ljust(11, " ") if hasattr(item, 'updated') else '', item.notebookName.ljust(18, " ") if showNotebook and hasattr(item, 'notebookName') else '', item.title if hasattr(item, 'title') else item.name, "".join(map(lambda s: " #" + s, item.tagGuids)) if showTags and hasattr(item, 'tagGuids') and item.tagGuids else '', " " + (">>> " + config.NOTE_WEBCLIENT_URL % item.guid) if showUrl else '',)) if showByStep != 0 and 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' or num == 'q': 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