Display line errors in data table registry display encountered when loading a location file.

This commit is contained in:
Daniel Blankenberg
2014-05-13 16:10:27 -04:00
parent 157812954d
commit 421e88cd05
2 changed files with 13 additions and 8 deletions
+8 -6
View File
@@ -285,8 +285,9 @@ class TabularToolDataTable( ToolDataTable ):
filename = corrected_filename
found = True
errors = []
if found:
self.data.extend( self.parse_file_fields( open( filename ) ) )
self.data.extend( self.parse_file_fields( open( filename ), errors=errors ) )
self._update_version()
else:
self.missing_index_file = filename
@@ -294,7 +295,7 @@ class TabularToolDataTable( ToolDataTable ):
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 )
config_element=config_element, tool_shed_repository=repo_info, errors=errors )
else:
log.debug( "Filename '%s' already exists in filenames (%s), not adding", filename, self.filenames.keys() )
@@ -353,7 +354,7 @@ class TabularToolDataTable( ToolDataTable ):
if 'name' not in self.columns:
self.columns['name'] = self.columns['value']
def parse_file_fields( self, reader ):
def parse_file_fields( self, reader, errors=None ):
"""
Parse separated lines from file and return a list of tuples.
@@ -371,9 +372,10 @@ class TabularToolDataTable( ToolDataTable ):
if self.largest_index < len( fields ):
rval.append( fields )
else:
log.warn( "Line %i in tool data table '%s' is invalid (HINT: "
"'%s' characters must be used to separate fields):\n%s"
% ( ( i + 1 ), self.name, separator_char, line ) )
line_error = "Line %i in tool data table '%s' is invalid (HINT: '%s' characters must be used to separate fields):\n%s" % ( ( i + 1 ), self.name, separator_char, line )
if errors is not None:
errors.append( line_error )
log.warn( line_error )
return rval
def get_column_name_list( self ):
@@ -18,7 +18,7 @@
<th bgcolor="#D8D8D8">Name</th>
<th bgcolor="#D8D8D8">Filename</th>
<th bgcolor="#D8D8D8">Tool data path</th>
<th bgcolor="#D8D8D8">Missing index file</th>
<th bgcolor="#D8D8D8">Errors</th>
</tr>
%for data_table_elem_name, data_table in sorted_data_tables:
%if ctr % 2 == 1:
@@ -35,8 +35,11 @@
<td>${ file_dict.get( 'tool_data_path' ) | h }</td>
<td>
%if not file_dict.get( 'found' ):
missing
file missing
%endif
%for error in file_dict.get( 'errors', [] ):
${ error | h } <br/>
%endfor
</td>
</tr>
%endfor