PokemonGo-Bot icon indicating copy to clipboard operation
PokemonGo-Bot copied to clipboard

[Bug] Error when trying to get the count of an item with new inventory manager

Open BriceSD opened this issue 10 years ago • 0 comments

@aeckert @douglascamata #2528

Expected Behavior

Returning the count of the specified item in inventory

Actual Behavior

  File "C:\Users\KaliMist\Desktop\PycharmProjects\PokemonGo-Bot\pokemongo_bot\cell_workers\recycle_items.py", line 93, in __init__self.amount_in_inventory = inventory.items().count_for(self.id)
  File "C:\Users\KaliMist\Desktop\PycharmProjects\PokemonGo-Bot\pokemongo_bot\inventory.py", line 102, in count_for
    return self._data[item_id]['count']
KeyError: 'count'

Steps to Reproduce

Try to use the function inventory.items().count_fort(item_id)

How I fixed it

I changed :

        return self._data[item_id]['count']

Into :

        return self._data[item_id].get('count', False)

Other Information

OS: Windows 7 Python Version: Python 2.7.10

BriceSD avatar Aug 09 '16 10:08 BriceSD