ソースを参照

add function to check if grass_logo.png and grassdocs.css are present on /docs/html to a correct web page style

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48892 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 13 年 前
コミット
c5290d9c06
1 ファイル変更19 行追加1 行削除
  1. 19 1
      scripts/g.extension/g.extension.py

+ 19 - 1
scripts/g.extension/g.extension.py

@@ -92,6 +92,7 @@ import os
 import sys
 import re
 import atexit
+import shutil
 
 import urllib
 
@@ -438,10 +439,27 @@ def create_dir(path):
         grass.fatal(_("Unable to create '%s': %s") % (path, e))
     
     grass.debug("'%s' created" % path)
-    
+
+def check_style_files(fil):
+    #check the links to grassdocs.css/grass_logo.png to a correct manual page of addons
+    dist_file = os.path.join(os.getenv('GISBASE'),'docs','html',fil)
+    addons_file = os.path.join(options['prefix'],'docs','html',fil)
+    #check if file already exists in the grass addons docs html path
+    if os.path.isfile(addons_file):
+	return
+    #otherwise copy the file from $GISBASE/docs/html, it doesn't use link 
+    #because os.symlink it work only in Linux
+    else:
+	try:
+	    shutil.copyfile(dist_file,addons_file)
+	except OSError, e:
+	    grass.fatal(_("Unable to create '%s': %s") % (addons_file, e))
+
 def check_dirs():
     create_dir(os.path.join(options['prefix'], 'bin'))
     create_dir(os.path.join(options['prefix'], 'docs', 'html'))
+    check_style_files('grass_logo.png')
+    check_style_files('grassdocs.css')    
     create_dir(os.path.join(options['prefix'], 'man', 'man1'))
     create_dir(os.path.join(options['prefix'], 'scripts'))