[GRASS-SVN] r57487 - grass/trunk/lib/python/pygrass
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 23 04:27:52 PDT 2013
Author: zarch
Date: 2013-08-23 04:27:51 -0700 (Fri, 23 Aug 2013)
New Revision: 57487
Modified:
grass/trunk/lib/python/pygrass/functions.py
Log:
Add get_lib_path
Modified: grass/trunk/lib/python/pygrass/functions.py
===================================================================
--- grass/trunk/lib/python/pygrass/functions.py 2013-08-22 10:40:06 UTC (rev 57486)
+++ grass/trunk/lib/python/pygrass/functions.py 2013-08-23 11:27:51 UTC (rev 57487)
@@ -216,3 +216,26 @@
return output
else:
raise ValueError('Raster map does not exist.')
+
+
+def get_lib_path(modname, libname):
+ """Return the path of the libname contained in the module. ::
+
+ >>> get_lib_path(modname='r.modis', libname='libmodis')
+ """
+ from os.path import isdir, join
+ from os import getenv
+
+ if isdir(join(getenv('GISBASE'), 'etc', modname)):
+ path = join(os.getenv('GISBASE'), 'etc', modname)
+ elif getenv('GRASS_ADDON_BASE') and \
+ isdir(join(getenv('GRASS_ADDON_BASE'), 'etc', modname)):
+ path = join(getenv('GRASS_ADDON_BASE'), 'etc', modname)
+ elif getenv('GRASS_ADDON_BASE') and \
+ isdir(join(getenv('GRASS_ADDON_BASE'), modname, modname)):
+ path = join(os.getenv('GRASS_ADDON_BASE'), modname, modname)
+ elif isdir(join('..', libname)):
+ path = join('..', libname)
+ else:
+ path = None
+ return path
More information about the grass-commit
mailing list