[GRASS-SVN] r66445 - grass-addons/tools/addons

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 9 06:38:35 PDT 2015


Author: wenzeslaus
Date: 2015-10-09 06:38:35 -0700 (Fri, 09 Oct 2015)
New Revision: 66445

Modified:
   grass-addons/tools/addons/update_manual.py
Log:
ignore also https when fixing URLs in addons manuals

Follows r63507. Fixes e.g. Reference link in v.ellipse manual.


Modified: grass-addons/tools/addons/update_manual.py
===================================================================
--- grass-addons/tools/addons/update_manual.py	2015-10-09 12:11:13 UTC (rev 66444)
+++ grass-addons/tools/addons/update_manual.py	2015-10-09 13:38:35 UTC (rev 66445)
@@ -7,9 +7,11 @@
 import sys
 import re
 
+
 def get_addons(path):
     return os.walk(path).next()[1]
 
+
 def main(htmlfile, prefix):
     try:
         f = open(htmlfile)
@@ -25,14 +27,22 @@
     pattern = r'''<a href="([^"]+)">([^>]+)</a>'''
     addons = get_addons(os.sep.join(htmlfile.split(os.sep)[:4]))
     for match in re.finditer(pattern, shtml):
-        if match.group(1)[:7] == 'http://':
+        # most common URLs
+        if match.group(1).startswith('http://'):
             continue
+        if match.group(1).startswith('https://'):
+            continue
+        # protocol-relative URL
+        if match.group(1).startswith('//'):
+            continue
+        # TODO: perhaps we could match any *://
+        # link to other addon
         if match.group(1).replace('.html', '') in addons:
             continue
         pos.append(match.start(1))
 
     if not pos:
-        return # no match
+        return  # no match
 
     # replace file URIs
     ohtml = shtml[:pos[0]]
@@ -49,6 +59,7 @@
     else:
         f.close()
 
+
 if __name__ == "__main__":
     if len(sys.argv) != 3:
         sys.exit("provide file and url")



More information about the grass-commit mailing list