Kaynağa Gözat

pythonlib: tempfile/dir() use `create = False`, see https://trac.osgeo.org/grass/changeset/46975

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46976 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 yıl önce
ebeveyn
işleme
d72abb6cbe
1 değiştirilmiş dosya ile 14 ekleme ve 5 silme
  1. 14 5
      lib/python/core.py

+ 14 - 5
lib/python/core.py

@@ -464,14 +464,23 @@ def parser():
 
 # interface to g.tempfile
 
-def tempfile():
-    """!Returns the name of a temporary file, created with g.tempfile."""
-    return read_command("g.tempfile", pid = os.getpid()).strip()
+def tempfile(create = True):
+    """!Returns the name of a temporary file, created with
+    g.tempfile.
+    
+    @param create True to create a file
+    
+    @return path to a tmp file
+    """
+    flags = ''
+    if not create:
+        flags += 'd'
+    
+    return read_command("g.tempfile", flags = flags, 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)
+    tmp = tempfile(create = False)
     os.mkdir(tmp)
     
     return tmp