[GRASS-dev] Default content for the "answer" to G_OPT_F_INPUT

Vaclav Petras wenzeslaus at gmail.com
Tue Apr 17 07:41:18 PDT 2018


Hi Nikos,

I'm sorry if my comment is out of topic as I'm not following the whole
discussion, but can you just hardcode the values in the code and allow them
to be overridden by the user-specified file? That is much simpler (for both
user and GRASS) than handling paths and if the file is short, it does not
raise major code cleanness concern. If people need to edit the file, then
documentation is the appropriate place.

Vaclav

On Tue, Apr 17, 2018 at 10:32 AM, Nikos Alexandris <nik at nikosalexandris.net>
wrote:

>
>
> Le Mardi 17 avril 2018, Markus Metz a écrit :
> > On Tue, Apr 17, 2018 at 4:21 PM, Nikos Alexandris <
> nik at nikosalexandris.net>
> > wrote:
> > >
> > > * Moritz Lennert <mlennert at club.worldonline.be> [2018-04-17 15:56:10
> > +0200]:
> > >
> > >> On 17/04/18 15:31, Nikos Alexandris wrote:
> > >>>
> > >>> Dear developers,
> > >>>
> > >>> is there a way to set a string as the content of a default "answer"
> for
> > >>> the G_OPT_F_INPUT option? I am trying to identify potential cases in
> the
> > >>> grass-addons repository, but I am not sure I have seen something
> > related.
> > >>>
> > >>> The G_OPT_F_INPUT offers a field to enter a filename. The default
> > >>> "answer", for the parser, will be the name of the file.
> > >>>
> > >>> In addition, a field to "enter values directly" is created. The
> > >>> description of this field is: "Enter file content directly instead of
> > >>> specifying a file. Temporary file will be automatically created."
> > >>>
> > >>> Can this field be filled with a pre-defined content?
> > >>> The use case is to expose, to the user, a pre-defined set of
> > >>> reclassification rules. These will help a beginner to get started,
> > >>> understand easier and modify rules as he sees fit.
> > >>
> > >>
> > >> Use the 'answer' parameter:
> > >>
> > >> #% answer : myfilename
> > >>
> > >> Moritz
> > >
> > >
> > > It works: it loads the content of an external file. Are we forced to
> use
> > > external files in such a case? Which means an extra file has to be
> > > shipped with the source code.
> > > Can we not use an in-script hardcoded string for example?
> >
> > Be aware that you can't use a hardcoded full path, because depending on
> the
> > installation/user/os, that path may or may not exist. If you use a
> relative
> > path, that path is relative to the current working directory which is of
> > course not constant between sessions/installation/user/os. I'm afraid a
> > default answer to G_OPT_F_INPUT will cause a lot of trouble.
> >
> > my2c
> >
> > Markus M
>
> Ciao Markus.
>
> Yet my intention was/is to use a hardcoded string of rules. Not a path to
> a file.
>
> It appears the only option is to document, the rules, and suggest a copy
> and paste in to the corresponding field.
>
> Can the parser be extended in this regard with yet another option? Perhaps
> I missed some existing option (?).
>
> Thank you Markus, Nikos
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180417/93e29262/attachment-0001.html>


More information about the grass-dev mailing list