[GRASS-user] GRASS'c Python core function to use as g.mlist

Jenny Turner jennyturner1980 at gmail.com
Mon Mar 14 11:00:49 EDT 2011


Hello Ricardo
Thanks for your feedback but the problem is that mapset cannot be used as
input.
Because I got this error:
p=grass.mlist_grouped ('rast', pattern=pattern,
mapset='PERMANENT')
TypeError: mlist_grouped() got an unexpected keyword
argument 'mapset'.
If I avoid using mapset I get a dictionary variable in which, each entry is
the list of rasters for each MAPSET.

Am I doing something wrong?
Thanks
Jenny

On Fri, Mar 11, 2011 at 2:29 PM, Ricardo Filipe Soares Garcia da <
ricardo.garcia.silva at gmail.com> wrote:

> Hi Jenny
>
> Long story short: use your command like this (note the asterisk on the
> 'pattern' variable):
>
> # python code
> p=grass.mlist_grouped ('rast', pattern='output*', mapset='Mapping')
>
>
> I am using the Ipython shell to script grass. It has a cool feature,
> that if you type the name of a function followed by two question
> marks, you can see the source code of the function (as long as it is
> coded in python itself).
> So, in doing:
>
> grass.mlist_grouped??
>
> It is possible to see that the mlist_grouped function is internally
> calling the 'g.mlist' command with only the 'm' flag.
>
> Reading the documentation for the g.mlist command [1], I realize that,
> without using the -r or -e flags, this command accepts wildcards[2] as
> the 'pattern' string. The asterisk (*) is the wildcard character for
> substituting for any zero or more characters. So, in order to get a
> string that starts with 'output' and after that can have anything, you
> just type 'output*'
>
>
> [1] - http://grass.fbk.eu/grass64/manuals/html64_user/g.mlist.html
> [2] - http://en.wikipedia.org/wiki/Wildcard_character#Computing
>
>
> On Fri, Mar 11, 2011 at 12:10 PM, Jenny Turner
> <jennyturner1980 at gmail.com> wrote:
> > Greetings
> > I'm doing a GRASS Python Script where I need to list a set of raster maps
> > but I'm not using its exact name but a basic regular expression (r flag
> in
> > g.mlist function).
> > So I want to find a list of rasters with output on its name:
> > p=grass.mlist_grouped ('rast', pattern='output', mapset='Mapping')
> > But I get null entries because no raster map is named output only
> output01
> > output02 output03 ...
> > I want to list all raster maps with output on itsd name. How can I do
> this
> > using grass.mlist_grouped?
> > Thanks
> > Jenny
> > _______________________________________________
> > grass-user mailing list
> > grass-user at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/grass-user
> >
> >
>
>
>
> --
> ___________________________ ___ __
> Ricardo Garcia Silva
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20110314/16106d67/attachment.html


More information about the grass-user mailing list