[GRASS-SVN] r70734 - grass-addons/grass7/raster/r.mess

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 7 02:07:29 PST 2017


Author: pvanbosgeo
Date: 2017-03-07 02:07:29 -0800 (Tue, 07 Mar 2017)
New Revision: 70734

Modified:
   grass-addons/grass7/raster/r.mess/r.mess.py
Log:
r.mess addon: bugfix - solved issue with temporary file not being deleted on Windows

Modified: grass-addons/grass7/raster/r.mess/r.mess.py
===================================================================
--- grass-addons/grass7/raster/r.mess/r.mess.py	2017-03-06 04:31:32 UTC (rev 70733)
+++ grass-addons/grass7/raster/r.mess/r.mess.py	2017-03-07 10:07:29 UTC (rev 70734)
@@ -9,7 +9,7 @@
 #               surface (MESS) as proposed by Elith et al., 2010,
 #               Methods in Ecology & Evolution, 1(330–342).
 #
-# COPYRIGHT: (C) 2014-2016 by Paulo van Breugel and the GRASS Development Team
+# COPYRIGHT: (C) 2014-2017 by Paulo van Breugel and the GRASS Development Team
 #
 #            This program is free software under the GNU General Public
 #            License (>=v2). Read the file COPYING that comes with GRASS
@@ -130,9 +130,9 @@
 1\tnovel conditions
 """
 
-#----------------------------------------------------------------------------
+# ----------------------------------------------------------------------------
 # Functions
-#----------------------------------------------------------------------------
+# ----------------------------------------------------------------------------
 
 # create set to store names of temporary maps to be deleted upon exit
 CLEAN_RAST = []
@@ -151,7 +151,7 @@
     for chl in xrange(len(envlay)):
         ffile = gs.find_file(envlay[chl], element='cell')
         if not ffile['fullname']:
-            gs.fatal(_("The layer <%s> does not exist") % envlay[chl])
+            gs.fatal(_("The layer {} does not exist".format(envlay[chl])))
 
 
 # Create temporary name
@@ -249,9 +249,8 @@
     hist = ' '.join("{!s}={!r}".format(k, v) for (k, v) in opt2.iteritems())
     hist = "r.mess {}".format(hist)
     unused, tmphist = tempfile.mkstemp()
-    text_file = open(tmphist, "w")
-    text_file.write(hist)
-    text_file.close()
+    with open(tmphist, "w") as text_file:
+        text_file.write(hist)
 
     # Create reference layer if not defined
     if not ref_rast and not ref_vect:



More information about the grass-commit mailing list