[GRASS-SVN] r44398 - grass/trunk/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 24 08:49:55 EST 2010


Author: martinl
Date: 2010-11-24 05:49:55 -0800 (Wed, 24 Nov 2010)
New Revision: 44398

Modified:
   grass/trunk/lib/python/core.py
Log:
backport r44366


Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py	2010-11-24 13:33:15 UTC (rev 44397)
+++ grass/trunk/lib/python/core.py	2010-11-24 13:49:55 UTC (rev 44398)
@@ -447,6 +447,14 @@
     """!Returns the name of a temporary file, created with g.tempfile."""
     return read_command("g.tempfile", pid = os.getpid()).strip()
 
+def tempdir():
+    """!Returns the name of a temporary dir, created with g.tempfile."""
+    tmp = read_command("g.tempfile", pid = os.getpid()).strip()
+    try_remove(tmp)
+    os.mkdir(tmp)
+    
+    return tmp
+
 # key-value parsers
 
 def parse_key_val(s, sep = '=', dflt = None, val_type = None, vsep = None):
@@ -793,7 +801,7 @@
     """!Attempt to remove a file; no exception is generated if the
     attempt fails.
 
-    @param path path
+    @param path path to file to remove
     """
     try:
 	os.remove(path)
@@ -806,12 +814,12 @@
     """!Attempt to remove a directory; no exception is generated if the
     attempt fails.
 
-    @param path path
+    @param path path to directory to remove
     """
     try:
 	os.rmdir(path)
     except:
-	pass
+	shutil.rmtree(path, ignore_errors = True)
 
 def float_or_dms(s):
     """!Convert DMS to float.



More information about the grass-commit mailing list