commit/galaxy-central: jgoecks: Tool data tables: (a) add spaces between function per PEP8 and (b) add warning when an invalid line is found in tool data table.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2f8989a1a160/ changeset: 2f8989a1a160 user: jgoecks date: 2013-02-13 00:44:06 summary: Tool data tables: (a) add spaces between function per PEP8 and (b) add warning when an invalid line is found in tool data table. affected #: 1 file diff -r 04b8060562f865fa5b3ec6dac4ecfe590bd3ec07 -r 2f8989a1a16001e5dfcded4e0526ef3e2d6f55f9 lib/galaxy/tools/data/__init__.py --- a/lib/galaxy/tools/data/__init__.py +++ b/lib/galaxy/tools/data/__init__.py @@ -158,6 +158,7 @@ def __init__( self, config_element, tool_data_path ): super( TabularToolDataTable, self ).__init__( config_element, tool_data_path ) self.configure_and_load( config_element, tool_data_path ) + def configure_and_load( self, config_element, tool_data_path ): """ Configure and load table from an XML element. @@ -196,11 +197,14 @@ self.missing_index_file = filename log.warn( "Cannot find index file '%s' for tool data table '%s'" % ( filename, self.name ) ) self.data = all_rows + def handle_found_index_file( self, filename ): self.missing_index_file = None self.data.extend( self.parse_file_fields( open( filename ) ) ) + def get_fields( self ): return self.data + def parse_column_spec( self, config_element ): """ Parse column definitions, which can either be a set of 'column' elements @@ -230,14 +234,17 @@ assert 'value' in self.columns, "Required 'value' column missing from column def" if 'name' not in self.columns: self.columns['name'] = self.columns['value'] + def parse_file_fields( self, reader ): """ Parse separated lines from file and return a list of tuples. TODO: Allow named access to fields using the column names. """ + separator_char = (lambda c: '<TAB>' if c == '\t' else c)(self.separator) + rval = [] - for line in reader: + for i, line in enumerate( reader, start=1 ): if line.lstrip().startswith( self.comment_char ): continue line = line.rstrip( "\n\r" ) @@ -245,6 +252,10 @@ fields = line.split( self.separator ) 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, self.name, separator_char, line ) ) return rval def get_entry( self, query_attr, query_val, return_attr ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket