<commit_before>import evdev
from evdev import ecodes
import pifacecad
import threading
import atexit


class InputDevice():
    mapping = [
    ecodes.KEY_LEFT,
    ecodes.KEY_RIGHT,
    ecodes.KEY_HOME,
    ecodes.KEY_END,
    ecodes.KEY_DELETE,
    ecodes.KEY_KPENTER,
    ecodes.KEY_UP,
    ecodes.KEY_DOWN]
    
    def __init__(self, name='piface-uinput'):
        self.name = name
        self.uinput = evdev.UInput(name=name, devnode='/dev/uinput')
        self.cad = pifacecad.PiFaceCAD()
        self.listener = pifacecad.SwitchEventListener(chip=self.cad)
        atexit.register(self.listener.deactivate)
        for i in range(8):
            self.listener.register(i, pifacecad.IODIR_FALLING_EDGE, self.press_key)
    
    def start(self):
        self.listener.activate()

    def stop(self):
        self.listener.deactivate()

    def press_key(self, event):
        key = self.mapping[event.pin_num]
        self.uinput.write(ecodes.EV_KEY, key, 1)
        self.uinput.write(ecodes.EV_KEY, key, 0)
        self.uinput.syn()

    def activate(self):
        self.thread = threading.Thread(target=self.start)
        self.thread.daemon = False
        self.thread.start()

    def deactivate(self):
       self.stop()

    def __del__(self):
       self.deactivate()<commit_msg>Removing deactivate() function from input drivers<commit_after>import evdev
from evdev import ecodes
import pifacecad
import threading
import atexit


class InputDevice():
    mapping = [
    ecodes.KEY_LEFT,
    ecodes.KEY_RIGHT,
    ecodes.KEY_HOME,
    ecodes.KEY_END,
    ecodes.KEY_DELETE,
    ecodes.KEY_KPENTER,
    ecodes.KEY_UP,
    ecodes.KEY_DOWN]
    
    def __init__(self, name='piface-uinput'):
        self.name = name
        self.uinput = evdev.UInput(name=name, devnode='/dev/uinput')
        self.cad = pifacecad.PiFaceCAD()
        self.listener = pifacecad.SwitchEventListener(chip=self.cad)
        atexit.register(self.listener.deactivate)
        for i in range(8):
            self.listener.register(i, pifacecad.IODIR_FALLING_EDGE, self.press_key)
    
    def start(self):
        self.listener.activate()

    def stop(self):
        self.listener.deactivate()

    def press_key(self, event):
        key = self.mapping[event.pin_num]
        self.uinput.write(ecodes.EV_KEY, key, 1)
        self.uinput.write(ecodes.EV_KEY, key, 0)
        self.uinput.syn()

    def activate(self):
        self.thread = threading.Thread(target=self.start)
        self.thread.daemon = False
        self.thread.start()

    def __del__(self):
       self.deactivate()
{'fraction_non_alphanumeric': 0.11024844720496894, 'fraction_numerical': 0.002329192546583851, 'mean_word_length': 2.65014164305949, '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': '3811458', 'n_tokens_mistral': 892, 'n_tokens_neox': 866, 'n_words': 149}