Changeset 66481
- Timestamp:
- Oct 12, 2015, 5:34:33 PM (9 years ago)
- Location:
- grass-addons/tools/addons
- Files:
-
- 2 edited
-
grass-addons-build.sh (modified) (1 diff)
-
update_manual.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass-addons/tools/addons/grass-addons-build.sh
r65890 r66481 31 31 if [ -d $dir/docs/html ] ; then 32 32 for f in `pwd`/$dir/docs/html/*.html ; do 33 ${SRC}grass-addons/tools/addons/update_manual.py $f http://grass.osgeo.org/grass${1}${2}/manuals 33 ${SRC}grass-addons/tools/addons/update_manual.py $f http://grass.osgeo.org/grass${1}${2}/manuals `pwd` 34 34 done 35 35 cp -r $dir/docs/html/* $HTMLDIR/ 2>/dev/null -
grass-addons/tools/addons/update_manual.py
r66480 r66481 9 9 10 10 11 def get_ addons(path):12 """Get list of addons11 def get_pages(path): 12 """Get list of HTML pages in the given directory and its subdirectories 13 13 14 Goes two levels deep to get directory names which are assumed 15 to be addon names. 14 Only filenames are returned, not the paths. 16 15 """ 17 top_directories = os.walk(path).next()[1]18 addons = []19 for directory in top_directories:20 addons.extend(os.walk(directory).next()[1])21 addons.extend(top_directories)22 return addons16 matches = [] 17 for root, dirnames, filenames in os.walk(path): 18 for filename in filenames: 19 if filename.endswith('.html'): 20 matches.append(filename) 21 return matches 23 22 24 23 25 def main(htmlfile, prefix ):24 def main(htmlfile, prefix, html_directory): 26 25 try: 27 26 f = open(htmlfile) … … 36 35 # find URIs 37 36 pattern = r'''<a href="([^"]+)">([^>]+)</a>''' 38 # TODO: replace the magic 4 by passing the base addons dir as parameter 39 addons = get_addons(os.sep.join(htmlfile.split(os.sep)[:4])) 37 addon_pages = get_pages(html_directory) 40 38 for match in re.finditer(pattern, shtml): 41 39 # most common URLs … … 49 47 # TODO: perhaps we could match any *:// 50 48 # link to other addon 51 if match.group(1) .replace('.html', '') in addons:49 if match.group(1) in addon_pages: 52 50 continue 53 51 pos.append(match.start(1)) … … 73 71 74 72 if __name__ == "__main__": 75 if len(sys.argv) != 3:76 sys.exit(" provide file and url")77 main(sys.argv[1], sys.argv[2] )73 if len(sys.argv) != 4: 74 sys.exit("Provide file, URL and directory with other HTML files") 75 main(sys.argv[1], sys.argv[2], sys.argv[3])
Note:
See TracChangeset
for help on using the changeset viewer.
