[GRASS-dev] python function to get the path to the GRASS configuration directory
Pietro
peter.zamb at gmail.com
Mon Feb 15 01:09:34 PST 2016
On Fri, Feb 12, 2016 at 4:01 PM, Anna Petrášová <kratochanna at gmail.com> wrote:
> On Fri, Feb 12, 2016 at 4:43 AM, Pietro <peter.zamb at 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
More information about the grass-dev
mailing list