def main_loop(self): while 1: #set fps self.clock.tick(60) #if the desired mode is changed, then change the program to that mode. if self.selected_mode != str(self.current_mode): if self.selected_mode == 'Start' or self.selected_mode == 'Continue': if self.save == None: self.save = Game(self.screen) self.current_mode = self.save elif self.selected_mode == 'Menu': if self.save == None: self.current_mode = Menu(['Start', 'Quit'], self.screen) else: self.current_mode = Menu(['Continue', 'Quit'], self.screen) elif self.selected_mode == 'Shop': temp = Shop(self.screen, self.save.player) self.current_mode = temp self.save.player = temp.player elif self.selected_mode == 'Quit': raise SystemExit #if the current_mode exist, run its loop if self.current_mode != None: #the loop usually returns a str(self), so when it is not the case, the mode changes self.selected_mode = self.current_mode.loop( pygame.event.get(), self.screen) pygame.display.flip()
def buy(self, ashop=Shop(), bike=Bicycle): if bike.mname in self.canbuy(ashop): self.fund -= ashop.get_prices()[bike.mname] print("%s buy %s bike at %s, and have $%d remaining." % (self.cname, bike.mname, ashop.sname, self.fund)) else: print("too expensive to buy")
def init(): global grave_digger grave_digger = Shop("grave digger", [], False) global druid druid = Shop("druid", [item for item in game.items if not item.passive_effect], False) global blacksmith blacksmith = Shop("blacksmith", [item for item in game.items if item.passive_effect], False) global merchant merchant = Shop("merchant", game.player.inventory, True) if game.bonus_tasks: text.VILLAGE_OPTIONS.insert(text.VILLAGE_OPTIONS.index(text.OPTION_SAVE), text.OPTION_TREASURE_CHEST) text.VILLAGE_OPTIONS.insert(text.VILLAGE_OPTIONS.index(text.OPTION_SAVE), text.OPTION_GRAVE_DIGGER) update_actions()
def create_shop(): address = "piazza Calamatta" open_at = 9 close_at = 19 min_price_euro = 10 max_price_euro = 30 walk_in_start_time = 17 walk_in_length_time = 2 return Shop(address, open_at, close_at, min_price_euro, max_price_euro, walk_in_start_time, walk_in_length_time)
def init(self): self.user = User(self.username, self.password) self.user.login() self.attacker = Attacker(self.user, log=self.log) self.box = Box(self.user, self.openBoxType) self.equip = Equip(self.user, self.smeltEquipType) self.item = Item(self.user, self.useItemType, self.sellItemType) self.shop = Shop(self.user) self.growup = Growup(self.user) self.card = Card(self.user)
def make_shop(gauntletNum): if gauntletNum <= 5: itemLevel = 5 else: itemLevel = gauntletNum + 1 shopItems = [] shopItems.append(Potion(itemLevel, randint(2, 5))) shopItems.append(Ether(itemLevel, randint(2, 5))) shopItems.append(Spear(itemLevel, randint(1, 6))) shop = Shop(shopItems) return shop
def __init__(self, token, memory_filename, ban_filename, lootcrate_filename, promotion_access_filename, promotion_rating): logging.info('Initializing bot...') self.updater = Updater(token=token) logging.info('Updater initialized') self.memory_filename = memory_filename self.ban_filename = ban_filename self.memory = self.load_memory() self.lootCrates = LootCrates(lootcrate_filename) self.myshop = Shop(promotion_access_filename, helpers, self.lootCrates, self.add_cheat_winner, promotion_rating) logging.info('Memory loaded') self.today = None # self.echo_mode = False handlers = [ CommandHandler('start', self.start), CommandHandler('pidorules', self.start), CommandHandler('shrug', self.shrug), CommandHandler('pidoreg', self.reg), CommandHandler('pidunreg', self.unreg), CommandHandler('pidor', self.choose_winner), CommandHandler('pidostats', self.stats), CommandHandler('rollBan', self.rollBan), # CommandHandler('test', self.test), # CommandHandler('test2', self.test2), CommandHandler('test3', self.test3), CommandHandler('shop', self.shop), CommandHandler('pidostats_lifetime', self.get_top_winners_all), CommandHandler('listlootcrates', self.list_lootcrates), CommandHandler('openlootcrate', self.openlootcrate), CommandHandler('rmBan', self.rmBan), CommandHandler('grantLegend', self.grantLegend), CommandHandler('promotop', self.promotop), CallbackQueryHandler(self.myshop.promoInfo, pattern="promo"), CallbackQueryHandler(self.myshop.buyLegend, pattern="buy_legend"), CallbackQueryHandler(self.myshop.buyPromoAccess, pattern="aclo_access") # CommandHandler('echo', self.echo), # MessageHandler(filters.Filters.all, self.echo_msg) ] for handler in handlers: self.updater.dispatcher.add_handler(handler) self.updater.dispatcher.add_error_handler(self.error_handler) logging.info('Handlers added')
def get_city_shop_info(shopId, cityId, proxy, headers): shop = Shop(shopId) shop.get(proxy=proxy, headers=headers) if not shop._fetched: return data = { '地址': shop.address, '点评数': shop.reviews, '点评标签': shop.review_tags, '电话': get_full_phone(shop.phone, cityId), '点评类别': shop.comment_kinds, '评分': shop.scores } return data, shop.proxy, shop.headers
def parse_elements(self, element): soup = BeautifulSoup(element, 'lxml') name = self.get_name(soup) full_discount = self.get_full_discount(soup) discount = self.get_discount(full_discount) label = self.get_label(full_discount) image = self.get_image(soup) url = self.get_url(soup) if name is not None and discount is not None and label is not None and image is not None and url is not None: return Shop(name=name, discount=discount, label=label, image=image, url=url)
def get_city_shop_info(shopId, cityId, proxy, headers): shop = Shop(shopId) shop.get(proxy=proxy, headers=headers) if not shop._fetched: return data = { # '地址': shop.address, 'reviews': shop.reviews, # 点评数 'review_tags': shop.review_tags, # 点评标签 'phoneNumber': get_full_phone(shop.phone, cityId), # 电话 'comment_kinds': shop.comment_kinds, # 点评类别 'scores': shop.scores # 评分 } return data, shop.proxy, shop.headers
def draw(self): while True: self.clock.tick(30) # リストボックスの描画 self.option_listbox.draw(False) self.file_listbox.draw() self.Select_Stage(self.file_id) #ステージ選択処理 self.messagebox.draw() pygame.display.update() for event in pygame.event.get(): # リストボックスに入力 file_id = self.file_listbox.process(event) option_num = self.option_listbox.process(event) if event.type == KEYDOWN: self.Key_Event(event) #押されたキーによって異なる処理 if event.key == K_RETURN and self.select_num == 1 and self.file_id != None: return self.Return_Stage(self.stage_path[self.stage_num]) if event.type == QUIT: return EXIT, None if file_id != None: # ファイルが選択されたとき self.file_id = file_id self.stage_path = glob(self.path[self.file_id] + '/*') self.stage_text = self.stage_path self.stage_said_text = [] for i, _ in enumerate(self.stage_text): self.stage_said_text.append("Stage" + str(i+1)) self.select_num += 1 # file_listboxからターゲットを外す self.file_listbox.process(event) self.stage_num = 0 if option_num != None: # オプションが選択されたとき if option_num == 0: return None, '0' elif option_num == 1: Shop(self.screen, self.data).do() break elif option_num == 2: if Equipment(self.screen, self.data).do() == EXIT: return EXIT, None break self.screen.fill((0,0,0))
def main(): # clear terminal or console # os.system('cls') # User login user = log_in() # Interface initialization initialization() # Initialize shop rental_shop = Shop(INVENTORY_DATA_PATH) # Start to operate related instructions user.run(rental_shop)
def setUp(self) -> None: """ Before testing the method of the class, create the instance of the class. """ if not os.path.exists(CUSTOMERS_DIRECTORY): os.makedirs(CUSTOMERS_DIRECTORY) self.data_path = CUSTOMERS_DIRECTORY + "/test.json" if os.path.exists(self.data_path): with open(self.data_path, 'r') as load_f: rented_cars = json.load(load_f) self.user = Customer(self.data_path, rented_cars) else: self.user = Customer(self.data_path) rental_shop = Shop(INVENTORY_DATA_PATH) self.user.rental_shop = rental_shop
def __init__(self, root): with open('users_pwd.pkl','rb') as f: self.pwd = pickle.load(f) self.p = Shop() self.l1 = tk.Label(root, text="Account Number") self.l1.grid(row=0, column=0) self.l2 = tk.Label(root, text="Password") self.l2.grid(row=1, column=0) self.v1 = tk.StringVar() self.v2 = tk.StringVar() self.e1 = tk.Entry(root, textvariable=self.v1) self.e1.grid(row=0, column=1, padx=10, pady=5) self.e2 = tk.Entry(root, textvariable=self.v2, show="*") self.e2.grid(row=1, column=1, padx=10, pady=5) self.b1 = tk.Button(root, text="Login", width=10, command=self.home_page) self.b1.grid(row=2, column=0, sticky=tk.W, padx=10, pady=5) self.b2 = tk.Button(root, text="Sign up", width=10, command=self.sign_up) self.b2.grid(row=2, column=1, sticky=tk.E, padx=10, pady=5)
def dump_details(): try: details_dict = {} if os.path.exists(DUMP_FILE_SHOP_DETAILS): with open(DUMP_FILE_SHOP_DETAILS, 'r') as f: doc_details = f.read() for shop_details in decode_json_stacked(doc_details): idx = shop_idx(shop_details) details_dict[idx] = shop_details with open(DUMP_FILE_SHOPS, 'r') as f: doc_shops = f.read() shop_data_list = list(decode_json_stacked(doc_shops)) progress_bar = tqdm(range(len(shop_data_list)), unit='shop', position=0, dynamic_ncols=True) with open(DUMP_FILE_SHOP_DETAILS, 'a') as f: for cur in progress_bar: shop_data = shop_data_list[cur] idx = shop_data['店铺ID'] if details_dict.get(idx) is not None: continue shop = Shop(shop_idx(shop_data)) headers = inject_cookie(HEADERS) try_http_request( lambda: shop.get(headers=headers), lambda cookies: inject_cookie(headers, cookies)) shop.get(headers=inject_cookie(HEADERS)) to_extend = { 'comment_kinds': shop.comment_kinds, 'review_tags': parse_review_tags(shop.review_tags), 'scores': shop.scores, } shop_data.update(to_extend) f.write(encode_json(shop_data)) f.flush() progress_bar.close() finally: logger.info(f'Data dumped to {DUMP_FILE_SHOP_DETAILS}')
def initial_game(screen): pygame.mixer.music.stop() pygame.mixer.music.load(const.MUSIC_DIR + "home.ogg") pygame.mixer.music.set_volume(const.BGM_VOL) player = Hero('resources/images/Actor/Actor1.png', 0, 0) # load_tasks(player) player.controller = "main" dialog = Dialog(player, screen) scroll_map = ScrollMap(const.TMX_DIR + "home.tmx", screen, const.MUSIC_DIR + "home.ogg") pygame.mixer.music.play(loops=-1) icon = Icon(scroll_map, player, dialog, screen) shop = Shop(player, icon, screen) scroll_map.add(player) for start_point in scroll_map.start_points: if start_point.properties['__name__'] == 'start_point': player.rect.center = (start_point.rect.left, start_point.rect.top) break scroll_map.center(player.rect.center) return player, scroll_map, dialog, icon, shop
def load_game(screen): pygame.mixer.music.stop() screen.fill((0, 0, 0)) pygame.display.flip() own_list = pet_list("resources\\save\\own_list.json") battle_list = [] with open("resources\\save\\battle_list.json", "r") as ob: load_battle_list = json.load(ob) for i in range(len(load_battle_list)): battle_list.append(own_list[load_battle_list[i]]) with open("resources\\save\\hero.json", "r") as ob: load_hero = json.load(ob) player = Hero(load_hero[0], load_hero[1], load_hero[2]) player.load(load_hero) player.own_list = own_list player.battle_list = battle_list load_tasks(player) with open("resources\\save\\scroll_map.json", "r") as ob: load_scroll_map = json.load(ob) scroll_map = ScrollMap(load_scroll_map[0], screen, load_scroll_map[1]) scroll_map.add(player) scroll_map.center(player.rect.center) dialog = Dialog(player, screen) icon = Icon(scroll_map, player, dialog, screen) shop = Shop(player, icon, screen) pygame.mixer.music.load(scroll_map.music) pygame.mixer.music.set_volume(const.BGM_VOL) pygame.mixer.music.play(loops=-1) const.LOAD = 0 return player, scroll_map, dialog, icon, shop
def __init__(self): self.menu = Menu() self.window_w = 1100 self.window_h = 700 self.wave = 0 self.player_gold = 100 self.bg = pygame.image.load("img/bg.png") self.bg = pygame.transform.scale(self.bg, (self.window_w, self.window_h)) self.run = True self.shop = Shop() self.shop_upgrades = [self.shop.dmg_rect, self.shop.def_rect, self.shop.spd_rect] self.interface = Interface() self.crossbow = Crossbow() self.enemies = [] self.window = pygame.display.set_mode((self.window_w, self.window_h)) self.hp = 1500 self.defense = 0 self.game_status = "menu" # running / shop / menu self.wave_button = pygame.image.load("img/button.png") self.wave_button = pygame.transform.scale(self.wave_button, (200, 60)) self.wave_button_pos = 30, 530 self.wave_button_rect = self.wave_button.get_rect(topleft=self.wave_button_pos)
def printMenu(): shopName = input("What is the name of the shop?") shopLocation = input("What is the location of the shop") s1 = Shop(shopName, shopLocation) while True: print("-" * 40) print("1. Add Product ") print("2. Sell Product ") print("3. Show Products ") print("4. Exit ") userInput = int(input("Choose a menu option.")) if userInput == 1: s1.inventory.addProduct() elif userInput == 2: s1.inventory.sellProduct() elif userInput == 3: s1.inventory.showInventory() elif userInput == 4: quit() else: pass
class Handler: shop = Shop() def __init__(self, CHANNEL_ACCESS_TOKEN, CHANNEL_SECRET, mongodb): self.CHANNEL_ACCESS_TOKEN = CHANNEL_ACCESS_TOKEN self.CHANNEL_SECRET = CHANNEL_SECRET self.mongodb = mongodb self.shop = Shop() def callback(self, signature, body): parser = WebhookParser(self.CHANNEL_SECRET) try: events = parser.parse(body, signature) self.__handle_message(events[0]) except InvalidSignatureError as e: print(e) def __handle_message(self, event): line_bot_api = LineBotApi(self.CHANNEL_ACCESS_TOKEN) if event.type == 'message': if event.message.type == 'location': self.__handle_location_message(event, line_bot_api) elif event.message.text == 'search': self.__handle_quick_reply_action(event, line_bot_api) elif event.message.text == 'topics': print(event) elif event.message.text == 'favorites': self.__handle_favorites_message(event, line_bot_api) else: line_bot_api.reply_message( event.reply_token, TextSendMessage(text="對不起,我不了解您的問題")) else: # postback actions action = event.postback.data.split('_')[0] if action == 'favorite': self.__handle_favorites_postback_action(event, line_bot_api) elif action == 'deleteshop': self.__handle_delete_shop_postback_action(event, line_bot_api) elif action == 'topics': self.__handle_topics_postback_action(event, line_bot_api) else: result = self.shop.delete_favorite_shop(event, self.mongodb) if result: line_bot_api.reply_message(event.reply_token, TextSendMessage(text="已移除!")) else: line_bot_api.reply_message(event.reply_token, TextSendMessage(text="找不到結果")) def __handle_location_message(self, event, line_bot_api): nearby_shops = self.shop.get_nearby_shops_by_location( event, self.mongodb) if nearby_shops: with open('./templates/flexmessage.json') as file: flex_message_template = json.load(file) flex_messages = { "type": "carousel", "contents": [ deepcopy( self.__insert_flex_message(nearby_shop, flex_message_template)) for nearby_shop in nearby_shops ] } line_bot_api.reply_message( event.reply_token, FlexSendMessage(alt_text='店家資訊', contents=flex_messages)) else: line_bot_api.reply_message(event.reply_token, TextSendMessage(text="尚未探索這區~")) def __handle_favorites_message(self, event, line_bot_api): favorite_shops = self.shop.get_favorites(event, self.mongodb) if favorite_shops: with open('./templates/favorites.json') as file: favorites_template = json.load(file) line_bot_api.reply_message( event.reply_token, FlexSendMessage(alt_text='最愛清單', contents=self.__insert_favorites_flex_message( favorite_shops, favorites_template))) else: line_bot_api.reply_message(event.reply_token, TextSendMessage(text="尚未加入我的最愛")) def __handle_favorites_postback_action(self, event, line_bot_api): favorite_shops = self.shop.get_favorites(event, self.mongodb) if len(favorite_shops) > 9: line_bot_api.reply_message( event.reply_token, TextSendMessage(text="最愛店家已達十筆,請先刪除店家再進行新增!")) return None result = self.shop.add_into_my_favorites(event, self.mongodb) if result: line_bot_api.reply_message(event.reply_token, TextSendMessage(text="加入成功")) else: line_bot_api.reply_message(event.reply_token, TextSendMessage(text="已加入")) def __handle_delete_shop_postback_action(self, event, line_bot_api): favorite_shops = self.shop.get_favorites(event, self.mongodb) with open('./templates/favoritesComfirmMessage.json') as file: favorites_confirm_message_template = json.load(file) favorites_confirm_messages = { "type": "carousel", "contents": [ deepcopy( self.__insert_favorites_confirm_flex_message( favorite_shop, favorites_confirm_message_template)) for favorite_shop in favorite_shops ] } line_bot_api.reply_message( event.reply_token, FlexSendMessage(alt_text='確認刪除清單', contents=favorites_confirm_messages)) def __handle_quick_reply_action(self, event, line_bot_api): quick_reply_messages = [ QuickReplyButton( action=LocationAction(label='地點查詢', type='location')), QuickReplyButton( action=PostbackAction(label='小幫手愛店', display_text='小幫手愛店', data='topics_kensfavorites')), QuickReplyButton(action=PostbackAction( label='深夜咖啡館', display_text='深夜咖啡館', data='topics_nightcafe')), QuickReplyButton(action=PostbackAction(label='早鳥咖啡館', display_text='早鳥咖啡館', data='topics_morningcafe')), QuickReplyButton(action=PostbackAction(label='寬敞聚會咖啡廳', display_text='寬敞聚會咖啡廳', data='topics_spacious')) ] line_bot_api.reply_message( event.reply_token, TextSendMessage( text='選擇地點查詢開啟google map, 或是選擇其他主題分類', quick_reply=QuickReply(items=quick_reply_messages))) def __handle_topics_postback_action(self, event, line_bot_api): shops = self.shop.get_shops_by_topics(event, self.mongodb) with open('./templates/flexmessage.json') as file: flex_message_template = json.load(file) flex_messages = { "type": "carousel", "contents": [ deepcopy( self.__insert_flex_message(shop, flex_message_template)) for shop in shops ] } line_bot_api.reply_message( event.reply_token, FlexSendMessage(alt_text='店家資訊', contents=flex_messages)) def __insert_flex_message(self, nearby_shop, flex_message_template): flex_message_template['body']['contents'][0]['text'] = nearby_shop[ 'shop_name'] flex_message_template['body']['contents'][1]['contents'][0][ 'contents'][1]['text'] = nearby_shop['address'] flex_message_template['body']['contents'][1]['contents'][1][ 'contents'][1]['text'] = nearby_shop['open_hour'] flex_message_template['body']['contents'][1]['contents'][2][ 'contents'][1]['text'] = nearby_shop['close_date'] flex_message_template['body']['contents'][1]['contents'][3][ 'contents'][1]['text'] = nearby_shop['style'] flex_message_template['body']['contents'][1]['contents'][4][ 'contents'][1]['text'] = nearby_shop['plug_number'] flex_message_template['body']['contents'][1]['contents'][5][ 'contents'][1]['text'] = nearby_shop['space'] flex_message_template['body']['contents'][1]['contents'][6][ 'contents'][1]['text'] = nearby_shop['comment'] flex_message_template['footer']['contents'][0]['action'][ 'uri'] = nearby_shop['map_url'] flex_message_template['footer']['contents'][1]['action'][ 'uri'] = nearby_shop['facebook'] flex_message_template['footer']['contents'][2]['action']['data'] = 'favorite' + \ '_' + nearby_shop['shop_name'] + '_' + str(nearby_shop['_id']) return flex_message_template def __insert_favorites_flex_message(self, favorite_shops, favorites_template): for favorite_shop in favorite_shops: flex_message = { "type": "box", "layout": "vertical", "contents": [{ "type": "text", "text": favorite_shop['shop_name'], "weight": "regular", "size": "sm", "contents": [] }] } favorites_template['body']['contents'].append(flex_message) favorites_template['footer']['contents'][0]['action'][ 'data'] = 'deleteshop' return favorites_template def __insert_favorites_confirm_flex_message( self, favorite_shop, favorites_confirm_message_template): favorites_confirm_message_template['body']['contents'][0][ 'text'] = favorite_shop['shop_name'] favorites_confirm_message_template['footer']['contents'][0]['action'][ 'data'] = str(favorite_shop['_id']) return favorites_confirm_message_template
gf.create_fleet_enemy(background, enemy_group, stats.level) gf.create_fleet(width_background, height_background, wall_group_up, wall_group_down, ground_group, ladder_group, door_group, end_group, traider_group, Wall(False).rect.h) for sprite in wall_group_up: nn = sprite.rect.y break player = Player(screen, screen_rect.centerx, nn) player_group.add(player) play_button = Button(screen, "Play", screen_rect.centerx - 100, screen_rect.centery, (100, 150, 50)) game_over_button = Button(screen, "New", screen_rect.centerx - 100, screen_rect.centery, (100, 150, 50)) quit_button = Button(screen, "quit", screen_rect.centerx - 100, screen_rect.centery + 70, (100, 150, 50)) return_intro_button = Button(screen, "return intro", screen_rect.centerx - 100, screen_rect.centery + 130, (100, 150, 50)) camera = Camera() intro = Intro(screen, stats) shop = Shop(screen, stats) help_image = gf.load_image('help.png') while stats.game_active: # действия с квавиатуры и мыши gf.key_evens(screen, player, bullets, ladder_group, door_group, play_button, game_over_button, camera, stats, intro, background, end_group, enemy_group, wall_group_down, wall_group_up, ground_group, quit_button, return_intro_button, traider_group, shop) if stats.game_intro: # интро игры intro.blit() else: if stats.game_return: # переход через интро gf.new_fleet(screen, background, end_group, enemy_group, wall_group_down, wall_group_up, ladder_group, ground_group, door_group, stats, player, camera, traider_group) stats.game_return = False
from product import Product from shop import Shop from stock import Stock from controller import Controller from model import * from view import * from controller import Stock_Controller # create products bread = Product("bread", 0.80, 10) milk = Product("milk", 0.50, 50) wine = Product("wine", 5.60, 5) # create shop and add products to shop shop = Controller(Model_shop(Shop()), View()) #shop.addItem("bread", 0.80, 10) #shop.addItem("milk", 0.50, 50) #shop.addItem("wine", 5.60, 5) # show items #shop.showItems() # show item #shop.showItem("wine") #shop.updateItem("milk", 1, 10) #shop.deleteItem("milk") #shop.deleteAllItems()
def main(): s = Shop() chosenStore = s.getStore() chosenStore.main()
def __init__(self, CHANNEL_ACCESS_TOKEN, CHANNEL_SECRET, mongodb): self.CHANNEL_ACCESS_TOKEN = CHANNEL_ACCESS_TOKEN self.CHANNEL_SECRET = CHANNEL_SECRET self.mongodb = mongodb self.shop = Shop()
class Discount(Shop): def __init__(self, shop_name, store_type, discount_products): super().__init__( shop_name, store_type, ) self.discount_products = discount_products def get_discounts_products(self): print(self.discount_products) if __name__ == '__main__': # a print('a task') store = Shop('Golden Car', 'used cars trade in') print(store.shop_name) print(store.store_type) store.describe_shop() store.open_shop() # b створіть три різні екзепляри, викличіть метод describe_shop для кожного print('b task') store1 = Shop('shop1', 'trading1') store2 = Shop('shop2', 'trading2') store3 = Shop('shop3', 'trading3') for st in store1, store2, store3: st.describe_shop() # c print('c task')
import tkinter as tk from shop import Shop, Customer # Root window root = tk.Tk() # Option List optionList = ['Hourly', 'Daily', 'Weekly'] # Shop and Customer variables customer = Customer() shop = Shop(stock=10) global when_rented # Switch-like method for getting OptionMenu index def get_list_index(argument): switcher = { 'Hourly': 1, "Daily": 2, "Weekly": 3, } return switcher.get(argument) # return_bike functionality def rent_bike(): global when_rented if bike_entry.get() == "": set_status("Cannot be empty!", "red") # In empty, show status
def canbuy(self, ashop=Shop()): canbuy = [] for (k, v) in ashop.get_prices().items(): if self.fund > v: canbuy.append(k) return canbuy
def __init__(self): global cs print("Hotel init") spa = Spa() cs = CoffeeShop() shop = Shop()
from shop import Shop if __name__ == "__main__": # customer = Customer("Paul", datetime.datetime(1951, 4, 13), "*****@*****.**", "555-555-5555", "email") # sale = Sale() # sale_amount = 1000 # discount = sale.send_discount_message(customer) # print(f"{customer.name} received R{discount*sale_amount} discount on their purchase of R{sale_amount} ") shop = Shop("customers.csv") shop.issue_discounts()
""" Display the product information by URL """ from pprint import pprint if __name__ == "__main__": from shop import Shop shop = Shop("http://some-website") pprint( shop.get_product_info(product_url="/shop/jackets/pxakc9yqe/ghvud8p49"))