<commit_before>#!/usr/bin/env python

from flexbe_core.proxy import ProxySubscriberCached
from flexbe_core import EventState, Logger
from sara_msgs.msg import Entities
from geometry_msgs.msg import Pose
from tf.transformations import euler_from_quaternion

import math


class list_found_entities(EventState):
    '''
        will list entities seen by the camera

        -- frontality_level        float
        #> found_entities          object
        #< name                    string

        <= found            entities are found
        <= not_found        no one is found

    '''

    def __init__(self, frontality_level):
        '''
        Constructor
        '''
        super(list_found_entities, self).__init__(outcomes=['found', 'not_found'], output_keys=['list_found_entities', 'number'], input_keys=['name'])
        self._sub = ProxySubscriberCached({'/entities': Entities})

        self._topic = "/robot_pose"
        self._subpos = ProxySubscriberCached({self._topic: Pose})
        self.frontality_level = frontality_level
        self.mypose = None
        self.message = None


    def execute(self, userdata):

        if self._subpos.has_msg(self._topic):
            self.mypose = userdata.pose = self._subpos.get_last_msg(self._topic)

        if self._sub.has_msg('/entities'):
            Logger.loginfo('getting message')
            self.message = self._sub.get_last_msg('/entities')
            self._sub.remove_last_msg('/entities')

        if self.message is not None and self.mypose is not None:
            found_entities = self.list(userdata.name)
            userdata.list_found_entities = found_entities
            userdata.number = len(found_entities)

            if len(found_entities) != 0:
                return 'found'
            else:
                return 'not_found'

    def list(self, name):
        found_entities = []
        wraps = []
        for entity in self.message.entities:
            if entity.name == name:
                wrap = wrapper()
                wrap.init(self.mypose, entity, self.frontality_level)

                wraps.append(wrap)

        wraps.sort(key=wrapper.key)

        for wrap in wraps:
            found_entities.append(wrap.entity)

        return found_entities


class wrapper():
    def init(self, mypose, entity, frontality_level):
<commit_msg>retour de state list_entities by name<commit_after>#!/usr/bin/env python

from flexbe_core.proxy import ProxySubscriberCached
from flexbe_core import EventState, Logger
from sara_msgs.msg import Entities
from geometry_msgs.msg import Pose
from tf.transformations import euler_from_quaternion

import math


class list_entities_by_name(EventState):
    '''
        will list entities seen by the camera

        -- frontality_level        float
        #> found_entities          object
        #< name                    string

        <= found            entities are found
        <= not_found        no one is found

    '''

    def __init__(self, frontality_level):
        '''
        Constructor
        '''
        super(list_entities_by_name, self).__init__(outcomes=['found', 'not_found'], output_keys=['list_entities_by_name', 'number'], input_keys=['name'])
        self._sub = ProxySubscriberCached({'/entities': Entities})

        self._topic = "/robot_pose"
        self._subpos = ProxySubscriberCached({self._topic: Pose})
        self.frontality_level = frontality_level
        self.mypose = None
        self.message = None


    def execute(self, userdata):

        if self._subpos.has_msg(self._topic):
            self.mypose = userdata.pose = self._subpos.get_last_msg(self._topic)

        if self._sub.has_msg('/entities'):
            Logger.loginfo('getting message')
            self.message = self._sub.get_last_msg('/entities')
            self._sub.remove_last_msg('/entities')

        if self.message is not None and self.mypose is not None:
            found_entities = self.list(userdata.name)
            userdata.list_entities_by_name = found_entities
            userdata.number = len(found_entities)

            if len(found_entities) != 0:
                return 'found'
            else:
                return 'not_found'

    def list(self, name):
        found_entities = []
        wraps = []
        for entity in self.message.entities:
            if entity.name == name:
                wrap = wrapper()
                wrap.init(self.mypose, entity, self.frontality_level)

                wraps.append(wrap)

        wraps.sort(key=wrapper.key)

        for wrap in wraps:
            found_entities.append(wrap.entity)

        return found_entities


class wrapper():
    def init(self, mypose, entity, frontality_level):

{'fraction_non_alphanumeric': 0.09356477561388654, 'fraction_numerical': 0.0004233700254022015, 'mean_word_length': 2.1839622641509435, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '2653394', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1341, 'n_words': 295}