def importnotes(docopt_args): filename = docopt_args["<filename>"] + ".csv" if os.path.isfile(filename): with open(filename, 'rb') as f: reader = csv.reader(f) for row in reader: title = row[0] body = row[1] time = row[2] note = NoteOperations() note.save(title=title, body=body) with indent(4, quote=' >'): puts(colored.green("Import successful")) note.synctocloud() else: with indent(4, quote=' >'): puts(colored.red("Sorry,the file does not exist"))
def createnewnote(docopt_args): notebody = "" if docopt_args["<note_title>"] and docopt_args["-m"]: with indent(4, quote=' >'): # puts( # colored.yellow('Type the body of the notes.Press "/pq" to save & exit')) print(Back.YELLOW + Fore.RED + 'Type the body of the notes' + Back.RESET + Fore.RESET + Style.BRIGHT + ' (Press ' + Back.YELLOW + Fore.RED + "/pq" + Back.RESET + Fore.RESET + ' to save & exit)' + Style.NORMAL + Fore.GREEN) sentinel = '/pq' # ends when this string is seen for line in iter(raw_input, sentinel): notebody += line + "\n" print(Fore.RESET) notetitle = docopt_args["<note_title>"] note = NoteOperations() note.save(title=notetitle, body=notebody) with indent(4, quote='√ '): puts(colored.green("Successfully saved")) note.synctocloud()
def deletenote(docopt_args): noteid = docopt_args["<note_id>"] note = NoteOperations() if docopt_args["-a"]: puts("Are you sure you want to delete all notes? [" + colored.red("y") + "][" + colored.green("n") + "]") answer = raw_input(">") if answer == "y": status = note.delete(noteid, "all") else: return else: puts("Are you sure you want to delete note " + str(note.getnotetitle(noteid)) + "? [" + colored.red("y") + "][" + colored.green("n") + "]") answer = raw_input(">") if answer == "y": notetitle = note.getnotetitle(noteid) status = note.delete(noteid, "one") else: return if status > 0: with indent(4, quote=' √'): if docopt_args["-a"]: puts(colored.red("Successfully deleted all notes")) note = NoteOperations() note.deletenotesfromcloud() else: puts( colored.red("Successfully deleted note ") + colored.yellow(notetitle)) note = NoteOperations() note.synctocloud() else: with indent(4, quote=' √'): puts( colored.red("Sorry,the note with id ") + colored.green(noteid) + colored.red(" does not exist"))
def deletenote(docopt_args): noteid = docopt_args["<note_id>"] note = NoteOperations() if docopt_args["-a"]: puts( "Are you sure you want to delete all notes? [" + colored.red("y") + "][" + colored.green("n") + "]") answer = raw_input(">") if answer == "y": status = note.delete(noteid, "all") else: return else: puts("Are you sure you want to delete note " + str(note.getnotetitle(noteid) ) + "? [" + colored.red("y") + "][" + colored.green("n") + "]") answer = raw_input(">") if answer == "y": notetitle = note.getnotetitle(noteid) status = note.delete(noteid, "one") else: return if status > 0: with indent(4, quote=' √'): if docopt_args["-a"]: puts(colored.red("Successfully deleted all notes")) note = NoteOperations() note.deletenotesfromcloud() else: puts(colored.red("Successfully deleted note ") + colored.yellow(notetitle)) note = NoteOperations() note.synctocloud() else: with indent(4, quote=' √'): puts(colored.red("Sorry,the note with id ") + colored.green(noteid) + colored.red(" does not exist"))
def synctocloud(docopt_args): note = NoteOperations() note.synctocloud()