[GRASS-dev] inconsistency between G_OPT_V_INPUT and G_OPT_R_INPUT

Dear all,

I found an inconsistency of behaviors between G_OPT_R_INPUT and
G_OPT_V_INPUT, here the test code:

{{{
#!/usr/bin/env python
# -- coding: utf-8 --
#%module
#% description: Test
#% keywords: test
#%end
#%option G_OPT_R_INPUT
#% key: discharge
#% description: Name of river discharge [m3/s]
#% required: yes
#%end
#%option G_OPT_V_INPUT
#% key: river
#% key_desc: name
#% description: Name of vector map with interested segments of rivers
#% required: yes
#%end
from __future__ import print_function
import sys

# import grass libraries
from grass.script import core as gcore

def main(opts, flgs):
    print(opts, flgs)

if __name__ == "__main__":
    options, flags = gcore.parser()
    sys.exit(main(options, flags))
}}}

here is the output of the manual page:

{{{
python r.example.py --help

Description:
Test

Keywords:
test

Usage:
r.example.py discharge=name river=name [--help] [--verbose] [--quiet]
   [--ui]

Flags:
--h Print usage summary
--v Verbose module output
--q Quiet module output
--ui Force launching GUI dialog

Parameters:
  discharge Name of river discharge [m3/s]
      river Name of input vector map
               Name of vector map with interested segments of rivers
}}}

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

The behavior concerning the GUI is worst, because it shows only the
default description string, see attached figure.

What do you think?

Pietro

(attachments)

r_example_gui.png

* Pietro <peter.zamb@gmail.com> [2015-05-13 08:03:04 +0200]:

Dear all,

I found an inconsistency of behaviors between G_OPT_R_INPUT and
G_OPT_V_INPUT, here the test code:

{{{
#!/usr/bin/env python
# -- coding: utf-8 --
#%module
#% description: Test
#% keywords: test
#%end
#%option G_OPT_R_INPUT
#% key: discharge
#% description: Name of river discharge [m3/s]
#% required: yes
#%end
#%option G_OPT_V_INPUT
#% key: river
#% key_desc: name
#% description: Name of vector map with interested segments of rivers
#% required: yes
#%end
from __future__ import print_function
import sys

# import grass libraries
from grass.script import core as gcore

def main(opts, flgs):
    print(opts, flgs)

if __name__ == "__main__":
    options, flags = gcore.parser()
    sys.exit(main(options, flags))
}}}

here is the output of the manual page:

{{{
python r.example.py --help

Description:
Test

Keywords:
test

Usage:
r.example.py discharge=name river=name [--help] [--verbose] [--quiet]
   [--ui]

Flags:
--h Print usage summary
--v Verbose module output
--q Quiet module output
--ui Force launching GUI dialog

Parameters:
  discharge Name of river discharge [m3/s]
      river Name of input vector map
               Name of vector map with interested segments of rivers
}}}

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

The behavior concerning the GUI is worst, because it shows only the
default description string, see attached figure.

What do you think?

Pietro,

What if you place the 'key_desc' instruction in G_OPT_R_INPUT too?

Nikos

Hi,

2015-05-13 8:03 GMT+02:00 Pietro <peter.zamb@gmail.com>:

#% description: Name of vector map with interested segments of rivers

<- label

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

right, G_OPT_V_INPUT has defined both label and description [1]. This
the source of inconsistency. There are more standard options which
defines both label and description.

Martin

[1] http://grass.osgeo.org/programming7/parser__standard__options_8c_source.html#l00442

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

Hi Martin,

On Wed, May 13, 2015 at 11:08 AM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2015-05-13 8:03 GMT+02:00 Pietro <peter.zamb@gmail.com>:

#% description: Name of vector map with interested segments of rivers

<- label

Therefore I should use label instead of description, something like:

{{{
#!/usr/bin/env python
# -- coding: utf-8 --
#%module
#% description: Test
#% keywords: test
#%end
#%option G_OPT_R_INPUT
#% key: discharge
#% label: Name of river discharge [m3/s]
#% required: yes
#%end
#%option G_OPT_V_INPUT
#% key: river
#% label: Name of vector map with interested segments of rivers
#% required: yes
#%end
from __future__ import print_function
import sys

# import grass libraries
from grass.script import core as gcore

def main(opts, flgs):
    print(opts, flgs)

if __name__ == "__main__":
    options, flags = gcore.parser()
    sys.exit(main(options, flags))
}}}

The GUI is now fine and the command output looks:

{{{$ r.example --h

Description:
Test

Keywords:
test

Usage:
r.example discharge=name river=name [--help] [--verbose] [--quiet]
   [--ui]

Flags:
--h Print usage summary
--v Verbose module output
--q Quiet module output
--ui Force launching GUI dialog

Parameters:
  discharge Name of river discharge [m3/s]
               Name of input raster map
      river Name of vector map with interested segments of rivers
               Or data source for direct OGR access
}}}

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

right, G_OPT_V_INPUT has defined both label and description [1]. This
the source of inconsistency. There are more standard options which
defines both label and description.

Do you think this inconsistency should be fix, or just reported
somewhere on a Wiki page?

All the best.

Pietro

On Wed, May 13, 2015 at 9:47 AM, Pietro <peter.zamb@gmail.com> wrote:

Hi Martin,

On Wed, May 13, 2015 at 11:08 AM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2015-05-13 8:03 GMT+02:00 Pietro <peter.zamb@gmail.com>:

#% description: Name of vector map with interested segments of rivers

← label

Therefore I should use label instead of description, something like:

{{{
#!/usr/bin/env python

– coding: utf-8 –

#%module
#% description: Test
#% keywords: test
#%end
#%option G_OPT_R_INPUT
#% key: discharge
#% label: Name of river discharge [m3/s]
#% required: yes
#%end
#%option G_OPT_V_INPUT
#% key: river
#% label: Name of vector map with interested segments of rivers
#% required: yes
#%end
from future import print_function
import sys

import grass libraries

from grass.script import core as gcore

def main(opts, flgs):
print(opts, flgs)

if name == “main”:
options, flags = gcore.parser()
sys.exit(main(options, flags))
}}}

The GUI is now fine and the command output looks:

{{{$ r.example --h

Description:
Test

Keywords:
test

Usage:
r.example discharge=name river=name [–help] [–verbose] [–quiet]
[–ui]

Flags:
–h Print usage summary
–v Verbose module output
–q Quiet module output
–ui Force launching GUI dialog

Parameters:
discharge Name of river discharge [m3/s]
Name of input raster map
river Name of vector map with interested segments of rivers
Or data source for direct OGR access
}}}

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

right, G_OPT_V_INPUT has defined both label and description [1]. This
the source of inconsistency. There are more standard options which
defines both label and description.

Do you think this inconsistency should be fix, or just reported
somewhere on a Wiki page?

Perhaps all standard options should define both label and description and you can then modify whatever suits you. (I often end up setting both.)

In the future, we should revise this anyway, like move from description to label as the primary one or making both mandatory.

All the best.

Pietro


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

On Wed, May 13, 2015 at 10:14 AM, Vaclav Petras <wenzeslaus@gmail.com> wrote:

On Wed, May 13, 2015 at 9:47 AM, Pietro <peter.zamb@gmail.com> wrote:

On Wed, May 13, 2015 at 11:08 AM, Martin Landa <landa.martin@gmail.com> wrote:

2015-05-13 8:03 GMT+02:00 Pietro <peter.zamb@gmail.com>:

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

right, G_OPT_V_INPUT has defined both label and description [1]. This
the source of inconsistency. There are more standard options which
defines both label and description.

Do you think this inconsistency should be fix, or just reported
somewhere on a Wiki page?

Perhaps all standard options should define both label and description and you can then modify whatever suits you. (I often end up setting both.)

In the future, we should revise this anyway, like move from description to label as the primary one or making both mandatory.

See also Standard options label vs description from Huidae Cho:

http://lists.osgeo.org/pipermail/grass-dev/2014-June/069313.html
http://osgeo-org.1560.x6.nabble.com/Standard-options-label-vs-description-td5144023.html

Vaclav

I think we still need to fix it.

···

On Thu, May 21, 2015 at 11:15 AM, Vaclav Petras <wenzeslaus@gmail.com> wrote:

On Wed, May 13, 2015 at 10:14 AM, Vaclav Petras <wenzeslaus@gmail.com> wrote:

On Wed, May 13, 2015 at 9:47 AM, Pietro <peter.zamb@gmail.com> wrote:

On Wed, May 13, 2015 at 11:08 AM, Martin Landa <landa.martin@gmail.com> wrote:

2015-05-13 8:03 GMT+02:00 Pietro <peter.zamb@gmail.com>:

As you can see the description of the parameter add the default
description set in G_OPT_V_INPUT and in a new line the description
added manually in the definition of the module parameters. Instead the
G_OPT_R_INPUT shows only the description set manually.

right, G_OPT_V_INPUT has defined both label and description [1]. This
the source of inconsistency. There are more standard options which
defines both label and description.

Do you think this inconsistency should be fix, or just reported
somewhere on a Wiki page?

Perhaps all standard options should define both label and description and you can then modify whatever suits you. (I often end up setting both.)

In the future, we should revise this anyway, like move from description to label as the primary one or making both mandatory.

See also Standard options label vs description from Huidae Cho:

http://lists.osgeo.org/pipermail/grass-dev/2014-June/069313.html
http://osgeo-org.1560.x6.nabble.com/Standard-options-label-vs-description-td5144023.html

Vaclav


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev