[GRASS-dev] pygrass - stdout2dict

Hi,

pygrass manual uses stdout2dict() [1] which doesn't seems to be
available. Martin

[1] http://grass.osgeo.org/grass70/manuals/libpython/pygrass_modules.html

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Tue, Apr 7, 2015 at 11:10 AM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

pygrass manual uses stdout2dict() [1] which doesn't seems to be
available. Martin

[1] http://grass.osgeo.org/grass70/manuals/libpython/pygrass_modules.html

While I don't know the solution, there were to related comments:

http://lists.osgeo.org/pipermail/grass-user/2014-October/071144.html
http://lists.osgeo.org/pipermail/grass-user/2014-October/071150.html

Markus

Hi Martin,

On Tue, Apr 7, 2015 at 11:10 AM, Martin Landa <landa.martin@gmail.com> wrote:

pygrass manual uses stdout2dict() [1] which doesn't seems to be
available.

[1] http://grass.osgeo.org/grass70/manuals/libpython/pygrass_modules.html

You are right the function has not been defined... probably I can
simply update the docstring adding the function, something like:

{{{
def stdout2dict(stdout):
    return dict([kv.split('=') for kv in stdout.strip().split('\n')])
}}}

or with lambda

{{{
stdout2dict = lambda x: dict([i.split('=') for i in x.strip().split('\n')])
}}}

Best regards

Pietro

2015-04-07 12:58 GMT+02:00 Pietro <peter.zamb@gmail.com>:

You are right the function has not been defined... probably I can
simply update the docstring adding the function, something like:

{{{
def stdout2dict(stdout):
    return dict([kv.split('=') for kv in stdout.strip().split('\n')])
}}}

or with lambda

{{{
stdout2dict = lambda x: dict([i.split('=') for i in x.strip().split('\n')])
}}}

hm, is there any way how to parse command output using pygrass without
need to define your own function?

Thanks, Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Tue, Apr 7, 2015 at 1:05 PM, Martin Landa <landa.martin@gmail.com> wrote:

hm, is there any way how to parse command output using pygrass without
need to define your own function?

Why not use: parse_key_val(s, sep='=', dflt=None, val_type=None, vsep=None)

define in grass.script.utils?

2015-04-07 13:28 GMT+02:00 Pietro <peter.zamb@gmail.com>:

On Tue, Apr 7, 2015 at 1:05 PM, Martin Landa <landa.martin@gmail.com> wrote:

hm, is there any way how to parse command output using pygrass without
need to define your own function?

Why not use: parse_key_val(s, sep='=', dflt=None, val_type=None, vsep=None)

define in grass.script.utils?

you are right, are you planning to update pygrass manual? Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Tue, Apr 7, 2015 at 1:54 PM, Martin Landa <landa.martin@gmail.com> wrote:

you are right, are you planning to update pygrass manual? Martin

done in r65015

Pietro

2015-04-07 14:09 GMT+02:00 Pietro <peter.zamb@gmail.com>:

done in r65015

Thanks, Martin

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa