<commit_before>from pokemongo_bot import logger
from pokemongo_bot.cell_workers.utils import fort_details
from pokemongo_bot.cell_workers.pokemon_catch_worker import PokemonCatchWorker
from pokemongo_bot.cell_workers.base_task import BaseTask

class CatchLuredPokemon(BaseTask):
    def work(self):
        lured_pokemon = self.get_lured_pokemon()
        if lured_pokemon:
            self.catch_pokemon(lured_pokemon)

    def get_lured_pokemon(self):
        forts = self.bot.get_forts(order_by_distance=True)

        if len(forts) == 0:
            return False

        fort = forts[0]
        details = fort_details(self.bot, fort_id=fort['id'],
                              latitude=fort['latitude'],
                              longitude=fort['longitude'])
        fort_name = details.get('name', 'Unknown').encode('utf8', 'replace')

        encounter_id = fort.get('lure_info', {}).get('encounter_id', None)

        if encounter_id:
            logger.log('Lured pokemon at fort {}'.format(fort['id']))
            return {
                'encounter_id': encounter_id,
                'fort_id': fort['id'],
                'latitude': fort['latitude'],
                'longitude': fort['longitude']
            }

        return False

    def catch_pokemon(self, pokemon):
        worker = PokemonCatchWorker(pokemon, self.bot)
        return_value = worker.work()

        return return_value<commit_msg>Change FortID to FortName (#2249)<commit_after>from pokemongo_bot import logger
from pokemongo_bot.cell_workers.utils import fort_details
from pokemongo_bot.cell_workers.pokemon_catch_worker import PokemonCatchWorker
from pokemongo_bot.cell_workers.base_task import BaseTask

class CatchLuredPokemon(BaseTask):
    def work(self):
        lured_pokemon = self.get_lured_pokemon()
        if lured_pokemon:
            self.catch_pokemon(lured_pokemon)

    def get_lured_pokemon(self):
        forts = self.bot.get_forts(order_by_distance=True)

        if len(forts) == 0:
            return False

        fort = forts[0]
        details = fort_details(self.bot, fort_id=fort['id'],
                              latitude=fort['latitude'],
                              longitude=fort['longitude'])
        fort_name = details.get('name', 'Unknown').encode('utf8', 'replace')

        encounter_id = fort.get('lure_info', {}).get('encounter_id', None)

        if encounter_id:
            logger.log('Lured pokemon at fort {}'.format(fort_name))
            return {
                'encounter_id': encounter_id,
                'fort_id': fort['id'],
                'latitude': fort['latitude'],
                'longitude': fort['longitude']
            }

        return False

    def catch_pokemon(self, pokemon):
        worker = PokemonCatchWorker(pokemon, self.bot)
        return_value = worker.work()

        return return_value
{'fraction_non_alphanumeric': 0.10498779211719568, 'fraction_numerical': 0.003487966515521451, 'mean_word_length': 2.434730538922156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3011748', 'n_tokens_mistral': 891, 'n_tokens_neox': 856, 'n_words': 157}