Exemple #1
0
def holdings_loop():

    quit_input = ['q', 'Quit', 'quit']      # exit the game

    while True:
        user_input = view.menu().lower()

        if user_input.isdigit():
            # assume numeric input is CIK
            display_holdings(user_input)
        else:
            if user_input in quit_input or len(user_input) == 0:
                view.show_user_results('Thanks for playing.  Goodbye!')
                switched_on = False
                return False
            else:
                # company name lookup
                cik = model.get_cik_from_name(user_input)
                if len(cik) > 0:
                    display_holdings(cik)
                else:
                    view.show_user_results('CIK not found for {0}'.
                                           format(user_input))

    return True
Exemple #2
0
def game_loop():
    buy_input = ['b', 'buy']
    sell_input = ['s', 'sell']
    quit_input = ['q','quit']

    valid_input = buy_input + sell_input + quit_input

    switched_on = True
    while switched_on:
        user_input = view.menu().lower()
        if user_input in valid_input:
            if user_input in buy_input:
                #print('Progress to business logic for buy')
                x = model.buy()
                return x
            elif user_input in sell_input:
                print('Progress to business logic for sell')
            elif user_input in quit_input:
                print('Thanks for playing.  Goodbye!')
                break
                #switched_on = False
            print('Progress to next step')
        else:
            print('Invalid input')
            game_loop()
Exemple #3
0
def main():
    source_file = 'sac_realestate.csv'
    # Get a user request (expecting a list type, example: [ 'max', 'price' ])
    calc, field = view.menu()
    print(f"Selected Analysis: {calc}, {field}")

    # Get data set for analysis
    result, list_index_of_records = analyze_statistics.analyze_data_from_source(
        source_file, calc, field)
    #list_index_of_records = analyze_statistics.get_index_from_value(dataset, result)

    records = []
    for i in list_index_of_records:
        records.append(data.get_record_from_index(source_file, i))
    print("Result: ", result)
    print("Records: ", records)
 def run(self):
     choice = ''
     while choice != "7":
         choice = str(view.menu(input))
         if choice == "1":
             self.show_all()
         elif choice == "2":
             self.show_summary()
         elif choice == "3":
             self.show_by_period()
         elif choice == "4":
             self.show_summary_period()
         elif choice == "5":
             self.show_by_date()
         elif choice == "6":
             self.add_record()
Exemple #5
0
def choose_menu():
    """
    Choose menu function
    """
    choose = view.menu()
    if choose == 1:
        view.show()
    elif choose == 2:
        view.create()
    elif choose == 3:
        view.edit()
    elif choose == 4:
        view.delete()
    elif choose == 5:
        exit()
    else:
        print("Please, type a number from 1 to 5")
    choose_menu()
def main_func():
    """ readiness level: 1, 4, 5, 7"""
    choice = ''
    records = initialise("fuel_consumption.pickle")
    while choice != "7":
        choice = str(view.menu())
        if choice == "1":
            show_all(records)
        elif choice == "2":
            show_summary(records)
        elif choice == "3":
            show_by_period(records)
        elif choice == "4":
            show_summary_period(records)
        elif choice == "5":
            show_by_date(records)
        elif choice == "6":
            add_record(records)
        elif choice == "7":
            save_all(records, "fuel_consumption.pickle")
        else:
            pass
    def GET(self):
        redact = {}
        schema = db.wikischema()
        block_list = db.get_redact_list()

        for tcol in block_list:
            redaction = db.get_redaction(tcol)
            table, col = tcol.split('.')
            if table not in redact:
                redact[table] = {}
            redact[table][col] = {}
            redact[table][col]['type'] = schema[table][col]
            redact[table][col]['redaction'] = redaction

            m = re.search('\d+', schema[table][col])
            if m and m.group(0):
                redact[table][col]['size'] = m.group(0)
            else:
                redact[table][col]['size'] = 64

        print redact
        return render.base(view.menu('redacted'), view.redacted(redact))
Exemple #8
0
from ksiega_obiektowo import Wpis
from ksiega_obiektowo import Ksiega
import view as View

View.menu()
opcja = input('moj wybor:')

if opcja == '1':
    autor = input('Jak masz na imie: ')
    tresc = input('Podaj tresc wpisu: ')
    tytul = input('Podaj tytul wpisu: ')

    wpis = Wpis(autor, tresc, tytul)
    ksiega = Ksiega()
    ksiega.dodaj_wpis(wpis)

else:
    View.blad()
Exemple #9
0
from view.menu import *

'''
Nessa parte ele importa a pasta view e a classe menu, por isso está view.menu

'''
exibir = menu()

exibir.exibeInicio()
Exemple #10
0
def main():
    view.menu()
 def GET(self):
     schema = db.wikischema()
     tables = sorted(schema)
     review = db.get_review()
     return render.base(view.menu('review'),
                        view.review(schema, tables, review))
Exemple #12
0
def debit_loop(db_name, module_logger):

    create_input = ['c', 'create']      # create account
    charge_input = ['r', 'charge']      # charge account
    hold_input = ['h', 'hold']          # place hold on account
    settle_input = ['s', 'settle']      # release hold & charge actual amount
    quit_input = ['q', 'quit']          # exit the game

    # valid input is combination of all other inputs
    valid_actions = create_input + charge_input + hold_input + settle_input + quit_input

    msg = 'Valid actions are: [' + ','.join(valid_actions) + ']'
    view.show_user_results(msg)

    # Loop until user requests to quit
    switched_on = True
    while switched_on:
        user_input = view.menu().lower()

        # perform user requested action
        if user_input in create_input:
            # create_account(initial_balance)
            amt, ignore1, ignore2, valid_input = get_user_input(['amount'])

            if valid_input:
                acct_num = model.create_account(amt, db_name)
                if acct_num == -1:
                    view.show_user_results('Failed to create account')
                else:
                    msg = 'New account number = {acct_num} Initial balance = {amt}.'.\
                        format(acct_num=acct_num, amt=amt)
                    view.show_user_results(msg)
                    module_logger.info(msg)

        elif user_input in charge_input:
            # charge(account_id, amount)
            # get user input
            amt, acct_num, ignore2, valid_input = get_user_input(['amount', 'account'])

            # if user entered valid input, process it
            if valid_input:
                ret_sts = model.charge(acct_num, amt, db_name)
                if ret_sts == 0:
                    msg = 'Successfully charge account {acct_num} {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -1:
                    msg = 'Failed to charge account {acct_num}'.format(acct_num=acct_num)
                elif ret_sts == -2:
                    msg = 'Insufficient funds to charge account {acct_num} {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                else:
                    msg = 'Unknown status returned from model.charge {ret_sts}'.\
                        format(ret_sts=ret_sts)
                view.show_user_results(msg)
                module_logger.info(msg)

        elif user_input in hold_input:
            # hold(account_id, vendor_id, amount)
            # get user input
            amt, acct_num, vendor_id, valid_input = get_user_input(['amount', 'account', 'vendor'])

            # if user entered valid input, process it
            if valid_input:
                ret_sts = model.hold(acct_num, vendor_id, amt, db_name)
                if ret_sts == 0:
                    msg = 'Hold on account {acct_num} for {amt} is successful'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -1:
                    msg = 'Failed to place hold on account {acct_num} for {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -2:
                    msg = 'Insufficient funds to place hold on account {acct_num} for {amt}'.\
                        format(acct_num=acct_num, amt=amt)
                elif ret_sts == -3:
                    msg = 'Only 1 hold per vendor id for account {acct_num}'.\
                        format(acct_num=acct_num)
                else:
                    msg = 'Unknown status returned from model.hold {ret_sts}'.\
                        format(ret_sts=ret_sts)
                view.show_user_results(msg)
                module_logger.info(msg)

        elif user_input in settle_input:
            # settle_hold(account_id, vendor_id, actual_amount)
            # get user input
            amt, acct_num, vendor_id, valid_input = get_user_input(['amount', 'account', 'vendor'])

            if valid_input:
                ret_sts = model.settle_hold(acct_num, vendor_id, amt, db_name)
                if ret_sts == 0:
                    msg = 'Settle hold on account {acct_num} for {amt} is successful'.\
                            format(acct_num=acct_num, amt=amt)
                elif ret_sts == -1:
                    msg = 'Failed to settle hold on account {acct_num}'.\
                            format(acct_num=acct_num)
                elif ret_sts == -2:
                    msg = 'Insufficient funds to settle hold on account {acct_num} for {amt}'. \
                        format(acct_num=acct_num, amt=amt)
                else:
                    msg = 'Unknown status returned from model.hold {ret_sts}'. \
                        format(ret_sts=ret_sts)
                view.show_user_results(msg)
                module_logger.info(msg)

        elif user_input in quit_input:
            view.show_user_results('Thanks for playing.  Goodbye!')
            module_logger.info('User entered quit')
            switched_on = False
            # break
        else:
            view.show_user_results('Invalid input')
            msg = 'Valid actions are: [' + ','.join(valid_actions) + ']'
            view.show_user_results(msg)