Hello Peter, Thanks very much for this - I'm sure many will find it very helpful. I've applied your patch to changeset revision 8096:0c56502c7fd7, which will be included in the next Galaxy release currently scheduled for next Friday (not today's currently scheduled release).
Thanks again, Greg Von Kuster On Oct 22, 2012, at 7:03 AM, Peter Cock wrote: > FAO the Galaxy dev team, > > I've tested a patch (at end of email) which issues a warning if loading > a loc file with inconsistent numbers of tabs. In the case of blastdb_p.loc > this would result in showing the warning three times, since currently > Galaxy appears to reload a *.loc file for each tool using it. > > (If the error happens to be on the first list, then the warning is triggered > for all the following lines in the file - because they won't have the same > number of fields as the first line.) > > Could someone apply this to the trunk as is, or tell me if you would > prefer it as a pull request on bitbucket? > > Furthermore, would a more invasive change to treat this as an error > condition be acceptable? > > Thanks, > > Peter > > > On Sun, Oct 21, 2012 at 5:53 AM, Fields, Christopher J > <cjfie...@illinois.edu> wrote: >> Yes, have to agree there, an error would be more informative. >> >> chris >> >> On Oct 20, 2012, at 2:38 PM, Shane Sturrock <sh...@biomatters.com> wrote: >> >>> That would certainly have saved me a fair bit of time since the only >>> indication I got was an empty set of quotes in the error log. I always >>> feel like tabs aren't the best separators for these sorts of files anyway >>> since they are usually invisible but since that isn't likely to change, >>> making it more obvious what the problem is would be the best approach. >>> >>> Shane >>> >>> On 21/10/2012, at 1:44 AM, Peter Cock wrote: >>>> >>>> Another idea would be for Galaxy to issue a clear error if a loc file has >>>> an inconsistent number of fields/tabs per line. >>>> >>>> Peter >>>> > > Suggested patch: > > $ hg diff lib/galaxy/tools/parameters/dynamic_options.py > diff -r c05a680cbc80 lib/galaxy/tools/parameters/dynamic_options.py > --- a/lib/galaxy/tools/parameters/dynamic_options.py Fri Oct 19 > 15:56:51 2012 +0100 > +++ b/lib/galaxy/tools/parameters/dynamic_options.py Mon Oct 22 > 11:59:04 2012 +0100 > @@ -471,6 +471,7 @@ > > 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,17 @@ > 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 > > ___________________________________________________________ > Please keep all replies on the list by using "reply all" > in your mail client. To manage your subscriptions to this > and other Galaxy lists, please use the interface at: > > http://lists.bx.psu.edu/ ___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at: http://lists.bx.psu.edu/