Ejemplo n.º 1
0
def run_event_loop():

    journal_name = input('Enter journal name:\n')
    if not journal_name:
        journal_name = 'default'

    journal_data = journal.load(journal_name)

    cmd = 'Empty!'
    print('Enter journal command:\n')
    while cmd != 'x' and cmd:
        cmd = input(
            '[L]ist entries, [A]dd an entry, [S]ave journal, E[x]it: \n'
        )
        cmd = cmd.lower().strip()

        if cmd == 'l' or cmd == 'list':
            list_entries(journal_data)
        elif cmd == 'a' or cmd == 'add':
            add_entry(journal_data)
        elif cmd == 's' or cmd == 'save':
            journal_name = input(
                "Please enter journal name: \n"
            )
            journal.save(journal_name, journal_data)
            cmd = 'x'
        elif cmd != 'x' and cmd:
            print('Sorry, the input {} is not valid\n'.format(cmd))

    print('Done. Exiting...')
Ejemplo n.º 2
0
def run_event_loop(file):
    action = 'Empty'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while action != 'x':
        action = input('What do you want to do? [L]ist, [A]dd, or E[x]it? ')
        action = action.lower().strip()

        if action == 'l':
            list_entries(journal_data)

        elif action == 'a':
            entry = input('Enter your journal entry: ')
            journal_data = journal.add_entry(entry, journal_data)

        elif action == 'x':
            journal.save(journal_name, journal_data)

        else:
            print()
            print('Invalid input...')
            print()

    print('Exiting loop.')
Ejemplo n.º 3
0
def run_event_loop():
    """
    Event loop which asks user for journal name and loads from directory
    Then user can add to or list journal contents
    Saves back to loaded journal on exit
    """

    journal_name = input("Which journal do you want to work on?")
    if not journal_name:
        journal_name = 'default'
    
    journal_data = journal.load(journal_name)

    print("What do you want to do in your journal?")
    cmd = None
    while cmd != 'x':
        cmd = input("[A]dd an entry, [L]ist all entries or E[x]it? ")
        cmd = cmd.lower().strip()
        if cmd == 'a':
            text = input("Type your input here: ")
            journal.add_entry(journal_data, text)

        elif cmd == 'l':
            journal.list_entries(journal_data)

        elif cmd != 'x':
            print("Unable to process command '{}'".format(cmd))

    journal.save(journal_name, journal_data)
    print("Done, goodbye!")
Ejemplo n.º 4
0
def run_event_loop():
    print 'What do you want to do with your Journal? '

    cmd = 'Empty'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = raw_input('[L]ist Entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.lower().strip()

        if cmd == 'l':
            list_entries(journal_data)

        elif cmd == 'a':
            add_entry(journal_data)

        # # my code

        # elif cmd=='d':
        # 	del_entry(journal_data)

        # # end

        elif cmd != 'x' and cmd:
            print "Sorry, I don't understand'{}'".format(cmd)

    print 'Done. Goodbye'
    journal.save(journal_name, journal_data)
Ejemplo n.º 5
0
def runEventLoop():
    """
    runEventLoop function is where the user interacts with the journal by viewing
        previous entries, adding an entry, or exiting the journal. Once the user
        chooses to exit the program, the entries are saved as a file called
        'journal.jrl' found wherever the program is stored and it reads as a text
        file.
    """
    journal_name = 'journal'
    journal_data = journal.load(journal_name)  # []  # list()

    print('What would you like to do with your journal?')
    cmd = 'EMPTY'

    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.lower().strip()

        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x' and cmd:
            print("Sorry, '{}' is not an understood command.".format(cmd))

    journal.save(journal_name, journal_data)
    print('Goodbye!')
Ejemplo n.º 6
0
def event_loop():  # this is the function that starts the UI
    print('What would you like to do?')  # user prompt
    cmd = 'init'  # the cmd variable is used to capture user data
    journal_name = 'default'  # name the journal default
    journal_data = journal.load(
        journal_name
    )  # a variable that contains the output of journal.load(journal_name)

    while cmd != 'x' and cmd:  # while cmd is not x and cmd has something in it
        cmd = input(
            'Press L to [L]ist entries, A to [A]dd entry, and X to e[x]it: '
        )  # prompt for entry
        cmd = cmd.lower().strip()  # strip the whitespace on right

        if cmd == 'l':
            list_entries(
                journal_data)  # call list_entries, pass journal_data (list)
        elif cmd == 'a':
            add_entries(
                journal_data)  # call add_entries, pass journal_data (list)
        elif cmd != 'x' and cmd:
            print('"{}" Not valid, try again'.format(cmd))

    print('Saving... Goodbye!')
    journal.save(
        journal_name, journal_data
    )  # on exit call journal.save w/ the name of the journal and list
Ejemplo n.º 7
0
def run_event_loop():
    """
    Main loop of the journal app, saves the journal at the end.
    """
    print("What do you want to do with your journal?")
    cmd = None
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    exit_cmds = ['x', 'exit', '']
    list_cmds = ['l', 'list']
    add_cmds = ['a', 'add']

    while cmd not in exit_cmds:
        cmd = input('[L]ist entries, [A]dd entry, E[x]it: ').lower().strip()

        if cmd in list_cmds:
            # print('Listing...')
            list_entries(journal_data)
        elif cmd in add_cmds:
            # print('Adding...')
            add_entry(journal_data)

        elif cmd not in exit_cmds:
            print("Sorry, I don't understand '{}'.".format(cmd))

    journal.save(journal_name, journal_data)
    print('Done, goodbye')
Ejemplo n.º 8
0
def run_event_loop():

    cmd = None
    journal_name = "Default"
    journal_data = journal.load(journal_name)

    while cmd != 'x':
        print("\nWhat do you want to do with your journal? ")
        cmd = input(
            "[R]eload, [S]ave, [L]ist entries, [A]dd an entry, E[x]it: ")
        cmd = cmd.lower().strip()

        if cmd == "r":
            journal_data = journal.load(journal_name)

        elif cmd == "l":
            list_entries(journal_data)

        elif cmd == "a":
            add_entry(journal_data)

        elif cmd == "s":
            journal.save(journal_name, journal_data)

        elif cmd == "x":
            print("Goodbye")
            journal.save(journal_name, journal_data)
            break

        else:
            print("I don't understand {}".format(cmd))
Ejemplo n.º 9
0
def run_event_loop():
    print("What do you want to do with your journal")

    #===================================================//
    # this part declares a list and add data to it     //
    #=================================================//

    journal_name = "defualt"
    journal_data = journal.load(journal_name)

    #=================================================//
    # this part performs check for the menu entry    //
    #===============================================//
    cmd = "Empty"

    while cmd != 'x' and cmd:
        cmd = input("L[l]ist entries, A[a]dd an entry, E[x]xit: ")
        cmd = cmd.lower().strip()

        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entries(journal_data)
        elif cmd == "x":
            print("E")
        elif cmd != 'x' and cmd:
            print("Sorry we don\'t understand '{}'".format(cmd))
    print("Done, goodbye")
    journal.save(journal_name, journal_data)
Ejemplo n.º 10
0
def run_event_loop():

    print('What would you like to do with your journal?')
    print('')
    print('Commands: [L]ist, [A]dd, [E]dit, [D]elete, <return> to exit')
    print('')
    cmd = 'EMPTY'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = input('List, Add, Edit, Delete, <return> to exit: ')
        cmd = cmd.lower().strip()

        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd == 'e':
            edit_entry(journal_data)
        elif cmd == 'd':
            del_entry(journal_data)
        elif cmd != 'x' and cmd:
            print("Sorry, we don't understand the command: {}".format(cmd))

    print('Done, goodbye...')
    journal.save(journal_name, journal_data)
Ejemplo n.º 11
0
def run_event_loop():
    print('What do you want to do with your journal?')
    cmd = 'EMPTY'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = input(
            '[L]ist entries, [A]dd an entry, [U]pdate an entry, [R]emove an entry, E[x]it... '
        )
        cmd = cmd.lower().strip()

        if cmd == 'l':
            print_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd == 'u':
            update_entry(journal_data)
        elif cmd == 'r':
            remove_entry(journal_data)
        elif cmd != 'x' and cmd:
            print('Sorry, we don\'t understand {}'.format(cmd))

        print()

    print('Done, goodbye.')
    journal.save(journal_name, journal_data)
def run_event_loop():
    print('What do you want to do with your journal?')
    # asking the user what they wanna do for the journal, adding new stuff or listing all they did before or finish and exit
    command = 'EMPTY'
    journal_name = 'default'
    journal_data = journal.load(journal_name)  # []  # list()

    while command != 'x' and command:
        # using the first letter of the options as the command
        command = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        command = command.lower().strip(
        )  # changing the uppercase of the Command as the lowercase for decrease the error

        if command == 'l':
            list_entries(journal_data)
        elif command == 'a':
            add_entry(journal_data)
        elif command != 'x' and command:
            # if the command is not as L for listing A for adding X for exist
            print("Sorry, we don't understand. Please retype it '{}'.".format(
                command))


# when the user finish editing his/her journal, print Done and See You Next Time
    print('Done!')
    print('See You Next Time ~')
    journal.save(journal_name,
                 journal_data)  #saving the journal data and journal name
Ejemplo n.º 13
0
def run_event_loop():
    """
    main event loop for journal, most of the other functions run through this,
    or are activated through another function call from this loop.
    Small greeting, asks your name then hits the while loop and
    prompts for option selection.
    :return:

    """
    journal_name = input('What is your name?: \n')
    print("""Hello {}, how are you today?
        You should write about it in your journal.""".format(journal_name))
    print('\nWhat do you want to do? ')
    # print("")
    cmd = "EMPTY"

    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd != 'exit':
        # print("")
        cmd = input('\n[L]ist entries, [A]dd entries, E[x]it:  \n').lower().strip()

        if cmd == 'l' or cmd == 'list':
            list_entries(journal_data)
        elif cmd == 'a' or cmd == 'add':
            add_entry(journal_data)
        elif cmd != 'x' and cmd != 'exit':
            print("Sorry, we don't understand '{}'.".format(cmd))
    print('In a galaxy far far away...\n')

    journal.save(journal_name, journal_data)
Ejemplo n.º 14
0
def run_event_loop():
    print('What would you like to do today?')
    while True:
        try:
            cmd = "EMPTY"
            journal_name = 'default'
            journal_data = journal.load(journal_name)
            while cmd != 'x' and cmd:
                cmd = input('(L)ist, (A)dd, E(x)it: ')
                if cmd.lower().strip() == 'l':
                    list_entries(journal_data)
                elif cmd.lower().strip() == 'a':
                    add_entries(journal_data)
                elif cmd.lower().strip() == 'x':
                    break
                elif cmd:
                    print('Sorry, we don\'t understand {0}.'.format(cmd))

            print('Goodbye!')
            journal.save(journal_name, journal_data)
        except ValueError:
            print('Please enter a valid value.')
            continue
        else:
            break
Ejemplo n.º 15
0
def run_event_loop():

    global name
    print(f'What would you like to do today, {name}?')

    data = journal.load(name)

    cmd = None
    while cmd != 'c':
        journal.display_journal(name, data)
        cmd = input(
            '[R]ead Entry, [A]dd Entry, [D]elete Entry, [E]dit Entry, [C]lose Journal: '
        )
        cmd = cmd.lower().strip()

        if cmd == 'r':
            do_read(data)
        elif cmd == 'a':
            do_add(data)
        elif cmd == 'd':
            do_delete(data)
        elif cmd == 'e':
            do_edit(data)
        elif cmd != 'c':
            print(f'Not sure what you mean by {cmd}!')

    print_goodbye("have a good one")
    journal.save(name, data)
Ejemplo n.º 16
0
def run_event_loop():
    """
    hier wordt aan de gebruiker gevraagd wat hij wilt doen, dag boek bekijken of juist nieuwe items toevoegen
    :return:
    """
    # in de while loop verder op wordt er gekeken naar de variable cmd. deze moet eerst gedefinieerd worden
    cmd = 'EMPTY'
    # we zetten nu de journal name op "None" dan is hij leeg en kunnen we straks kijken of hij leeg is.
    # is hij leeg dan vragen we de naam op. dit doen we om te zorgen dat we in de while loop kunnen wisselen van gebruiker
    journal_name = None
    print('What do you want to do with your journal?')
    # onderstaande while loop wordt uitgevoerd zolang er geen "x" wordt ingegeven of direct op enter wordt gedrukt.
    while cmd != 'x' and cmd:
        # zolang journal_name leeg is wordt onderstaande if uitgevoerd, we vragen hier de gebruikersnaam op (dit gebeurt als we het script de eerst keer draaien, of van gebruiker wisselen dan gooien we journal_name namelijk leeg
        if not journal_name:
            # dit heb ik gedaan zodat er meerdere journals gemaakt worden voor meerder mensen
            journal_name = input('Please give your yournal name: ')
            # hier wordt de load functie aangeroepen in het journal.py programma, de return van deze functie wordt opgeslagen in journal_data
            journal_data = journal.load(journal_name)

        # vraag aan de gebruiker wat hij wilt doen en sla dit op in "cmd"
        cmd = input(
            '[L]ist entries, [A]dd entry, [C]hange journal, [x] our <enter> to exit: '
        )
        # om te zorgen dat cmd altijd lowercase is en er geen eventuele spaties voor kunnen staan gebruiken we .lower() "om er kleine letters van te maken en .strip() om alleen de ingevoerde letter te gebruiken
        cmd = cmd.lower().strip()
        # als er een "L" is ingevoerd voer het onderstaande uit
        if cmd == 'l':
            # de sub functie list entry wordt aangeroepen en de data uit journal_data wordt mee gegevens als variable
            list_entries(journal_data)
        # als er een "A" is ingevoerd voer dan onderstaande uit:
        elif cmd == 'a':
            # de functie add_entry wordt nu aangeroepen en de data uit journal_data wordt meegegeven als variable
            add_entry(journal_data)
        # als er een "c" wordt ingegeven wordt onderstaande uitgevoerd:
        elif cmd == 'c':
            # eerst wordt de functie save in het journal.py bestand uitgevoerd, de variablen journal_name en Journal_data worden mee gegeven
            journal.save(journal_name, journal_data)
            # nu zetten we de variable journal_name terug naar None (leeg) zodat in de eerste if statement in de while loop deze weer gevuld wordt en we dan met die gebruiker verder gaan in de while loop.
            journal_name = None
        # als er een teken wordt ingevoerd welke niet hierboven wordt beschreven ( x, l, a, en c) wordt er aangegeven dat dit teken niet bekend is
        elif cmd != 'x' and cmd:
            # hier wordt daadwerkelijk geprint dat we het teken niet herkennen en welk teken dat is
            print("sorry, we don't understand '{}'".format(cmd))
    # hier wordt de goodbye message geprint
    print('Done, goodbye')
    # hier wordt de functie save in het journal.py bestand uitgevoerd, de variablen journal_name en Journal_data worden mee gegeven om de data op te slaan
    journal.save(journal_name, journal_data)
Ejemplo n.º 17
0
def run_event_loop():
    filename = input("What file would you like to load? ")
    journal_data = journal.load(filename)  #[]

    while True:
        command = input("[L]ist entries, [A]dd an entry, E[x]it: ")

        if command.upper() == "L":
            list_entries(journal_data)
        elif command.upper() == "A":
            add_entry(journal_data)
        elif command.upper() == "X":
            break
        else:
            print("Sorry, I don't understand")
    journal.save(filename, journal_data)
Ejemplo n.º 18
0
def run_event_loop():
    filename = "default"
    journal_data = journal.load(filename)#[]

    while True:
        command = input("[L]ist entries, [A]dd an entry, E[x]it: ")

        if command.upper() == "L":
            list_entries(journal_data)
        elif command.upper() == "A":
            add_entry(journal_data)
        elif command.upper() == "X":
            break
        else:
            print("You Idiot! There are only three options and you tried to choose a fourth")
    journal.save(filename, journal_data)
Ejemplo n.º 19
0
def run_event_loop():
    filename = "default"
    journal_data = journal.load(filename)

    while True:
        command = input("[L]ist entries, [A]dd an entry, E[x]it: ")

        if command == "L":
            list_entries(journal_data)
        elif command == "A":
                add_entry(journal_data)
        elif command.upper() == "X":
                    break
        else:
            print("sorry, i dont understand")
    journal.save(filename, journal_data)
Ejemplo n.º 20
0
def run_event_loop():
    journal_name = input("Journal Name: ")
    journal_data = journal.load(journal_name)

    cmd = None
    while cmd != 'x':
        cmd = input("What do you want to do? [L]ist, [E]nter, or E[x]it?: ")
        cmd = cmd.lower().strip()
        if cmd == 'l':
            journal.list_entries(journal_data)
        elif cmd == 'e':
            journal.enter(journal_data)

    print("DONE")

    journal.save(journal_name, journal_data)
Ejemplo n.º 21
0
def run_event_loop():
    filename = input("What should we call your journal file? ")
    print("what do you want to do with your journal? ")
    command = None
    journal_data = journal.load("filename")
    while command != "x":
        command = input("[L]ist entries, [A]dd an entry, E[x]it: ")

        if command.upper() == "L":
            list_entries(journal_data)
        elif command.upper() == "A":
            add_entry(journal_data)
        elif command.upper() != "X":
            print("Sorry, we don't understand ")

    journal.save("filename", journal_data)
Ejemplo n.º 22
0
def run_event_loop():
    print("What do you want to do with your journal?")
    cmd = None
    cmd_clean = None
    journal_name = "my_journal"
    journal_data = journal.load(journal_name)
    while cmd_clean != "x":
        cmd = input("[L]ist entries, [A]dd entry, E[x]it: ")
        cmd_clean = cmd.lower().strip()
        if cmd_clean == "l":
            list_entries(journal_data)
        elif cmd_clean == "a":
            add_entry(journal_data)
        else:
            print("Invalid option {}".format(cmd))
    journal.save(journal_name, journal_data)
    print("Program exited.")
Ejemplo n.º 23
0
def run_event_loop():
    print('What do you want to do with your journal?')
    cmd = 'EMPTY'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.lower().strip()
        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x' and cmd:
            print("Did not understand the command '{}'".format(cmd))
    print('Done, goodbye.')
    journal.save(journal_name, journal_data)
Ejemplo n.º 24
0
def run_event_loop():
	print("What do you want to do with your journal?")
	cmd = "EMPTY"
	journal_name = 'default'
	journal_data = journal.load(journal_name) # [] list()
	while cmd != 'x' and cmd:
		cmd = input('[L]ist entries, [A]dd an entry, E[x]it:')
		cmd = cmd.lower().strip()

		if cmd == '1':
			list_entries(journal_data)
		elif cmd == 'a':
			add_entry(journal_data)
		elif cmd == 'x' and cmd:
			print("Sorry, we don't understand {}.".format(cmd))
	print("Done, goodbye")
	journal.save(journal_name, journal_data)
Ejemplo n.º 25
0
def run_event_loop():
    print("What do you want to do with your journal?")
    cmd = 'EMPTY'
    journal_name = "default"
    journal_data = journal.load(journal_name)

    while cmd != 'X' and cmd:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.upper().strip() 
        if cmd == 'L':
            list_entries(journal_data)
        elif cmd == 'A':
            add_entry(journal_data)
        elif cmd != 'X' and cmd:
            print("Sorry, we don't understand {}.".format(cmd))  
    print("\nGoodbye.")
    journal.save(journal_name, journal_data)
Ejemplo n.º 26
0
def run_event_loop():
    cmd = 'EMPTY'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = input('What do you want to do? [L]ist, [A]dd, or E[x]it? ')
        cmd = cmd.lower().strip()
        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x' and cmd:
            print('Sorry, we don\'t understand {}'.format(cmd))

    print('Done, goodbye.')
    journal.save(journal_name, journal_data)
Ejemplo n.º 27
0
def run_event_loop():
    cmd = ''
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd.upper().strip() != 'X':
        cmd = input('Do you want to List, Add entries or eXit?')

        if cmd.upper().strip() == 'L':
            list_entries(journal_data)
        elif cmd.upper().strip() == 'A':
            add_entry(journal_data)
        elif cmd.upper().strip() != 'X':
            print('Incorrect input')

    print('Saving...')
    journal.save(journal_name, journal_data)
Ejemplo n.º 28
0
def run_event_loop():
    filename = input("What should we call your journal file? ")
    print("What do you want to do with your journal?")
    command = "J"  # J is Placeholder.
    journal_data = journal.load(filename)

    while command.upper() != "E":
        command = input("[L]ist entries, [A]dd an entry, [E]xit: ")

        if command.upper() == "L":
            list_entries(journal_data)
        elif command.upper() == "A":
            add_entry(journal_data)
        elif command.upper() != "E":
            print("Input not recognized.")

    journal.save(filename, journal_data)
Ejemplo n.º 29
0
def run_event_loop():
    print("What do you want to do with your journal?")
    cmd = "EMPTY"
    journal_name = 'default'
    journal_data = journal.load(journal_name)  # [] list()
    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it:')
        cmd = cmd.lower().strip()

        if cmd == '1':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd == 'x' and cmd:
            print("Sorry, we don't understand {}.".format(cmd))
    print("Done, goodbye")
    journal.save(journal_name, journal_data)
Ejemplo n.º 30
0
def run_event_loop():
    print('What do you want to do with your journal?')
    cmd = None
    journal_name = "default"
    journal_data = journal.load(journal_name)
    while cmd != 'x':
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.lower().strip()
        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x':
            print("We don't understand the format")

    journal.save(journal_name, journal_data)
    print('Goodbye')
Ejemplo n.º 31
0
def eventloop():
    journalM = journal.load()
    while (True):
        print('What do you want to do?')
        cmd = input('(L)ist, (A)dd, E(x)it ? ')
        cmd = cmd.strip()
        cmd = cmd.lower()
        if (cmd == 'l'):
            listentries(journalM)
        elif (cmd == 'a'):
            addentry(journalM)
        elif (cmd == 'x'):
            print('Thank you for using the Journal App!')
            break
        else:
            print("Sorry, didn't understand that")
    journal.save(journalM)
Ejemplo n.º 32
0
def run_event_loop():
    print('What do you want to do with your journal?')
    cmd = "SOMETHING"
    journal_name = "default"
    journal_data = journal.load(journal_name)  # []  # list()

    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.lower().strip()
        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x' and cmd:
            print("Sorry, we don't understand '{}'.".format(cmd))
    print("Done. Goodbye!")
    journal.save(journal_name, journal_data)
Ejemplo n.º 33
0
def run_event_loop():
    print('What do you want to do with your journal?')
    cmd = 'EMPTY'
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it. :  ')
        cmd = cmd.lower().strip()
        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x' and cmd:
            print("Sorry didn't understand '{}'".format(cmd))

    print('Done. Goodbye friend.')
    journal.save(journal_name, journal_data)
Ejemplo n.º 34
0
def run_event_loop():
    print('What do you want to do with your journal?')
    cmd = None
    journal_name = 'default'
    journal_data = journal.load(journal_name)

    while cmd != 'X':
        cmd = input('([L]ist entries, [A]dd an entry, E[x]it:')
        cmd = cmd.upper().strip()

        if cmd == 'L':
            list_entries(journal_data)
        elif cmd == 'A':
            add_entry(journal_data)
        elif cmd != 'X':
            print("Sorry, we don't understand '{}".format(cmd))

    print('Done, goodbye.')
    journal.save(journal_name, journal_data)
Ejemplo n.º 35
0
def run_event_loop():
    
    command = None 
    journal_name = 'default'
    print("Loading {0}...".format(journal_name))
    journal_data = journal.load(journal_name)    

    while(command != 'X'):

        command = input('[L]ist entries, [A]dd an entry, E[x]it:')
        command = command.upper().strip()

        if command == 'L':
            list_entries(journal_data)
        elif command == 'A':
            add_entry(journal_data)
        elif command != 'X':
            print("'{}' not found".format(command))
    journal.save(journal_name, journal_data)
Ejemplo n.º 36
0
def run_event_loop():
    """
    Accepts the input from the user and calls the operation functions based on the input
    """
    print'What do you want to do with your journal'
    cmd = 'EMPTY'
    journal_name = 'Default'
    journal_data = journal.load(journal_name)
    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd entries, E[x]it: ')
        cmd = cmd.lower().strip()
        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd != 'x':
            print"Sorry, we don't understand '{}'.".format(cmd)

    print'Done, goodbye'
    journal.save(journal_name, journal_data)
Ejemplo n.º 37
0
def run_event_loop():
    print('What do you want to do with your journal?')
    journal_name = 'default'
    journal_data = journal.load(journal_name)


    while True:
        cmd = input('[L]ist entries, [A]dd an entry, E[x]it: ')
        cmd = cmd.lower().strip()

        if cmd == 'l':
            list_entries(journal_data)
        elif cmd == 'a':
            add_entry(journal_data)
        elif cmd == 'x':
            print('Done, goodbye.')
            journal.save(journal_name, journal_data)
            break
        else:
            print('Erro na aplicação, não existe o comando: ', cmd)
Ejemplo n.º 38
0
def get_action():
    print('What would you like to do with your journal')
    cmd = 'Empty'
    journal_name = 'default'
    entries = journal.load(journal_name)

    while cmd != 'x' and cmd:
        cmd = input('[L]ist entries, [A]dd or E[x]it? ')
        cmd.lower().strip()

        if cmd == 'l':
            print('Listing entries')
            list_entries(entries)
        elif cmd == 'a':
            print('Add entries')
            add_entries(entries)
        elif cmd != 'x' and cmd:
            print('Sorry! We don\'t understand {}'.format(cmd))

    print('Done goodbye!')
    journal.save(journal_name, entries)