[GRASS-SVN] r46757 - grass/trunk/scripts/g.extension

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 23 07:20:53 EDT 2011


Author: martinl
Date: 2011-06-23 04:20:53 -0700 (Thu, 23 Jun 2011)
New Revision: 46757

Modified:
   grass/trunk/scripts/g.extension/g.extension.py
Log:
g.extension: support multiple GRASS_ADDONS_PATH values


Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2011-06-22 13:38:39 UTC (rev 46756)
+++ grass/trunk/scripts/g.extension/g.extension.py	2011-06-23 11:20:53 UTC (rev 46757)
@@ -416,10 +416,17 @@
     if options['prefix'] == '$GRASS_ADDON_PATH':
         if not os.environ.has_key('GRASS_ADDON_PATH') or \
                 not os.environ['GRASS_ADDON_PATH']:
-            grass.warning(_("GRASS_ADDON_PATH is not defined, installing to ~/.grass7/addons/"))
-            options['prefix'] = os.path.join(os.environ['HOME'], '.grass7', 'addons')
+            major_version = int(grass.version()['version'].split('.', 1)[0])
+            grass.warning(_("GRASS_ADDON_PATH is not defined, "
+                            "installing to ~/.grass%d/addons/") % major_version)
+            options['prefix'] = os.path.join(os.environ['HOME'], '.grass%d' % major_version, 'addons')
         else:
-            options['prefix'] = os.environ['GRASS_ADDON_PATH']
+            path_list = os.environ['GRASS_ADDON_PATH'].split(os.pathsep)
+            if len(path_list) < 1:
+                grass.fatal(_("Invalid GRASS_ADDON_PATH value - '%s'") % os.environ['GRASS_ADDON_PATH'])
+            if len(path_list) > 1:
+                grass.warning(_("GRASS_ADDON_PATH has more items, using first defined - '%s'") % path_list[0])
+            options['prefix'] = path_list[0]
     
     # check dirs
     check_dirs()



More information about the grass-commit mailing list