def addToInventory(self, octoPart, quantity):
"""
Adds quantity of Octopart to the inventory. Performs a searchInventory to determine if part is already in
inventory, then either adds the part to the inventory or simply updates the quantity if the part already
exists.
:param octoPart: Octopart object to add
:type octoPart: octo_utils.Octopart
:param quantity: Quantity of part to add to inventory
:type quantity: int
:return: None
:rtype: None
"""
index = self.searchInventory(octoPart)
if index == -1:
octoPart.quantity = quantity
self.inventory.append(octoPart)
else:
self.inventory[index].quantity += quantity
self.saveInventory()
if octoPart.dataFile:
request.urlretrieve(octoPart.dataURL, octoPart.dataFile)
评论列表
文章目录