[GRASS-dev] [GRASS GIS] #2605: d.rast.leg: invalid literal for float(): rectangle

#2605: d.rast.leg: invalid literal for float(): rectangle
-------------------------+--------------------------------------------------
Reporter: pertusus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.1
Component: Display | Version: svn-releasebranch70
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
I get a traceback for d.rast.leg.
{{{
d.rast.leg raster_selection_basins_change lines=2
}}}
{{{
Traceback (most recent call last):
   File "/usr/local/grass-7.0.0svn//scripts/d.rast.leg", line 167, in
<module>
     main()
   File "/usr/local/grass-7.0.0svn//scripts/d.rast.leg", line 103, in main
     f = tuple([float(x) for x in s.split()[1:5]])
ValueError: invalid literal for float(): rectangle:
}}}

This is triggered by a wrong parsing of d.info which returns:

{{{
frame rectangle: 0.000000 640.000000 0.000000 480.000000
}}}
Original code is
   [float(x) for x in s.split()[1:5]]
which naturally the to x being 'rectangle:'

I attach a patch where I propose instead:
  [float(x) for x in s.split(":")[1].split()[0:4]]
It seems more robust, though I don't know if the : will be there forever.
Overall, the approach is not very robust, but I have no idea on what's
going on so I only propose that fix which may not be appropriate in other
cases.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2605&gt;
GRASS GIS <http://grass.osgeo.org>