<commit_before>import logging
from pantsmud.driver import hook
from spacegame import game, login


def open_brain_hook(_, brain):
    logging.debug("brain %r opened" % brain)
    game.get_universe().add_brain(brain)
    brain.push_input_handler(login.login_input_handler, "login")


def close_brain_hook(_, brain):
    logging.debug("brain %r closed" % brain)
    game.get_universe().remove_brain(brain)


def init():
    hook.add(hook.HOOK_OPEN_BRAIN, open_brain_hook)
    hook.add(hook.HOOK_CLOSE_BRAIN, close_brain_hook)<commit_msg>Change handler to remove mobile from universe when brain closes.<commit_after>import logging
from pantsmud.driver import hook
from spacegame import game, login


def open_brain_hook(_, brain):
    logging.debug("brain %r opened" % brain)
    game.get_universe().add_brain(brain)
    brain.push_input_handler(login.login_input_handler, "login")


def close_brain_hook(_, brain):
    logging.debug("brain %r closed" % brain)
    if brain.mobile:
        mobile = brain.mobile
        mobile.detach_brain()
        game.get_universe().remove_mobile(mobile)
    game.get_universe().remove_brain(brain)


def init():
    hook.add(hook.HOOK_OPEN_BRAIN, open_brain_hook)
    hook.add(hook.HOOK_CLOSE_BRAIN, close_brain_hook)
{'fraction_non_alphanumeric': 0.10543130990415335, 'fraction_numerical': 0.0, 'mean_word_length': 4.774193548387097, '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': '6470991', 'n_tokens_mistral': 440, 'n_tokens_neox': 408, 'n_words': 84}