Load the module with the tool-specific code.

def load_tool(result):
    """
    Load the module with the tool-specific code.
    """
    def load_tool_module(tool_module):
        if not tool_module:
            logging.warning('Cannot extract values from log files for benchmark results %s '
                            '(missing attribute "toolmodule" on tag "result").',
                            Util.prettylist(result.attributes['name']))
            return None
        try:
            logging.debug('Loading %s', tool_module)
            return __import__(tool_module, fromlist=['Tool']).Tool()
        except ImportError as ie:
            logging.warning(
                'Missing module "%s", cannot extract values from log files (ImportError: %s).',
                tool_module, ie)
        except AttributeError:
            logging.warning(
                'The module "%s" does not define the necessary class Tool, '
                'cannot extract values from log files.',
                tool_module)
        return None

    tool_module = result.attributes['toolmodule'][0] if 'toolmodule' in result.attributes else None
    if tool_module in loaded_tools:
        return loaded_tools[tool_module]
    else:
        result = load_tool_module(tool_module)
        loaded_tools[tool_module] = result
        return result