[GRASS-SVN] r44367 - grass/branches/releasebranch_6_4/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 22 16:16:26 EST 2010
Author: martinl
Date: 2010-11-22 13:16:26 -0800 (Mon, 22 Nov 2010)
New Revision: 44367
Modified:
grass/branches/releasebranch_6_4/lib/python/core.py
Log:
sync pythonlib with trunk
(merge r44366 from devbr6)
Modified: grass/branches/releasebranch_6_4/lib/python/core.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/core.py 2010-11-22 21:14:34 UTC (rev 44366)
+++ grass/branches/releasebranch_6_4/lib/python/core.py 2010-11-22 21:16:26 UTC (rev 44367)
@@ -29,6 +29,7 @@
import re
import atexit
import subprocess
+import shutil
# i18N
import gettext
@@ -446,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):
@@ -792,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)
@@ -805,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