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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 29 16:25:41 EDT 2011


Author: martinl
Date: 2011-09-29 13:25:41 -0700 (Thu, 29 Sep 2011)
New Revision: 48560

Modified:
   grass/trunk/scripts/g.extension/g.extension.py
Log:
g.extension: fix addons html pages (modify links)


Modified: grass/trunk/scripts/g.extension/g.extension.py
===================================================================
--- grass/trunk/scripts/g.extension/g.extension.py	2011-09-29 20:01:31 UTC (rev 48559)
+++ grass/trunk/scripts/g.extension/g.extension.py	2011-09-29 20:25:41 UTC (rev 48560)
@@ -371,7 +371,7 @@
     
     if ret != 0:
         grass.fatal(_('Compilation failed, sorry. Please check above error messages.'))
-    
+
     if flags['i'] or options['extension'] in gui_list:
         return
     
@@ -384,7 +384,31 @@
         grass.warning(_('Installation failed, sorry. Please check above error messages.'))
     else:
         grass.message(_("Installation of '%s' successfully finished.") % options['extension'])
-
+    
+    # manual page: fix href
+    if os.getenv('GRASS_ADDON_PATH'):
+        html_man = os.path.join(os.getenv('GRASS_ADDON_PATH'), 'docs', 'html', options['extension'] + '.html')
+        if os.path.exists(html_man):
+            fd = open(html_man)
+            html_str = '\n'.join(fd.readlines())
+            fd.close()
+            for rep in ('grassdocs.css', 'grass_logo.png'):
+                patt = re.compile(rep, re.IGNORECASE)
+                html_str = patt.sub(os.path.join(gisbase, 'docs', 'html', rep),
+                                    html_str)
+                
+            patt = re.compile(r'(<a href=")(d|db|g|i|m|p|ps|r|r3|s|v|wxGUI)(\.)(.+)(.html">)', re.IGNORECASE)
+            while True:
+                m = patt.search(html_str)
+                if not m:
+                    break
+                html_str = patt.sub(m.group(1) + os.path.join(gisbase, 'docs', 'html',
+                                                              m.group(2) + m.group(3) + m.group(4)) + m.group(5),
+                                    html_str, count = 1)
+            fd = open(html_man, "w")
+            fd.write(html_str)
+            fd.close()
+    
     if not os.environ.has_key('GRASS_ADDON_PATH') or \
             not os.environ['GRASS_ADDON_PATH']:
         grass.warning(_('This add-on module will not function until you set the '



More information about the grass-commit mailing list