[GRASS-dev] python function to get the path to the GRASS configuration directory

Dear devs,

The GRASS's configuration directory change from grass version and
depending by OS in use as explained here:

https://grasswiki.osgeo.org/wiki/GRASS_configuration_files_in_home_directory

I wonder if already exist somewhere C/Python API a function that
return the right path.

Any idea?
All the best

Pietro

On Fri, Feb 12, 2016 at 4:43 AM, Pietro <peter.zamb@gmail.com> wrote:

Dear devs,

The GRASS's configuration directory change from grass version and
depending by OS in use as explained here:

https://grasswiki.osgeo.org/wiki/GRASS_configuration_files_in_home_directory

I wonder if already exist somewhere C/Python API a function that
return the right path.

In gui/wxpython/core/utils:
https://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/core/utils.py#L795

But we should consider moving it into grass/script/utils.py or similar.

Anna

Any idea?
All the best

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

On Fri, Feb 12, 2016 at 4:01 PM, Anna Petrášová <kratochanna@gmail.com> wrote:

On Fri, Feb 12, 2016 at 4:43 AM, Pietro <peter.zamb@gmail.com> wrote:

https://grasswiki.osgeo.org/wiki/GRASS_configuration_files_in_home_directory

I wonder if already exist somewhere C/Python API a function that
return the right path.

In gui/wxpython/core/utils:
https://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/core/utils.py#L795

But we should consider moving it into grass/script/utils.py or similar.

Indeed I think would be useful to clearly distinguish the GUI from
other functionalities.
And would also fix things like:

{{{# gui/wxpython/core/toolboxes.py:53
def GetSettingsPath():
    # this is for cases during compilation and it is not possible to import wx
    # TODO: if the function would be in the grass Python library there would
    # no need to do this
    try:
        from core.utils import GetSettingsPath as actualGetSettingsPath
        return actualGetSettingsPath()
    except ImportError:
        # expecting that there will be no such path
        # (these files are always check for existence here)
        return ""
}}}

So how to proceed? Should I move this function to grass.script.utils
and then just import the function definition in
gui/wxpython/core/utils.py?

Should I just fix all the following imports in the GRASS source code:

{{{
gui/wxpython/gui_core/gselect.py:69:from core.utils import
GetSettingsPath, GetValidLayerName, ListSortLower
gui/wxpython/web_services/dialogs.py:35:from core.utils import
GetSettingsPath, _
gui/wxpython/core/settings.py:29:from core.utils import
GetSettingsPath, PathJoin, rgb2str, _
}}}

What do you think?

Pietro

On Mon, Feb 15, 2016 at 4:09 AM, Pietro <peter.zamb@gmail.com> wrote:

So how to proceed? Should I move this function to grass.script.utils
and then just import the function definition in
gui/wxpython/core/utils.py?

Since the name will change (I think it should change), perhaps this option
is better as it will limit the change just to utils.py. I currently don't
see any benefit in propagating the new import and name everywhere. But you
can perhaps obsolete the GUI wrapper in documentation.