def generate_default_slots(atom_type='_NO_VALUE_', atom_subtype='user'):
    """
    Generate the slots that are common to every Atom.

    :param str atom_type: Type of the atom
    :param str atom_subtype: Subtype of te atom. Defaults to 'user'
    :return: Yields the default VarSlots
    :rtype: VarSlot
    """
    yield VarSlot(name="type", val=atom_type)
    yield VarSlot(name="subtype", val=atom_subtype)
    yield VarSlot(name="timestamp", val="_NO_VALUE_", type="number")
    yield VarSlot(name="consumed", val="false", type="string")
def slot_from_bool(b, slotname, slottype='string'):
    """
    Produce a VarSlot from a boolean.

    Example:
        >>> next(slot_from_bool(False, 'a_boolean_slot'))
        name: a_boolean_slot
        relation: ''
        val: false
        type: string
        unique_mask: False
    """
    yield VarSlot(name=slotname, val=str(b).lower(), type=slottype)
def slot_from_string(string, slotname, slottype='string'):
    """
    Produce a VarSlot from a string.

    Example:

        >>> next(slot_from_string('the_slot_value', 'the_slot_name'))
        name: the_slot_name
        relation: ''
        val: the_slot_value
        type: string
        unique_mask: False
    """
    yield VarSlot(name=slotname, val=string, type=slottype)
    def setUp(self):

        hand = 'left'
        event = 'learn'
        self.event_msg = EventHandler(hand=hand, event=event, last_event=event)

        self.def_slots = [VarSlot(name="type", val='event_handler'),
                          VarSlot(name="subtype", val='user'),
                          VarSlot(name="timestamp", val="_NO_VALUE_",
                                  type="number"),
                          VarSlot(name="consumed", val="false", type="string")]
        self.event_slots = \
            [VarSlot(name="hand", val=hand, type="string"),
             VarSlot(name="event", val=event, type="string"),
             VarSlot(name="last_event", val=event, type="string")]

        self.event_handler_atom = \
            AtomMsg(list(chain(self.def_slots, self.event_slots)))
def slot_from_iter(arr, slotname, slottype='string'):
    """Produce a Varslot from an iterable.

    Example:

    >>> next(slot_from_iter([1, 2, 3, 4], 'an_array_slot'))
    name: an_array_slot
    relation: ''
    val: 1|2|3|4
    type: string
    unique_mask: False

    >>> strings = ['an_str', 'another_str', 'third_str']
    >>> next(slot_from_iter(strings, slotname='an_array_slot_with_strings'))
    name: an_array_slot_with_strings
    relation: ''
    val: an_str|another_str|third_str
    type: string
    unique_mask: False

    """
    slot_value = '|'.join(str(item) for item in arr)
    yield VarSlot(name=slotname, val=slot_value, type=slottype)
def slot_from_num(num, slotname, slottype='number'):
    """
    Produce a VarSlot from an num.

    It accepts int and float.

    Example:

        >>> next(slot_from_num(123, 'an_int_slot'))
        name: an_int_slot
        relation: ''
        val: 123
        type: number
        unique_mask: False

        >>> next(slot_from_num(0.12345, 'a_float_slot'))
        name: a_float_slot
        relation: ''
        val: 0.12345
        type: number
        unique_mask: False
    """
    yield VarSlot(name=slotname, val=str(num), type=slottype)
def generate_learned_object_slots(learned_msg):
    """Generate the slots for the ObjectDescriptor Messages."""
    yield VarSlot(name="object", val=learned_msg.name, type="string")
    yield VarSlot(name="id2D", val=str(learned_msg.id2D), type="number")
    yield VarSlot(name="id3D", val=str(learned_msg.id3D), type="number")
def generate_object_name_slots(string_msg):
    """Generate the slots for the object_name Atom."""
    yield VarSlot(name="object_name", val=string_msg.data, type="string")
def generate_google_asr_slots(asr_msg):
    """Generate the slots for the Atoms corresponding Goolge ASR messages."""
    yield VarSlot(name="content", val=asr_msg.content, type="string")
    yield VarSlot(name="confidence", val=str(asr_msg.confidence), type="number")
    yield VarSlot(name="languageID", val=str(asr_msg.languageID), type="number")
def generate_user_command_slots(user_command):
    """Generate the slots for the OCULAR's user_command atom."""
    yield VarSlot(name="command", val=user_command, type="string")
def generate_event_handler_slots(event_msg):
    """Generate the slots for the OCULAR's event_handler_atom."""
    yield VarSlot(name="hand", val=event_msg.hand, type="string")
    yield VarSlot(name="event", val=event_msg.event, type="string")
    yield VarSlot(name="last_event", val=event_msg.last_event, type="string")