def register_item(): #import global variable into function clear() global id_count print_header("REGISTER NEW ITEM") #ask users for object values title = input("Please input the Title: ") category = input("Please input the Category: ") price = float(input("Please input the Price: ")) stock = int(input("Please input the Stock: ")) #assign those values to Item object new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) print(" Item Created!! ") log_line = str(get_time()) + " | REGISTER ITEM | " + str(id) logs.append(str(log_line)) input("\n Press Enter To Return To Main Menu...")
def generate_item(category): item = Item() item.category = category template = util.load_constructor()[category] location = template.pop("location") item.kind = selector.pick_random(template) template = template[item.kind] location += template["location"] names = util.read(location).split("\n") item.name = selector.pick_random(names) return item
def create(self, path, flags, mode): logging.info("Creating File") item = Item(mode | stat.S_IFREG, self.uid, self.gid) fileName, fileExtension = os.path.splitext(path) item.category = self.extensions[fileExtension[1:]] for attr in self.attributes[item.category]: setattr(item, attr, "") #DEFAULT VALUE FOR EACH ATTR IS NULL self.mongo.updateFile(path,item.getMetadata()) self.kv.updateFile(path,item.getData()) self.kv.commit() self._add_to_parent_dir(path)
def register_item(): global id_count print_header("Register New Item: ") title = input("Please input the title: ") category = input("Please input the category: ") price = float(input("Please input a price: ")) stock = int(input("Please input the stock: ")) #validations new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) print(" Item Created!! ")
def register_item(): global id_count print_header("Register New Items") title = input("Core Material?") category = input("To which Hogwarts house does the wand Owner belong?: ") price = float(input("Price in Galleons: ")) stock = int(input("How many wands are currently in stock? ")) new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) print(" Item Created!!")
def register_item(): global last_id header("Register new Item:") title = input("New Item Title: ") category = input("New Item Category: ") price = float(input("New Item Price: ")) stock = int(input("New Item Quantity:")) new_item = Item() # <- create instances of a class (objects) last_id += 1 # No last_id++ new_item.id = last_id new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock catalog.append(new_item) print("Item created!")
def register_item(): global last_id header("Register new Item") title = input("New item title: ") cat = input("New item category: ") price = float(input("New item price: ")) stock = int(input("New item stock: ")) new_item = Item() # <- create instances of a class (objects) last_id += 1 new_item.id = last_id new_item.title = title new_item.category = cat new_item.price = price new_item.stock = stock catalog.append(new_item) add_log_event("NewItem", "Added item: " + str(last_id)) print("Item created!")
def register_item(): global id_count print_header("register new item") title = input("please input the title") category = input("please input the Category: ") price = float(input("please input the Price: ")) stock = int(input("please input the stock: ")) new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) print("Item Created!")
def register_item(): global last_id header("Register new item") title = input("New item name: ") category = input("Item's category: ") price = float(input("Price of item: ")) inventory = int(input("Amount of items: ")) new_item = Item() last_id += 1 new_item.id = last_id new_item.title = title new_item.category = category new_item.price = price new_item.inventory = inventory catalog.append(new_item) add_log_event("New Item", "Added Item: ", +str(last_id)) print("Item has been created...")
def register_item(): global id_count #importing the global variable, into function scope print_header(" Register new Item") title = input("Please input the Title: ") category = input("Please input the Category: ") price = float(input("Please input the Price:")) stock = int(input("Please input the Stock: ")) #validations new_item = Item() new_item.id = id_count id_count += 1 new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock items.append(new_item) print(" Item Created! ")
def register_items(): global id_count # importing the global variables, into fn scope print_header(" ----- Register New Product -----") title = input("Enter Title: ") category = input("Enter Category: ") price = float(input("Enter the Price: ")) stock = int(input("Enter the Stock: ")) # validations new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) print(" Item Created")
def register_item(): global last_id header('Register new item') title = input('New item title: ') cat = input('New item category: ') price = float(input('New item price: ')) stock = int(input('New item stock: ')) new_item = Item() # <- how you create instances of a class (objects) last_id += 1 # no last_id ++ new_item.id = last_id new_item.title = title new_item.category = cat new_item.price = price new_item.stock = stock catalog.append(new_item) add_log_event('New Item', 'Added: ' + str(last_id)) print("Item created!")
def register_item(): global id_count #import the global variable into fn scope print_header(' something') title = input('please input Title: ') category = input('Please input Category: ') price = float(input('Please input price: ')) stock = int(input('Please input stock: ')) #do validations here #create the object new_item = Item() # <- how to create an object of a class new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 catalog.append(new_item) print(" Item created!")
def register_item(): global last_id clear() header("Register an item") title = input("New item title: ") cat = input("New item category: ") price = float(input("New item price: ")) stock = int(input("New item stock: ")) new_item = Item() # how to create new objects last_id += 1 new_item.id = last_id new_item.title = title new_item.category = cat new_item.price = price new_item.stock = stock catalog.append(new_item) add_log_events("New Item", "Added item: " + str(last_id)) print("Item created!")
def register_item(): """ clear() print("-" * 30) print(" Register New Item") print("-" * 30) """ header(" Register new Item") title= input("New item title: ") category = input ("New item category: ") price= float(input ("New item price: ")) stock= int(input("New Item stock: ")) new_item = Item() #Create instances of a class (objects) new_item.id= 0 new_item.title= title new_item.category= category new_item.price= price new_item.stock= stock catalog.append(new_item) print("Item created!")
def parse_itemlist_from_response(json_response, viewmode="", channel="", context="", title_field="title", folder=True): plugintools.log("tvalacarta.api.parse_itemlist_from_response context=" + context) itemlist = [] if not json_response['error']: for entry in json_response['body']: plugintools.log("entry=" + repr(entry)) item = Item(title=entry[title_field]) # TODO: Adaptarlo a clase item if 'plot' in entry: item.plot = entry['plot'] if 'thumbnail' in entry and entry[ 'thumbnail'] is not None and entry['thumbnail'] <> "": item.thumbnail = entry['thumbnail'] if 'fanart' in entry and entry[ 'fanart'] is not None and entry['fanart'] <> "": item.fanart = entry['fanart'] else: item.fanart = item.thumbnail if 'action' in entry: item.action = entry['action'] else: item.action = "play" if 'url' in entry: item.url = entry['url'] elif 'id' in entry: item.url = entry['id'] else: item.url = entry['title'] item.folder = folder item.viewmode = viewmode item.channel = channel if 'channel_name' in entry: item.category = entry['channel_name'] if 'channel_title' in entry: item.channel_title = entry['channel_title'] if 'show_title' in entry: item.show_title = entry['show_title'] if 'channel_id' in entry: item.extra = entry['channel_id'] else: item.extra = "sinchannel" if 'updated_date' in entry: item.date = entry['updated_date'] elif 'episode_date' in entry: item.date = entry['episode_date'] else: item.date = "2016" item.context = context if 'id' in entry: item.id = str(entry['id']) item.uid = str(entry['id']) else: item.id = "" item.uid = "" item.is_favorite = "false" if 'is_favorite' in entry and entry['is_favorite'] == "1": item.is_favorite = "true" if item.is_favorite == "true": item.title = "[COLOR yellow]" + item.title + "[/COLOR]" plugintools.log("item=" + repr(item)) itemlist.append(item) return itemlist
def parse_itemlist_from_response(json_response, viewmode="", channel="", context="", title_field="title", folder=True): plugintools.log("tvalacarta.api.parse_itemlist_from_response context="+context) itemlist = [] if not json_response['error']: for entry in json_response['body']: plugintools.log("entry="+repr(entry)) item = Item(title = entry[title_field]) # TODO: Adaptarlo a clase item if 'plot' in entry: item.plot = entry['plot'] if 'thumbnail' in entry and entry['thumbnail'] is not None and entry['thumbnail']<>"": item.thumbnail = entry['thumbnail'] if 'fanart' in entry and entry['fanart'] is not None and entry['fanart']<>"": item.fanart = entry['fanart'] else: item.fanart = item.thumbnail if 'action' in entry: item.action = entry['action'] else: item.action = "play" if 'url' in entry: item.url = entry['url'] elif 'id' in entry: item.url = entry['id'] else: item.url = entry['title'] item.folder = folder item.viewmode = viewmode item.channel = channel if 'channel_name' in entry: item.category = entry['channel_name'] if 'channel_title' in entry: item.channel_title = entry['channel_title'] if 'show_title' in entry: item.show_title = entry['show_title'] if 'channel_id' in entry: item.extra = entry['channel_id'] else: item.extra = "sinchannel" if 'updated_date' in entry: item.date = entry['updated_date'] elif 'episode_date' in entry: item.date = entry['episode_date'] else: item.date = "2016" item.context = context if 'id' in entry: item.id = str(entry['id']) item.uid = str(entry['id']) else: item.id = "" item.uid = "" item.is_favorite = "false" if 'is_favorite' in entry and entry['is_favorite']=="1": item.is_favorite = "true" if item.is_favorite == "true": item.title = "[COLOR yellow]" + item.title + "[/COLOR]" plugintools.log("item="+repr(item)) itemlist.append( item ) return itemlist
def parse_itemlist_from_response(json_response): plugintools.log("tvalacarta.core.api.parse_itemlist_from_response") itemlist = [] for entry in json_response['body']: plugintools.log("tvalacarta.core.api.parse_itemlist_from_response entry="+repr(entry)) item = Item() if "item_type" in entry: item.item_type = entry['item_type'] if "title" in entry: item.title = entry['title'] if "url" in entry: item.url = entry['url'] if "id" in entry: item.id = entry['id'] if "thumbnail" in entry: item.thumbnail = entry['thumbnail'] if "plot" in entry: item.plot = entry['plot'] if "category" in entry: item.category = entry['category'] if "fanart" in entry: item.fanart = entry['fanart'] if "action" in entry: item.action = entry['action'] if "view" in entry: item.view = entry['view'] if "folder" in entry: item.folder = entry['folder'] if "id" in entry: item.id = entry['id'] if "channel_id" in entry: item.channel_id = entry['channel_id'] if "show_id" in entry: item.show_id = entry['show_id'] if "episode_id" in entry: item.episode_id = entry['episode_id'] if "channel_title" in entry: item.channel_title = entry['channel_title'] if "show_title" in entry: item.show_title = entry['show_title'] if "last_updated" in entry: item.last_updated = entry['last_updated'] if "updated_date" in entry: item.updated_date = entry['updated_date'] if "number_of_programs" in entry: item.number_of_programs = entry['number_of_programs'] if "found_date" in entry: item.found_date = entry['found_date'] if "aired_date" in entry: item.aired_date = entry['aired_date'] if "episode_date" in entry: item.episode_date = entry['episode_date'] if "is_favorite" in entry and entry['is_favorite']==True: item.is_favorite = "true" else: item.is_favorite = "false" if "is_hidden" in entry and entry['is_hidden']==True: item.is_hidden = "true" else: item.is_hidden = "false" if "is_favorite_show" in entry and entry['is_favorite_show']==True: item.is_favorite_show = "true" else: item.is_favorite_show = "false" if "watched" in entry and entry['watched']==True: item.watched = "true" else: item.watched = "false" if "folder" in entry: item.folder = entry['folder'] if item.is_favorite == "true": item.title = "[COLOR yellow]" + item.title + "[/COLOR]" item.channel = "api_programas" plugintools.log("tvalacarta.core.api.parse_itemlist_from_response item="+item.tostring()) itemlist.append( item ) return itemlist
def parse_itemlist_from_response(json_response): plugintools.log("tvalacarta.core.api.parse_itemlist_from_response") itemlist = [] for entry in json_response['body']: plugintools.log( "tvalacarta.core.api.parse_itemlist_from_response entry=" + repr(entry)) item = Item() if "item_type" in entry: item.item_type = entry['item_type'] if "title" in entry: item.title = entry['title'] if "url" in entry: item.url = entry['url'] if "id" in entry: item.id = entry['id'] if "thumbnail" in entry: item.thumbnail = entry['thumbnail'] if "plot" in entry: item.plot = entry['plot'] if "category" in entry: item.category = entry['category'] if "fanart" in entry: item.fanart = entry['fanart'] if "action" in entry: item.action = entry['action'] if "view" in entry: item.view = entry['view'] if "folder" in entry: item.folder = entry['folder'] if "id" in entry: item.id = entry['id'] if "channel_id" in entry: item.channel_id = entry['channel_id'] if "show_id" in entry: item.show_id = entry['show_id'] if "episode_id" in entry: item.episode_id = entry['episode_id'] if "channel_title" in entry: item.channel_title = entry['channel_title'] if "show_title" in entry: item.show_title = entry['show_title'] if "last_updated" in entry: item.last_updated = entry['last_updated'] if "updated_date" in entry: item.updated_date = entry['updated_date'] if "number_of_programs" in entry: item.number_of_programs = entry['number_of_programs'] if "found_date" in entry: item.found_date = entry['found_date'] if "aired_date" in entry: item.aired_date = entry['aired_date'] if "episode_date" in entry: item.episode_date = entry['episode_date'] if "is_favorite" in entry and entry['is_favorite'] == True: item.is_favorite = "true" else: item.is_favorite = "false" if "is_hidden" in entry and entry['is_hidden'] == True: item.is_hidden = "true" else: item.is_hidden = "false" if "is_favorite_show" in entry and entry['is_favorite_show'] == True: item.is_favorite_show = "true" else: item.is_favorite_show = "false" if "watched" in entry and entry['watched'] == True: item.watched = "true" else: item.watched = "false" if "folder" in entry: item.folder = entry['folder'] if item.is_favorite == "true": item.title = "[COLOR yellow]" + item.title + "[/COLOR]" item.channel = "api_programas" plugintools.log( "tvalacarta.core.api.parse_itemlist_from_response item=" + item.tostring()) itemlist.append(item) return itemlist