浏览代码

introduce prompt.py (check for mask)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48247 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 年之前
父节点
当前提交
08f77da643
共有 3 个文件被更改,包括 31 次插入0 次删除
  1. 1 0
      lib/init/Makefile
  2. 1 0
      lib/init/grass.py
  3. 29 0
      lib/init/prompt.py

+ 1 - 0
lib/init/Makefile

@@ -27,6 +27,7 @@ FILES = \
 	$(ETC)/license \
 	$(ETC)/welcome \
 	$(ETC)/VERSIONNUMBER \
+	$(ETC)/prompt.py \
 	$(HTMLDIR)/variables.html \
 	$(HTMLDIR)/grass7.html \
 	$(HTMLDIR)/helptext.html \

+ 1 - 0
lib/init/grass.py

@@ -810,6 +810,7 @@ def bash_startup():
     f = open(bashrc, 'w')
     f.write("test -r ~/.alias && . ~/.alias\n")
     f.write("PS1='GRASS %s (%s@%s):\w > '\n" % (grass_version, location_name, mapset))
+    f.write("PROMPT_COMMAND=\"'%s'\"\n" % os.path.join(gisbase, 'etc', 'prompt.py'))
     
     path = os.path.join(userhome, ".grass.bashrc")
     if os.access(path, os.R_OK):

+ 29 - 0
lib/init/prompt.py

@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+from grass.script import core as grass
+
+gisenv = grass.gisenv()
+
+import gettext
+gettext.install('grasslibs', os.path.join(gisenv['GISDBASE'], 'locale'), unicode = True)
+
+location = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'], gisenv['MAPSET'])
+
+has_mask   = os.path.isfile(os.path.join(location, 'cell', 'MASK'))
+has_mask3d = os.path.isdir(os.path.join(location, 'grid3', 'G3D_MASK'))
+
+def main():
+    if has_mask and has_mask3d:
+        grass.info(_("[Raster and Volume MASKs present]"))
+    elif has_mask:
+        grass.info(_("[Raster MASK present]"))
+    elif has_mask3d:
+        grass.info(_("[Volume MASK present]"))
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main())