'Create and return an ElementTree tool Element.'

def generate_tool_elem(self, tool_shed, repository_name, changeset_revision, owner, tool_file_path, tool, tool_section):

    if (tool_section is not None):
        tool_elem = XmlET.SubElement(tool_section, 'tool')
    else:
        tool_elem = XmlET.Element('tool')
    tool_elem.attrib['file'] = tool_file_path
    if (not tool.guid):
        raise ValueError('tool    has    no    guid')
    tool_elem.attrib['guid'] = tool.guid
    tool_shed_elem = XmlET.SubElement(tool_elem, 'tool_shed')
    tool_shed_elem.text = tool_shed
    repository_name_elem = XmlET.SubElement(tool_elem, 'repository_name')
    repository_name_elem.text = repository_name
    repository_owner_elem = XmlET.SubElement(tool_elem, 'repository_owner')
    repository_owner_elem.text = owner
    changeset_revision_elem = XmlET.SubElement(tool_elem, 'installed_changeset_revision')
    changeset_revision_elem.text = changeset_revision
    id_elem = XmlET.SubElement(tool_elem, 'id')
    id_elem.text = tool.id
    version_elem = XmlET.SubElement(tool_elem, 'version')
    version_elem.text = tool.version
    return tool_elem
