コード例 #1
0
def _create_component(name, component_type, command):

    component_class = EntityRegister.get_component(component_type)
    component = component_class(name, command)

    component.load_defaults()

    for attr_name in component.store().values().keys():        
        if attr_name in non_attributes:
            continue
        attr = EntityRegister.get_attribute(component_type, attr_name)
        if not attr:
            raise NotFound("Invalid attribute `{}` for component "
                           "{}. Maybe Missspelled?"
                           .format(attr_name, component.entity()))
        component.add_attribute(attr(component))

    # check if component is correctly initialized
    component.validate()
    return component