inventory_utilities.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:IC-Inventory 作者: tjschweizer 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号