<commit_before>
from rockit.plugins.razberry import models
from rockit.plugins.razberry import services

class MixesExecutor(object): 

    def collect(self, holder):
        """
        Collect capabilities of this executor
        """

        for c in self._get_then_capabilities():
            holder.mark_resolve_names()
            holder.add_then(**c)

        return holder

    def collect_details(self, identifier, holder):
        """
        Collect details 
        """
        instances = services.RazberryService().retrieve_instances(identifier)

        if instances:
            self.supported = {
                '37': lambda h, c: self._generalize_switch_binary(h, c),
            }

            for key, instance in instances.items():
                self._append_command_details(identifier, holder, instance['commandClasses'])

        return holder

    def _add_capabilities(self, container, identifier, name):
        container.append({
            'identifier': identifier,
            'name': name
            })
    
    def _append_command_details(self, identifier, holder, commandClasses):

        for key in commandClasses:
            command = commandClasses[key]

            if command['supported'] and key in self.supported:
                self.supported[key](holder, command)

    def _generalize_switch_binary(self, holder, command):
        data = {
            'identifier': command['name'],
            'type': 'radio',
            'required': True,
            'label': command['name'],
            'value': ['',True,False]
        }

        holder.add_post(**data)

    def _get_then_capabilities(self):
        result = list()

        nodes = models.Node.objects.exclude(device_type__contains='Controller')

        for node in nodes:
            self._add_capabilities(result, node.device_id, node.device_id)

        return result<commit_msg>Added name for binary switch<commit_after>
from rockit.plugins.razberry import models
from rockit.plugins.razberry import services

class MixesExecutor(object): 

    def collect(self, holder):
        """
        Collect capabilities of this executor
        """

        for c in self._get_then_capabilities():
            holder.mark_resolve_names()
            holder.add_then(**c)

        return holder

    def collect_details(self, identifier, holder):
        """
        Collect details 
        """
        instances = services.RazberryService().retrieve_instances(identifier)

        if instances:
            self.supported = {
                '37': lambda h, c: self._generalize_switch_binary(h, c),
            }

            for key, instance in instances.items():
                self._append_command_details(identifier, holder, instance['commandClasses'])

        return holder

    def _add_capabilities(self, container, identifier, name):
        container.append({
            'identifier': identifier,
            'name': name
            })
    
    def _append_command_details(self, identifier, holder, commandClasses):

        for key in commandClasses:
            command = commandClasses[key]

            if command['supported'] and key in self.supported:
                self.supported[key](holder, command)

    def _generalize_switch_binary(self, holder, command):
        data = {
            'identifier': command['name'],
            'type': 'radio',
            'required': True,
            'label': command['name'],
            'value': ['toggle',True,False]
        }

        holder.add_post(**data)

    def _get_then_capabilities(self):
        result = list()

        nodes = models.Node.objects.exclude(device_type__contains='Controller')

        for node in nodes:
            self._add_capabilities(result, node.device_id, node.device_id)

        return result
{'fraction_non_alphanumeric': 0.09992111490928214, 'fraction_numerical': 0.001051801209571391, 'mean_word_length': 2.162094763092269, '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': '4615364', 'n_tokens_mistral': 994, 'n_tokens_neox': 945, 'n_words': 231}