Przeglądaj źródła

g.extension: fix addons html pages (modify links)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48560 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 lat temu
rodzic
commit
b154b8e828
1 zmienionych plików z 26 dodań i 2 usunięć
  1. 26 2
      scripts/g.extension/g.extension.py

+ 26 - 2
scripts/g.extension/g.extension.py

@@ -371,7 +371,7 @@ def install_extension():
     
     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 @@ def install_extension():
         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 '