[GRASS-SVN] r40348 - grass-addons/vector/v.in.lines

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 9 08:17:26 EST 2010


Author: hamish
Date: 2010-01-09 08:17:25 -0500 (Sat, 09 Jan 2010)
New Revision: 40348

Modified:
   grass-addons/vector/v.in.lines/v.in.lines.py
Log:
fully functional

Modified: grass-addons/vector/v.in.lines/v.in.lines.py
===================================================================
--- grass-addons/vector/v.in.lines/v.in.lines.py	2010-01-09 12:57:28 UTC (rev 40347)
+++ grass-addons/vector/v.in.lines/v.in.lines.py	2010-01-09 13:17:25 UTC (rev 40348)
@@ -96,7 +96,7 @@
     else:
         infile = infile_opt
         if not os.path.exists(infile):
-            grass.fatal(_("Unable to read input data"))
+            grass.fatal(_("Unable to read input file <%s>") % infile)
         grass.debug("input file=[%s]" % infile)
 
 
@@ -104,8 +104,8 @@
         # read from stdin and write to tmpfile (v.in.mapgen wants a real file)
         outf = file(tmp, 'w')
         for line in inf:
-            if len(line) == 0 or line[0] == '#':
-	        continue
+            if len(line.lstrip()) == 0 or line[0] == '#':
+                continue
             outf.write(line.replace(fs, ' '))
 
         outf.close()
@@ -115,25 +115,26 @@
         if fs == ' ':
             runfile = infile
         else:
-	    inf = file(infile)
+            inf = file(infile)
             outf = file(tmp, 'w')
 
             for line in inf:
-                if len(line) == 0 or line[0] == '#':
-	            continue
+                if len(line.lstrip()) == 0 or line[0] == '#':
+                    continue
                 outf.write(line.replace(fs, ' '))
 
+            inf.close()
             outf.close()
             runfile = tmp
 
-    if infile:
-        inf.close()
 
-
     ##### check that there are at least two columns (three if -z is given)
     inf = file(runfile)
-    line = inf.readline()
-    numcols = len(line.split())
+    for line in inf:
+        if len(line.lstrip()) == 0 or line[0] == '#':
+            continue
+        numcols = len(line.split())
+        break
     if (do3D and numcols < 3) or (not do3D and numcols < 2):
         grass.fatal(_("Not enough data columns. (incorrect fs setting?)"))
     inf.close()
@@ -147,4 +148,3 @@
     options, flags = grass.parser()
     atexit.register(cleanup)
     main()
-



More information about the grass-commit mailing list