Example #1
0
def listnotes(docopt_args):
    if docopt_args["--limit"]:
        limit = docopt_args["<items>"]
        insertvaluecache("list", str(limit), "")
        # Scrible().hasnext = "list" + str(limit)
        # print "next" + Scrible().hasnext
        note = NoteOperations()
        allnotes = note.viewall(limit)
    else:
        note = NoteOperations()
        allnotes = note.viewall()
    if len(allnotes) > 0:
        for item in allnotes:
            with indent(4, quote=' >'):
                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:
        with indent(4):
            puts(colored.yellow("Sorry, no notes present"))
Example #2
0
def listnotes(docopt_args):
    if docopt_args["--limit"]:
        limit = docopt_args["<items>"]
        insertvaluecache("list", str(limit), "")
        # Scrible().hasnext = "list" + str(limit)
        # print "next" + Scrible().hasnext
        note = NoteOperations()
        allnotes = note.viewall(limit)
    else:
        note = NoteOperations()
        allnotes = note.viewall()
    if len(allnotes) > 0:
        for item in allnotes:
            with indent(4, quote=' >'):
                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:
        with indent(4):
            puts(colored.yellow("Sorry, no notes present"))
Example #3
0
def export(docopt_args):
    filename = docopt_args["<filename>"]
    finalfilepath = filename + ".csv"
    note = NoteOperations()
    allnotes = note.viewall()
    if len(allnotes) > 0:
        noteslist = []
        for item in allnotes:
            title = item.get("title", "")
            body = item.get("body", "")
            timedate = item.get("datecreated", "")
            templist = [title, body, timedate]
            noteslist.append(templist)
        with open(finalfilepath, 'wb') as fp:
            a = csv.writer(fp, delimiter=',')
            a.writerows(noteslist)
            puts(colored.green(
                "Notes exported successfully to " + os.getcwd() + "/" + finalfilepath))
    else:
        with indent(4):
            puts(colored.yellow("Sorry, no notes present"))
Example #4
0
def export(docopt_args):
    filename = docopt_args["<filename>"]
    finalfilepath = filename + ".csv"
    note = NoteOperations()
    allnotes = note.viewall()
    if len(allnotes) > 0:
        noteslist = []
        for item in allnotes:
            title = item.get("title", "")
            body = item.get("body", "")
            timedate = item.get("datecreated", "")
            templist = [title, body, timedate]
            noteslist.append(templist)
        with open(finalfilepath, 'wb') as fp:
            a = csv.writer(fp, delimiter=',')
            a.writerows(noteslist)
            puts(
                colored.green("Notes exported successfully to " + os.getcwd() +
                              "/" + finalfilepath))
    else:
        with indent(4):
            puts(colored.yellow("Sorry, no notes present"))