[GRASS-SVN] r47570 - grass/trunk/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 11 17:16:47 EDT 2011


Author: martinl
Date: 2011-08-11 14:16:47 -0700 (Thu, 11 Aug 2011)
New Revision: 47570

Modified:
   grass/trunk/lib/init/grass.py
Log:
grass.py (r47557):
	use sys.stdout.write instead of print
	fix indentation


Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py	2011-08-11 21:16:02 UTC (rev 47569)
+++ grass/trunk/lib/init/grass.py	2011-08-11 21:16:47 UTC (rev 47570)
@@ -671,7 +671,7 @@
 	    message(_("Executing '%s' ...") % batch_job)
 	    grass_gui = "text"
 	    shell = batch_job
-	    bj = Popen(shell,shell=True)
+	    bj = Popen(shell, shell=True)
 	    bj.wait()
 	    message(_("Execution of '%s' finished.") % batch_job)
     
@@ -860,27 +860,32 @@
     return [elem for elem in list if expr.match(elem)]
 
 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():
     global user
     if windows:



More information about the grass-commit mailing list