We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Evolving all pokemon after update
### Expected Behavior

Only evolve pokemon in the evolve_list
### Actual Behavior

Evolving all pokemon
### Your FULL config.json (remove your username, password, gmapkey and any other private info)

http://pastebin.com/xZgs68YY
### Output when issue occurred

[2016-08-30 10:20:09] [pokemon_evolved] Evolved Staryu [IV 0.82] [CP 514] [34 candies] [+1000 xp]
### Steps to Reproduce

<!-- Tell us the steps you have taken to reproduce the issue -->
### Other Information

OS: Mac osX
Branch: Dev
Git Commit: d7cf5558e56c9ca9611cec1f228365541f25f2bd
Python Version: Python 2.7.12


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pokemongo_bot/cell_workers/evolve_pokemon.py`
Content:
```
1 from random import uniform
2 
3 from pokemongo_bot import inventory
4 from pokemongo_bot.human_behaviour import sleep
5 from pokemongo_bot.inventory import Pokemon
6 from pokemongo_bot.item_list import Item
7 from pokemongo_bot.base_task import BaseTask
8 from pokemongo_bot.datastore import Datastore
9 
10 
11 class EvolvePokemon(Datastore, BaseTask):
12     SUPPORTED_TASK_API_VERSION = 1
13     def __init__(self, bot, config):
14         super(EvolvePokemon, self).__init__(bot, config)
15 
16     def initialize(self):
17         self.api = self.bot.api
18         self.evolve_list = self.config.get('evolve_list', [])
19         self.donot_evolve_list = self.config.get('donot_evolve_list', [])
20         self.min_evolve_speed = self.config.get('min_evolve_speed', 25)
21         self.max_evolve_speed = self.config.get('max_evolve_speed', 30)
22         self.first_evolve_by = self.config.get('first_evolve_by', 'cp')
23         self.evolve_above_cp = self.config.get('evolve_above_cp', 500)
24         self.evolve_above_iv = self.config.get('evolve_above_iv', 0.8)
25         self.cp_iv_logic = self.config.get('logic', 'or')
26         self.use_lucky_egg = self.config.get('use_lucky_egg', False)
27         self._validate_config()
28 
29     def _validate_config(self):
30         if isinstance(self.evolve_list, basestring):
31             self.evolve_list = [str(pokemon_name).strip() for pokemon_name in self.evolve_list.split(',')]
32             
33         if isinstance(self.donot_evolve_list, basestring):
34             self.donot_evolve_list = [str(pokemon_name).strip() for pokemon_name in self.donot_evolve_list.split(',')]
35 
36         if 'evolve_speed' in self.config:
37             self.logger.warning("evolve_speed is deprecated, instead please use 'min_evolve_speed' and 'max_evolved_speed'.")
38 
39         if 'evolve_all' in self.config:
40             self.logger.warning("evolve_all is deprecated, instead please use 'evolve_list' and 'donot_evolve_list'.")
41 
42     def work(self):
43         if not self._should_run():
44             return
45 
46         filtered_list = self._sort_and_filter()
47 
48         if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none':
49             filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list)
50 
51         cache = {}
52         for pokemon in filtered_list:
53             if pokemon.can_evolve_now():
54                 self._execute_pokemon_evolve(pokemon, cache)
55 
56     def _should_run(self):
57         if not self.evolve_list or self.evolve_list[0] == 'none':
58             return False
59 
60         # Evolve all is used - Use Lucky egg only at the first tick
61         if self.bot.tick_count is not 1 or not self.use_lucky_egg:
62             return True
63 
64         lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value)
65 
66         # Make sure the user has a lucky egg and skip if not
67         if lucky_egg.count > 0:
68             response_dict_lucky_egg = self.bot.use_lucky_egg()
69             if response_dict_lucky_egg:
70                 result = response_dict_lucky_egg.get('responses', {}).get('USE_ITEM_XP_BOOST', {}).get('result', 0)
71                 if result is 1:  # Request success
72                     lucky_egg.remove(1)
73                     self.emit_event(
74                         'used_lucky_egg',
75                         formatted='Used lucky egg ({amount_left} left).',
76                         data={
77                              'amount_left': lucky_egg.count
78                         }
79                     )
80                     return True
81                 else:
82                     self.emit_event(
83                         'lucky_egg_error',
84                         level='error',
85                         formatted='Failed to use lucky egg!'
86                     )
87                     return False
88         else:
89             # Skipping evolve so they aren't wasted
90             self.emit_event(
91                 'skip_evolve',
92                 formatted='Skipping evolve because has no lucky egg.'
93             )
94             return False
95 
96     def _sort_and_filter(self):
97         pokemons = []
98         logic_to_function = {
99             'or': lambda pokemon: pokemon.cp >= self.evolve_above_cp or pokemon.iv >= self.evolve_above_iv,
100             'and': lambda pokemon: pokemon.cp >= self.evolve_above_cp and pokemon.iv >= self.evolve_above_iv
101         }
102 
103         for pokemon in inventory.pokemons().all():
104             if pokemon.unique_id > 0 and pokemon.has_next_evolution() and (logic_to_function[self.cp_iv_logic](pokemon)):
105                 pokemons.append(pokemon)
106 
107         if self.first_evolve_by == "cp":
108             pokemons.sort(key=lambda x: (x.pokemon_id, x.cp, x.iv), reverse=True)
109         else:
110             pokemons.sort(key=lambda x: (x.pokemon_id, x.iv, x.cp), reverse=True)
111 
112         return pokemons
113 
114     def _execute_pokemon_evolve(self, pokemon, cache):
115         if pokemon.name in cache:
116             return False
117 
118         response_dict = self.api.evolve_pokemon(pokemon_id=pokemon.unique_id)
119         if response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('result', 0) == 1:
120             xp = response_dict.get("responses", {}).get("EVOLVE_POKEMON", {}).get("experience_awarded", 0)
121             evolution = response_dict.get("responses", {}).get("EVOLVE_POKEMON", {}).get("evolved_pokemon_data", {})
122             awarded_candies = response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('candy_awarded', 0)
123             candy = inventory.candies().get(pokemon.pokemon_id)
124 
125             candy.consume(pokemon.evolution_cost - awarded_candies)
126 
127             self.emit_event(
128                 'pokemon_evolved',
129                 formatted="Evolved {pokemon} [IV {iv}] [CP {cp}] [{candy} candies] [+{xp} xp]",
130                 data={
131                     'pokemon': pokemon.name,
132                     'iv': pokemon.iv,
133                     'cp': pokemon.cp,
134                     'candy': candy.quantity,
135                     'xp': xp,
136                 }
137             )
138 
139             inventory.pokemons().remove(pokemon.unique_id)
140             new_pokemon = inventory.Pokemon(evolution)
141             inventory.pokemons().add(new_pokemon)
142 
143             sleep(uniform(self.min_evolve_speed, self.max_evolve_speed))
144             evolve_result = True
145         else:
146             # cache pokemons we can't evolve. Less server calls
147             cache[pokemon.name] = 1
148             sleep(0.7)
149             evolve_result = False
150 
151         with self.bot.database as conn:
152             c = conn.cursor()
153             c.execute("SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name='evolve_log'")
154 
155         result = c.fetchone()
156 
157         while True:
158             if result[0] == 1:
159                 conn.execute('''INSERT INTO evolve_log (pokemon, iv, cp) VALUES (?, ?, ?)''', (pokemon.name, pokemon.iv, pokemon.cp))
160                 break
161             else:
162                 self.emit_event(
163                     'evolve_log',
164                     sender=self,
165                     level='info',
166                     formatted="evolve_log table not found, skipping log"
167                 )
168                 break
169 
170         return evolve_result
171
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pokemongo_bot/cell_workers/evolve_pokemon.py b/pokemongo_bot/cell_workers/evolve_pokemon.py
--- a/pokemongo_bot/cell_workers/evolve_pokemon.py
+++ b/pokemongo_bot/cell_workers/evolve_pokemon.py
@@ -45,6 +45,9 @@
 
         filtered_list = self._sort_and_filter()
 
+        if (len(self.evolve_list) > 0) and self.evolve_list[0] != 'all':
+            filtered_list = filter(lambda x: x.name in self.evolve_list, filtered_list)
+
         if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none':
             filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list)

{"golden_diff": "diff --git a/pokemongo_bot/cell_workers/evolve_pokemon.py b/pokemongo_bot/cell_workers/evolve_pokemon.py\n--- a/pokemongo_bot/cell_workers/evolve_pokemon.py\n+++ b/pokemongo_bot/cell_workers/evolve_pokemon.py\n@@ -45,6 +45,9 @@\n \n         filtered_list = self._sort_and_filter()\n \n+        if (len(self.evolve_list) > 0) and self.evolve_list[0] != 'all':\n+            filtered_list = filter(lambda x: x.name in self.evolve_list, filtered_list)\n+\n         if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none':\n             filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list)\n", "issue": "Evolving all pokemon after update\n### Expected Behavior\n\nOnly evolve pokemon in the evolve_list\n### Actual Behavior\n\nEvolving all pokemon\n### Your FULL config.json (remove your username, password, gmapkey and any other private info)\n\nhttp://pastebin.com/xZgs68YY\n### Output when issue occurred\n\n[2016-08-30 10:20:09] [pokemon_evolved] Evolved Staryu [IV 0.82] [CP 514] [34 candies] [+1000 xp]\n### Steps to Reproduce\n\n<!-- Tell us the steps you have taken to reproduce the issue -->\n### Other Information\n\nOS: Mac osX\nBranch: Dev\nGit Commit: d7cf5558e56c9ca9611cec1f228365541f25f2bd\nPython Version: Python 2.7.12\n\n", "before_files": [{"content": "from random import uniform\n\nfrom pokemongo_bot import inventory\nfrom pokemongo_bot.human_behaviour import sleep\nfrom pokemongo_bot.inventory import Pokemon\nfrom pokemongo_bot.item_list import Item\nfrom pokemongo_bot.base_task import BaseTask\nfrom pokemongo_bot.datastore import Datastore\n\n\nclass EvolvePokemon(Datastore, BaseTask):\n    SUPPORTED_TASK_API_VERSION = 1\n    def __init__(self, bot, config):\n        super(EvolvePokemon, self).__init__(bot, config)\n\n    def initialize(self):\n        self.api = self.bot.api\n        self.evolve_list = self.config.get('evolve_list', [])\n        self.donot_evolve_list = self.config.get('donot_evolve_list', [])\n        self.min_evolve_speed = self.config.get('min_evolve_speed', 25)\n        self.max_evolve_speed = self.config.get('max_evolve_speed', 30)\n        self.first_evolve_by = self.config.get('first_evolve_by', 'cp')\n        self.evolve_above_cp = self.config.get('evolve_above_cp', 500)\n        self.evolve_above_iv = self.config.get('evolve_above_iv', 0.8)\n        self.cp_iv_logic = self.config.get('logic', 'or')\n        self.use_lucky_egg = self.config.get('use_lucky_egg', False)\n        self._validate_config()\n\n    def _validate_config(self):\n        if isinstance(self.evolve_list, basestring):\n            self.evolve_list = [str(pokemon_name).strip() for pokemon_name in self.evolve_list.split(',')]\n            \n        if isinstance(self.donot_evolve_list, basestring):\n            self.donot_evolve_list = [str(pokemon_name).strip() for pokemon_name in self.donot_evolve_list.split(',')]\n\n        if 'evolve_speed' in self.config:\n            self.logger.warning(\"evolve_speed is deprecated, instead please use 'min_evolve_speed' and 'max_evolved_speed'.\")\n\n        if 'evolve_all' in self.config:\n            self.logger.warning(\"evolve_all is deprecated, instead please use 'evolve_list' and 'donot_evolve_list'.\")\n\n    def work(self):\n        if not self._should_run():\n            return\n\n        filtered_list = self._sort_and_filter()\n\n        if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none':\n            filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list)\n\n        cache = {}\n        for pokemon in filtered_list:\n            if pokemon.can_evolve_now():\n                self._execute_pokemon_evolve(pokemon, cache)\n\n    def _should_run(self):\n        if not self.evolve_list or self.evolve_list[0] == 'none':\n            return False\n\n        # Evolve all is used - Use Lucky egg only at the first tick\n        if self.bot.tick_count is not 1 or not self.use_lucky_egg:\n            return True\n\n        lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value)\n\n        # Make sure the user has a lucky egg and skip if not\n        if lucky_egg.count > 0:\n            response_dict_lucky_egg = self.bot.use_lucky_egg()\n            if response_dict_lucky_egg:\n                result = response_dict_lucky_egg.get('responses', {}).get('USE_ITEM_XP_BOOST', {}).get('result', 0)\n                if result is 1:  # Request success\n                    lucky_egg.remove(1)\n                    self.emit_event(\n                        'used_lucky_egg',\n                        formatted='Used lucky egg ({amount_left} left).',\n                        data={\n                             'amount_left': lucky_egg.count\n                        }\n                    )\n                    return True\n                else:\n                    self.emit_event(\n                        'lucky_egg_error',\n                        level='error',\n                        formatted='Failed to use lucky egg!'\n                    )\n                    return False\n        else:\n            # Skipping evolve so they aren't wasted\n            self.emit_event(\n                'skip_evolve',\n                formatted='Skipping evolve because has no lucky egg.'\n            )\n            return False\n\n    def _sort_and_filter(self):\n        pokemons = []\n        logic_to_function = {\n            'or': lambda pokemon: pokemon.cp >= self.evolve_above_cp or pokemon.iv >= self.evolve_above_iv,\n            'and': lambda pokemon: pokemon.cp >= self.evolve_above_cp and pokemon.iv >= self.evolve_above_iv\n        }\n\n        for pokemon in inventory.pokemons().all():\n            if pokemon.unique_id > 0 and pokemon.has_next_evolution() and (logic_to_function[self.cp_iv_logic](pokemon)):\n                pokemons.append(pokemon)\n\n        if self.first_evolve_by == \"cp\":\n            pokemons.sort(key=lambda x: (x.pokemon_id, x.cp, x.iv), reverse=True)\n        else:\n            pokemons.sort(key=lambda x: (x.pokemon_id, x.iv, x.cp), reverse=True)\n\n        return pokemons\n\n    def _execute_pokemon_evolve(self, pokemon, cache):\n        if pokemon.name in cache:\n            return False\n\n        response_dict = self.api.evolve_pokemon(pokemon_id=pokemon.unique_id)\n        if response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('result', 0) == 1:\n            xp = response_dict.get(\"responses\", {}).get(\"EVOLVE_POKEMON\", {}).get(\"experience_awarded\", 0)\n            evolution = response_dict.get(\"responses\", {}).get(\"EVOLVE_POKEMON\", {}).get(\"evolved_pokemon_data\", {})\n            awarded_candies = response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('candy_awarded', 0)\n            candy = inventory.candies().get(pokemon.pokemon_id)\n\n            candy.consume(pokemon.evolution_cost - awarded_candies)\n\n            self.emit_event(\n                'pokemon_evolved',\n                formatted=\"Evolved {pokemon} [IV {iv}] [CP {cp}] [{candy} candies] [+{xp} xp]\",\n                data={\n                    'pokemon': pokemon.name,\n                    'iv': pokemon.iv,\n                    'cp': pokemon.cp,\n                    'candy': candy.quantity,\n                    'xp': xp,\n                }\n            )\n\n            inventory.pokemons().remove(pokemon.unique_id)\n            new_pokemon = inventory.Pokemon(evolution)\n            inventory.pokemons().add(new_pokemon)\n\n            sleep(uniform(self.min_evolve_speed, self.max_evolve_speed))\n            evolve_result = True\n        else:\n            # cache pokemons we can't evolve. Less server calls\n            cache[pokemon.name] = 1\n            sleep(0.7)\n            evolve_result = False\n\n        with self.bot.database as conn:\n            c = conn.cursor()\n            c.execute(\"SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name='evolve_log'\")\n\n        result = c.fetchone()\n\n        while True:\n            if result[0] == 1:\n                conn.execute('''INSERT INTO evolve_log (pokemon, iv, cp) VALUES (?, ?, ?)''', (pokemon.name, pokemon.iv, pokemon.cp))\n                break\n            else:\n                self.emit_event(\n                    'evolve_log',\n                    sender=self,\n                    level='info',\n                    formatted=\"evolve_log table not found, skipping log\"\n                )\n                break\n\n        return evolve_result\n", "path": "pokemongo_bot/cell_workers/evolve_pokemon.py"}], "after_files": [{"content": "from random import uniform\n\nfrom pokemongo_bot import inventory\nfrom pokemongo_bot.human_behaviour import sleep\nfrom pokemongo_bot.inventory import Pokemon\nfrom pokemongo_bot.item_list import Item\nfrom pokemongo_bot.base_task import BaseTask\nfrom pokemongo_bot.datastore import Datastore\n\n\nclass EvolvePokemon(Datastore, BaseTask):\n    SUPPORTED_TASK_API_VERSION = 1\n    def __init__(self, bot, config):\n        super(EvolvePokemon, self).__init__(bot, config)\n\n    def initialize(self):\n        self.api = self.bot.api\n        self.evolve_list = self.config.get('evolve_list', [])\n        self.donot_evolve_list = self.config.get('donot_evolve_list', [])\n        self.min_evolve_speed = self.config.get('min_evolve_speed', 25)\n        self.max_evolve_speed = self.config.get('max_evolve_speed', 30)\n        self.first_evolve_by = self.config.get('first_evolve_by', 'cp')\n        self.evolve_above_cp = self.config.get('evolve_above_cp', 500)\n        self.evolve_above_iv = self.config.get('evolve_above_iv', 0.8)\n        self.cp_iv_logic = self.config.get('logic', 'or')\n        self.use_lucky_egg = self.config.get('use_lucky_egg', False)\n        self._validate_config()\n\n    def _validate_config(self):\n        if isinstance(self.evolve_list, basestring):\n            self.evolve_list = [str(pokemon_name).strip() for pokemon_name in self.evolve_list.split(',')]\n            \n        if isinstance(self.donot_evolve_list, basestring):\n            self.donot_evolve_list = [str(pokemon_name).strip() for pokemon_name in self.donot_evolve_list.split(',')]\n\n        if 'evolve_speed' in self.config:\n            self.logger.warning(\"evolve_speed is deprecated, instead please use 'min_evolve_speed' and 'max_evolved_speed'.\")\n\n        if 'evolve_all' in self.config:\n            self.logger.warning(\"evolve_all is deprecated, instead please use 'evolve_list' and 'donot_evolve_list'.\")\n\n    def work(self):\n        if not self._should_run():\n            return\n\n        filtered_list = self._sort_and_filter()\n\n        if (len(self.evolve_list) > 0) and self.evolve_list[0] != 'all':\n            filtered_list = filter(lambda x: x.name in self.evolve_list, filtered_list)\n\n        if (len(self.donot_evolve_list) > 0) and self.donot_evolve_list[0] != 'none':\n            filtered_list = filter(lambda pokemon: pokemon.name not in donot_evolve_list, filtered_list)\n\n        cache = {}\n        for pokemon in filtered_list:\n            if pokemon.can_evolve_now():\n                self._execute_pokemon_evolve(pokemon, cache)\n\n    def _should_run(self):\n        if not self.evolve_list or self.evolve_list[0] == 'none':\n            return False\n\n        # Evolve all is used - Use Lucky egg only at the first tick\n        if self.bot.tick_count is not 1 or not self.use_lucky_egg:\n            return True\n\n        lucky_egg = inventory.items().get(Item.ITEM_LUCKY_EGG.value)\n\n        # Make sure the user has a lucky egg and skip if not\n        if lucky_egg.count > 0:\n            response_dict_lucky_egg = self.bot.use_lucky_egg()\n            if response_dict_lucky_egg:\n                result = response_dict_lucky_egg.get('responses', {}).get('USE_ITEM_XP_BOOST', {}).get('result', 0)\n                if result is 1:  # Request success\n                    lucky_egg.remove(1)\n                    self.emit_event(\n                        'used_lucky_egg',\n                        formatted='Used lucky egg ({amount_left} left).',\n                        data={\n                             'amount_left': lucky_egg.count\n                        }\n                    )\n                    return True\n                else:\n                    self.emit_event(\n                        'lucky_egg_error',\n                        level='error',\n                        formatted='Failed to use lucky egg!'\n                    )\n                    return False\n        else:\n            # Skipping evolve so they aren't wasted\n            self.emit_event(\n                'skip_evolve',\n                formatted='Skipping evolve because has no lucky egg.'\n            )\n            return False\n\n    def _sort_and_filter(self):\n        pokemons = []\n        logic_to_function = {\n            'or': lambda pokemon: pokemon.cp >= self.evolve_above_cp or pokemon.iv >= self.evolve_above_iv,\n            'and': lambda pokemon: pokemon.cp >= self.evolve_above_cp and pokemon.iv >= self.evolve_above_iv\n        }\n\n        for pokemon in inventory.pokemons().all():\n            if pokemon.unique_id > 0 and pokemon.has_next_evolution() and (logic_to_function[self.cp_iv_logic](pokemon)):\n                pokemons.append(pokemon)\n\n        if self.first_evolve_by == \"cp\":\n            pokemons.sort(key=lambda x: (x.pokemon_id, x.cp, x.iv), reverse=True)\n        else:\n            pokemons.sort(key=lambda x: (x.pokemon_id, x.iv, x.cp), reverse=True)\n\n        return pokemons\n\n    def _execute_pokemon_evolve(self, pokemon, cache):\n        if pokemon.name in cache:\n            return False\n\n        response_dict = self.api.evolve_pokemon(pokemon_id=pokemon.unique_id)\n        if response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('result', 0) == 1:\n            xp = response_dict.get(\"responses\", {}).get(\"EVOLVE_POKEMON\", {}).get(\"experience_awarded\", 0)\n            evolution = response_dict.get(\"responses\", {}).get(\"EVOLVE_POKEMON\", {}).get(\"evolved_pokemon_data\", {})\n            awarded_candies = response_dict.get('responses', {}).get('EVOLVE_POKEMON', {}).get('candy_awarded', 0)\n            candy = inventory.candies().get(pokemon.pokemon_id)\n\n            candy.consume(pokemon.evolution_cost - awarded_candies)\n\n            self.emit_event(\n                'pokemon_evolved',\n                formatted=\"Evolved {pokemon} [IV {iv}] [CP {cp}] [{candy} candies] [+{xp} xp]\",\n                data={\n                    'pokemon': pokemon.name,\n                    'iv': pokemon.iv,\n                    'cp': pokemon.cp,\n                    'candy': candy.quantity,\n                    'xp': xp,\n                }\n            )\n\n            inventory.pokemons().remove(pokemon.unique_id)\n            new_pokemon = inventory.Pokemon(evolution)\n            inventory.pokemons().add(new_pokemon)\n\n            sleep(uniform(self.min_evolve_speed, self.max_evolve_speed))\n            evolve_result = True\n        else:\n            # cache pokemons we can't evolve. Less server calls\n            cache[pokemon.name] = 1\n            sleep(0.7)\n            evolve_result = False\n\n        with self.bot.database as conn:\n            c = conn.cursor()\n            c.execute(\"SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name='evolve_log'\")\n\n        result = c.fetchone()\n\n        while True:\n            if result[0] == 1:\n                conn.execute('''INSERT INTO evolve_log (pokemon, iv, cp) VALUES (?, ?, ?)''', (pokemon.name, pokemon.iv, pokemon.cp))\n                break\n            else:\n                self.emit_event(\n                    'evolve_log',\n                    sender=self,\n                    level='info',\n                    formatted=\"evolve_log table not found, skipping log\"\n                )\n                break\n\n        return evolve_result\n", "path": "pokemongo_bot/cell_workers/evolve_pokemon.py"}]}