def searchnotes(docopt_args): query = docopt_args["<query_string>"] if docopt_args["--limit"]: limit = docopt_args["<items>"] insertvaluecache("search", str(limit), query) note = NoteOperations() notes = note.search(query, limit) else: note = NoteOperations() notes = note.search(query) if len(notes) > 0: for item in notes: noteid = item.get("_id", "") time = "[" + item.get("datecreated", "") + "]" noteids = "[" + str(noteid) + "]" body = item.get("body", "") title = item.get("title", "========NOT FOUND=======") print(Fore.YELLOW + "===============================================" + Fore.RESET) print(Back.BLUE + noteids + Back.RESET + " " + Back.BLUE + time + Back.RESET + "\n\n" + Back.RED + title + Back.RESET + Style.BRIGHT + "\n\n" + Fore.GREEN + body + Fore.RESET + Style.NORMAL) print(Fore.YELLOW + "===============================================" + Fore.RESET) else: puts(colored.red("Sorry,the query does not match any notes"))
def searchnotes(docopt_args): query = docopt_args["<query_string>"] if docopt_args["--limit"]: limit = docopt_args["<items>"] insertvaluecache("search", str(limit), query) note = NoteOperations() notes = note.search(query, limit) else: note = NoteOperations() notes = note.search(query) if len(notes) > 0: for item in notes: noteid = item.get("_id", "") time = "["+ item.get("datecreated", "") + "]" noteids = "["+ str(noteid) + "]" body = item.get("body", "") title = item.get("title", "========NOT FOUND=======") print(Fore.YELLOW + "===============================================" + Fore.RESET) print(Back.BLUE + noteids + Back.RESET +" " + Back.BLUE + time + Back.RESET +"\n\n" + Back.RED + title + Back.RESET + Style.BRIGHT +"\n\n"+ Fore.GREEN + body + Fore.RESET + Style.NORMAL) print(Fore.YELLOW + "===============================================" + Fore.RESET) else: puts(colored.red("Sorry,the query does not match any notes"))