From 1575b76cee1781bf012fe10672e8082485bc0254 Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Wed, 24 Oct 2012 11:44:32 -0400 Subject: [PATCH] Apply patch from Peter Cock which issues a warning if loading a loc file with inconsistent numbers of tabs. --- lib/galaxy/tools/parameters/dynamic_options.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/galaxy/tools/parameters/dynamic_options.py b/lib/galaxy/tools/parameters/dynamic_options.py index 53a48621206..7d1bb0551fd 100644 --- a/lib/galaxy/tools/parameters/dynamic_options.py +++ b/lib/galaxy/tools/parameters/dynamic_options.py @@ -471,6 +471,7 @@ class DynamicOptions( object ): def parse_file_fields( self, reader ): rval = [] + field_count = None for line in reader: if line.startswith( '#' ) or ( self.line_startswith and not line.startswith( self.line_startswith ) ): continue @@ -478,6 +479,16 @@ class DynamicOptions( object ): if line: fields = line.split( self.separator ) if self.largest_index < len( fields ): + if not field_count: + field_count = len( fields ) + elif field_count != len( fields ): + try: + name = reader.name + except AttributeError: + name = "a configuration file" + # Perhaps this should be an error, but even a warning is useful. + log.warn( "Inconsistent number of fields (%i vs %i) in %s using separator %r, check line: %r" % \ + ( field_count, len( fields ), name, self.separator, line ) ) rval.append( fields ) return rval