Browse Source

grass.py (https://trac.osgeo.org/grass/changeset/47557):
use sys.stdout.write instead of print
fix indentation


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@47570 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 13 years ago
parent
commit
342c1c1182
1 changed files with 26 additions and 21 deletions
  1. 26 21
      lib/init/grass.py

+ 26 - 21
lib/init/grass.py

@@ -671,7 +671,7 @@ def check_batch_job():
 	    message(_("Executing '%s' ...") % batch_job)
 	    message(_("Executing '%s' ...") % batch_job)
 	    grass_gui = "text"
 	    grass_gui = "text"
 	    shell = batch_job
 	    shell = batch_job
-	    bj = Popen(shell,shell=True)
+	    bj = Popen(shell, shell=True)
 	    bj.wait()
 	    bj.wait()
 	    message(_("Execution of '%s' finished.") % batch_job)
 	    message(_("Execution of '%s' finished.") % batch_job)
     
     
@@ -860,26 +860,31 @@ def grep(string,list):
     return [elem for elem in list if expr.match(elem)]
     return [elem for elem in list if expr.match(elem)]
 
 
 def print_params():
 def print_params():
-       plat = os.path.join(gisbase,'include','Make','Platform.make')
-       fileplat = open(plat)
-       linesplat = fileplat.readlines()
-       fileplat.close()
-       for i in sys.argv[2:]:
-               if i == 'path':
-                       print gisbase
-               elif i == 'arch':
-                       val = grep('ARCH',linesplat)
-                       print val[0].split('=')[1].strip()
-               elif i == 'build':
-                       build = os.path.join(gisbase,'include','grass','confparms.h')
-                       filebuild = open(build)
-                       val = filebuild.readline()
-                       print val.strip().strip('"').strip()
-               elif i == 'compiler':
-                       val = grep('CC',linesplat)
-                       print val[0].split('=')[1].strip()
-               else:
-                       print "Parameter not supported"
+    plat = gfile(gisbase, 'include', 'Make', 'Platform.make')
+    fileplat = open(plat)
+    linesplat = fileplat.readlines()
+    fileplat.close()
+    
+    params = sys.argv[2:]
+    if not params:
+        params = ['arch', 'build', 'compiler', 'path']
+        
+    for arg in params:
+        if arg == 'path':
+            sys.stdout.write("%s\n" % gisbase)
+        elif arg == 'arch':
+            val = grep('ARCH',linesplat)
+            sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
+        elif arg == 'build':
+            build = os.path.join(gisbase,'include','grass','confparms.h')
+            filebuild = open(build)
+            val = filebuild.readline()
+            sys.stdout.write("%s\n" % val.strip().strip('"').strip())
+        elif arg == 'compiler':
+            val = grep('CC',linesplat)
+            sys.stdout.write("%s\n" % val[0].split('=')[1].strip())
+        else:
+            error(_("Parameter <%s> not supported") % i)
     
     
 def get_username():
 def get_username():
     global user
     global user