'Configure and load table from an XML element.'

def configure_and_load(self, config_element, tool_data_path, from_shed_config=False, url_timeout=10):

    self.separator = config_element.get('separator', ' DCTB ')
    self.comment_char = config_element.get('comment_char', '#')
    self.parse_column_spec(config_element)
    repo_elem = config_element.find('tool_shed_repository')
    if (repo_elem is not None):
        repo_info = dict(tool_shed=repo_elem.find('tool_shed').text, name=repo_elem.find('repository_name').text, owner=repo_elem.find('repository_owner').text, installed_changeset_revision=repo_elem.find('installed_changeset_revision').text)
    else:
        repo_info = None
    for file_element in config_element.findall('file'):
        tmp_file = None
        filename = file_element.get('path', None)
        if (filename is None):
            filename = file_element.get('url', None)
            if filename:
                tmp_file = NamedTemporaryFile(prefix=('TTDT_URL_%s-' % self.name))
                try:
                    tmp_file.write(urlopen(filename, timeout=url_timeout).read())
                except Exception as e:
                    log.error('Error    loading    Data    Table    URL    "%s":    %s', filename, e)
                    continue
                log.debug('Loading    Data    Table    URL    "%s"    as    filename    "%s".', filename, tmp_file.name)
                filename = tmp_file.name
                tmp_file.flush()
        filename = file_path = expand_here_template(filename, here=self.here)
        found = False
        if (file_path is None):
            log.debug("Encountered    a    file    element    (%s)    that    does    not    contain    a    path    value    when    loading    tool    data    table    '%s'.", util.xml_to_string(file_element), self.name)
            continue
        if (tool_data_path and from_shed_config):
            filename = os.path.split(file_path)[1]
            filename = os.path.join(tool_data_path, filename)
        if self.tool_data_path_files.exists(filename):
            found = True
        elif (self.tool_data_path_files.exists(('%s.sample' % filename)) and (not from_shed_config)):
            log.info(('Could    not    find    tool    data    %s,    reading    sample' % filename))
            filename = ('%s.sample' % filename)
            found = True
        else:
            (file_path, file_name) = os.path.split(filename)
            if (file_path and (file_path != self.tool_data_path)):
                corrected_filename = os.path.join(self.tool_data_path, file_name)
                if self.tool_data_path_files.exists(corrected_filename):
                    filename = corrected_filename
                    found = True
        errors = []
        if found:
            self.extend_data_with(filename, errors=errors)
            self._update_version()
        else:
            self.missing_index_file = filename
            log.warning(("Cannot    find    index    file    '%s'    for    tool    data    table    '%s'" % (filename, self.name)))
        if ((filename not in self.filenames) or (not self.filenames[filename]['found'])):
            self.filenames[filename] = dict(found=found, filename=filename, from_shed_config=from_shed_config, tool_data_path=tool_data_path, config_element=config_element, tool_shed_repository=repo_info, errors=errors)
        else:
            log.debug("Filename    '%s'    already    exists    in    filenames    (%s),    not    adding", filename, list(self.filenames.keys()))
        if (tmp_file is not None):
            tmp_file.close()
