예제 #1
0
    def takeUserInput(self):
        print("--------------------------------------------------------------------------")
        print("-----------------------Welcome to Safeway!!-------------------------------")

        enterOption = input("Press 1 to Enter, Press 2 to Exit")
        if enterOption == 1:
            print("-----------------------------------------------------------------------")
            new_customer = ""
            while True:
                print("-----------------------------------------------------------------------")
                print("Enter 1 for creating a customer")
                print("Enter 2 for generating a random customer")
                print("Enter 3 to exit")
                option = input("Please Enter your choice")
                print("\n")

                if option == 1:
                    new_customer = Customer()
                    del new_customer.items[:]
                    while True:
                        print("Enter 1 for Adding Item")
                        print("Enter 2 to see all the Items")
                        print("Enter 3 If finished shopping")

                        option2 = input("Please Enter your choice")
                        if option2 == 1:
                            item = Item.Item()
                            new_customer.items.append(item)
                            print("---------------------New Item Added-------------------------\n")

                        elif option2 == 2:
                            print("Item Name                    Item Price\n")
                            print("-----------------------------------------")
                            for i in new_customer.items:
                                print(str(i.name)+"                        "+ str(i.value))
                            print("\n")

                        elif option2 ==3:
                            message = Message('addcustomer', new_customer)
                            m = message.get_message_json()
                            self.protocol.sendLine(m)
                            print("Customer sent to the queue")
                            break




                if option==2:
                    message = Message('addcustomer', Customer())
                    m = message.get_message_json()
                    self.protocol.sendLine(m)
                    print("Customer sent to the queue")
                    continue

                if option ==3:
                    break

        if enterOption == 2:
            print("Good Bye")
            sys.exit()
예제 #2
0
 def add_item(self, item_id, item_name, image_url):
     new_item = Item(item_id=item_id,
                     item_name=item_name,
                     image_url=image_url)
     Database.session.add(new_item)
     Database.session.commit()
     return new_item
예제 #3
0
 def object_decoder(self, obj):
     self.isAdult = obj['isAdult']
     self.hasAgeProof = obj['hasAgeProof']
     self.hasDebitOrCreditCard = obj['hasDebitOrCreditCard']
     self.cashOnHand = obj['cashOnHand']
     for item_json in obj['items']:
         item = Item.Item()
         item.decode_from_json(item_json)
         self.items.append(item)
예제 #4
0
                    {"name": 'Hygiene',
                     "sort": 110
                    }
              ]

    for category in categories:
        c = Category(**category)
        c.save()

    items = [
                {"category": "Dairy",
                 "name": "Skim milk",
                 "sort": 10
                },
                {"category": "Dairy",
                 "name": "Creamer",
                 "sort": 20
                }
            ]


    for item in items:
        print(item['category'])
        success, category = CategoryQuery.getByName(item['category'])
        if (success):
            item['category'] = category
            i = Item(**item)
            i.save()
        else:
            print('record not found')
예제 #5
0
emptyDict = {}
emptyDict['1'] = "a"
print(emptyDict)

lst2 = [x * x for x in range(1, 10)]
print(lst2)

#range(*lst)

print(userDict['1'])
print(userDict)
for usr in userDict:
    print(userDict[usr])
    print(int(1.11))

itm1 = Item(1, "disc", "www.google.com", 100, "internet")
itm1.getItemId()

dic1 = {'a': {'1': 1}, 'b': {'2': 2}}
print(dic1['a'])
dic2 = {}
dic2["a"] = {'1': 1}
dic2["a"] = {'3': 3}
print(dic2)

if ((3 > 2) & (3 < 4)):
    print('a')

chars = {'a': 1, 'b': 2, 'c': 3, 'd': 4}

dic3 = {"a": 1, "b": 2}
예제 #6
0
import sys
sys.path.append('../modules')

import peewee as pw
#import Models

from Models import Item, Category
from CategoryQuery import CategoryQuery
#from Models import Category

from Repo import Repo
from pprint import pprint

if __name__ == "__main__":
    try:
        # Models.Item.drop_table(True);
        # Models.Category.drop_table(True);
        Item.drop_table(True);
        Category.drop_table(True);
    except pw.OperationalError as e:
        print('error dropping tables')

    try:
        # Models.Category.create_table()
        # Models.Item.create_table()
        Category.create_table()
        Item.create_table()
    except pw.OperationalError as e:
        print(str(e.args[1]))
예제 #7
0
 def generate_items(self):
     total = randint(1, MAX_ITEMS)
     for x in range(0, total):
         item = Item.Item()
         self.items.append(item)