[GRASS-SVN] r63507 - grass-addons/tools/addons
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Dec 12 10:20:43 PST 2014
Author: martinl
Date: 2014-12-12 10:20:43 -0800 (Fri, 12 Dec 2014)
New Revision: 63507
Added:
grass-addons/tools/addons/update_manual.py
Modified:
grass-addons/tools/addons/grass-addons-public.sh
Log:
fix url in addons manual pages published on grass.osgeo.org
Modified: grass-addons/tools/addons/grass-addons-public.sh
===================================================================
--- grass-addons/tools/addons/grass-addons-public.sh 2014-12-12 15:04:34 UTC (rev 63506)
+++ grass-addons/tools/addons/grass-addons-public.sh 2014-12-12 18:20:43 UTC (rev 63507)
@@ -13,13 +13,16 @@
exit 0
fi
-${HOME}/cronjobs/grass-addons.sh
+${SRC}/grass-addons/tools/addons/grass-addons.sh
manuals() {
HTMLDIR=addons
mkdir $HTMLDIR
for dir in `find . -maxdepth 1 -type d`; do
if [ -d $dir/docs/html ] ; then
+ for f in `pwd`/$dir/docs/html/*.html ; do
+ ${SRC}grass-addons/tools/addons/update_manual.py $f http://grass.osgeo.org/grass${1}${2}/manuals
+ done
cp -r $dir/docs/html/* $HTMLDIR/ 2>/dev/null
fi
done
@@ -30,13 +33,14 @@
}
promote() {
- version=$1
- cd /tmp/.grass${version}/addons
+ major=$1
+ minor=$2
+ cd /tmp/.grass${major}/addons
tar czf logs.tar.gz logs
- manuals $version $2
- cp logs.tar.gz ${DST}/addons/grass${version}
- cp modules.xml ${DST}/addons/grass${version}
- cp html.tar.gz ${DST}/addons/grass${version}
+ manuals $major $minor
+ cp logs.tar.gz ${DST}/addons/grass${major}
+ cp modules.xml ${DST}/addons/grass${major}
+ cp html.tar.gz ${DST}/addons/grass${major}
}
promote 6 4
Added: grass-addons/tools/addons/update_manual.py
===================================================================
--- grass-addons/tools/addons/update_manual.py (rev 0)
+++ grass-addons/tools/addons/update_manual.py 2014-12-12 18:20:43 UTC (rev 63507)
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+import os
+import sys
+import re
+
+def get_addons(path):
+ return os.walk(path).next()[1]
+
+def main(htmlfile, prefix):
+ try:
+ f = open(htmlfile)
+ shtml = f.read()
+ except IOError as e:
+ sys.exit("Unable to read manual page: %s" % e)
+ else:
+ f.close()
+
+ pos = []
+
+ # find URIs
+ 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://':
+ continue
+ if match.group(1).replace('.html', '') in addons:
+ continue
+ pos.append(match.start(1))
+
+ if not pos:
+ return # no match
+
+ # replace file URIs
+ ohtml = shtml[:pos[0]]
+ for i in range(1, len(pos)):
+ ohtml += prefix + '/' + shtml[pos[i-1]:pos[i]]
+ ohtml += prefix + '/' + shtml[pos[-1]:]
+
+ # write updated html file
+ try:
+ f = open(htmlfile, 'w')
+ f.write(ohtml)
+ except IOError as e:
+ sys.exit("Unable for write manual page: %s" % e)
+ else:
+ f.close()
+
+if __name__ == "__main__":
+ if len(sys.argv) != 3:
+ sys.exit("provide file and url")
+ main(sys.argv[1], sys.argv[2])
Property changes on: grass-addons/tools/addons/update_manual.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mime-type
+ text/x-python
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list