[GRASS-SVN] r59538 - grass/trunk/gui/wxpython/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 1 00:59:24 PDT 2014


Author: lucadelu
Date: 2014-04-01 00:59:23 -0700 (Tue, 01 Apr 2014)
New Revision: 59538

Modified:
   grass/trunk/gui/wxpython/animation/dialogs.py
   grass/trunk/gui/wxpython/animation/frame.py
   grass/trunk/gui/wxpython/animation/g.gui.animation.py
   grass/trunk/gui/wxpython/animation/provider.py
   grass/trunk/gui/wxpython/animation/utils.py
Log:
g.gui.animation: fix small bug with vector input; fix .format() function to be compatible also with python 2.6

Modified: grass/trunk/gui/wxpython/animation/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/animation/dialogs.py	2014-04-01 06:18:18 UTC (rev 59537)
+++ grass/trunk/gui/wxpython/animation/dialogs.py	2014-04-01 07:59:23 UTC (rev 59538)
@@ -1389,12 +1389,12 @@
             cmd.append('d.rast3d')
         if self._name:
             if self._mapType in ('rast', 'vect', 'rast3d'):
-                cmd.append('map={}'.format(self._name.split(',')[0]))
+                cmd.append('map={name}'.format(name=self._name.split(',')[0]))
             else:
                 try:
                     maps = getRegisteredMaps(self._name, etype=self._mapType)
                     if maps:
-                        cmd.append('map={}'.format(maps[0]))
+                        cmd.append('map={name}'.format(name=maps[0]))
                 except gcore.ScriptError, e:
                     GError(parent=self, message=str(e), showTraceback=False)
                     return None

Modified: grass/trunk/gui/wxpython/animation/frame.py
===================================================================
--- grass/trunk/gui/wxpython/animation/frame.py	2014-04-01 06:18:18 UTC (rev 59537)
+++ grass/trunk/gui/wxpython/animation/frame.py	2014-04-01 07:59:23 UTC (rev 59538)
@@ -274,7 +274,8 @@
         self._progressDlgMax = count
 
     def _updateProgress(self, current, text):
-        text += _(" ({} out of {})").format(current, self._progressDlgMax)
+        text += _(" ({c} out of {p})").format(c=current,
+                                              p=self._progressDlgMax)
         keepGoing, skip = self._progressDlg.Update(current, text)
         if not keepGoing:
             self.provider.RequestStopRendering()

Modified: grass/trunk/gui/wxpython/animation/g.gui.animation.py
===================================================================
--- grass/trunk/gui/wxpython/animation/g.gui.animation.py	2014-04-01 06:18:18 UTC (rev 59537)
+++ grass/trunk/gui/wxpython/animation/g.gui.animation.py	2014-04-01 07:59:23 UTC (rev 59538)
@@ -101,13 +101,13 @@
         layer = AnimLayer()
         layer.mapType = 'rast'
         layer.name = rast
-        layer.cmd = ['d.rast', 'map={}'.format(rast.split(',')[0])]
+        layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
         layerList.AddLayer(layer)
     if vect:
         layer = AnimLayer()
         layer.mapType = 'vect'
         layer.name = vect
-        layer.cmd = ['d.vect', 'map={}'.format(rast.split(',')[0])]
+        layer.cmd = ['d.vect', 'map={name=}'.format(name=vect.split(',')[0])]
         layerList.AddLayer(layer)
     if strds:
         layer = AnimLayer()

Modified: grass/trunk/gui/wxpython/animation/provider.py
===================================================================
--- grass/trunk/gui/wxpython/animation/provider.py	2014-04-01 06:18:18 UTC (rev 59537)
+++ grass/trunk/gui/wxpython/animation/provider.py	2014-04-01 07:59:23 UTC (rev 59538)
@@ -90,7 +90,7 @@
         @param opacities list of opacity values
         @param regions list of regions
         """
-        Debug.msg(2, "BitmapProvider.SetCmds: {} lists".format(len(cmdsForComposition)))
+        Debug.msg(2, "BitmapProvider.SetCmds: {n} lists".format(n=len(cmdsForComposition)))
         self._cmdsForComposition.extend(cmdsForComposition)
         self._opacities.extend(opacities)
         self._regions.extend(regions)
@@ -103,7 +103,7 @@
         @param cmds list of commands m.nviz.image (cmd as a list)
         @param region for 3D rendering
         """
-        Debug.msg(2, "BitmapProvider.SetCmds3D: {} commands".format(len(cmds)))
+        Debug.msg(2, "BitmapProvider.SetCmds3D: {c} commands".format(c=len(cmds)))
         self._cmds3D = cmds
         self._regionFor3D = region
 
@@ -157,7 +157,7 @@
                 continue
             count += 1
 
-        Debug.msg(3, "BitmapProvider._dryRender: {} files to be rendered".format(count))
+        Debug.msg(3, "BitmapProvider._dryRender: {c} files to be rendered".format(c=count))
 
         return count
 
@@ -177,7 +177,7 @@
                 continue
             count += 1
 
-        Debug.msg(2, "BitmapProvider._dryCompose: {} files to be composed".format(count))
+        Debug.msg(2, "BitmapProvider._dryCompose: {c} files to be composed".format(c=count))
 
         return count
 
@@ -190,7 +190,9 @@
         @param nprocs number of procs to be used for rendering
         """
         Debug.msg(2, "BitmapProvider.Load: "
-                     "force={}, bgcolor={}, nprocs={}".format(force, bgcolor, nprocs))
+                     "force={f}, bgcolor={b}, nprocs={n}".format(f=force,
+                                                                 b=bgcolor,
+                                                                 n=nprocs))
         cmds = []
         regions = []
         if self._uniqueCmds:
@@ -246,7 +248,7 @@
 
     def WindowSizeChanged(self, width, height):
         """!Sets size when size of related window changes."""
-        Debug.msg(5, "BitmapProvider.WindowSizeChanged: w={}, h={}".format(width, height))
+        Debug.msg(5, "BitmapProvider.WindowSizeChanged: w={w}, h={h}".format(w=width, h=height))
 
         self.imageWidth, self.imageHeight = width, height
 
@@ -260,7 +262,7 @@
 
         @return bitmap with legend
         """
-        Debug.msg(5, "BitmapProvider.LoadOverlay: cmd={}".format(cmd))
+        Debug.msg(5, "BitmapProvider.LoadOverlay: cmd={c}".format(c=cmd))
 
         fileHandler, filename = tempfile.mkstemp(suffix=".png")
         os.close(fileHandler)
@@ -603,14 +605,14 @@
             self.referenceCount[key] = 1
         else:
             self.referenceCount[key] += 1
-        Debug.msg(5, 'DictRefCounter.__setitem__: +1 for key {}'.format(key))
+        Debug.msg(5, 'DictRefCounter.__setitem__: +1 for key {k}'.format(k=key))
 
     def __contains__(self, key):
         return key in self.dictionary
 
     def __delitem__(self, key):
         self.referenceCount[key] -= 1
-        Debug.msg(5, 'DictRefCounter.__delitem__: -1 for key {}'.format(key))
+        Debug.msg(5, 'DictRefCounter.__delitem__: -1 for key {k}'.format(k=key))
 
     def keys(self):
         return self.dictionary.keys()
@@ -670,9 +672,9 @@
         if os.path.exists(self._tempDir):
             try:
                 shutil.rmtree(self._tempDir)
-                Debug.msg(5, 'CleanUp: removed directory {}'.format(self._tempDir))
+                Debug.msg(5, 'CleanUp: removed directory {t}'.format(t=self._tempDir))
             except OSError:
-                gcore.warning(_("Directory {} not removed.").format(self._tempDir))
+                gcore.warning(_("Directory {t} not removed.").format(t=self._tempDir))
 
 
 def _setEnvironment(width, height, filename, transparent, bgcolor):
@@ -684,15 +686,20 @@
     @param transparent use transparency
     @param bgcolor background color as a tuple of 3 values 0 to 255
     """
-    Debug.msg(5, "_setEnvironment: width={}, height={}, "
-                 "filename={}, transparent={}, bgcolor={}".format(width, height, filename,
-                                                                  transparent, bgcolor))
+    Debug.msg(5, "_setEnvironment: width={w}, height={h}, "
+                 "filename={f}, transparent={t}, bgcolor={b}".format(w=width,
+                                                                     h=height,
+                                                                     f=filename,
+                                                                     t=transparent,
+                                                                     b=bgcolor))
 
     os.environ['GRASS_WIDTH'] = str(width)
     os.environ['GRASS_HEIGHT'] = str(height)
     driver = UserSettings.Get(group='display', key='driver', subkey='type')
     os.environ['GRASS_RENDER_IMMEDIATE'] = driver
-    os.environ['GRASS_BACKGROUNDCOLOR'] = '{:02x}{:02x}{:02x}'.format(*bgcolor)
+    os.environ['GRASS_BACKGROUNDCOLOR'] = '{r}{g}{b}'.format(r=bgcolor[0],
+                                                             g=bgcolor[1],
+                                                             b=bgcolor[2])
     os.environ['GRASS_TRUECOLOR'] = "TRUE"
     if transparent:
         os.environ['GRASS_TRANSPARENT'] = "TRUE"
@@ -710,8 +717,9 @@
     @param imageWidth image width
     @param imageHeight image height
     """
-    Debug.msg(4, "createNoDataBitmap: w={}, h={}, text={}".format(imageWidth,
-                                                                  imageHeight, text))
+    Debug.msg(4, "createNoDataBitmap: w={w}, h={h}, text={t}".format(w=imageWidth,
+                                                                     h=imageHeight,
+                                                                     t=text))
     bitmap = wx.EmptyBitmap(imageWidth, imageHeight)
     dc = wx.MemoryDC()
     dc.SelectObject(bitmap)
@@ -772,13 +780,13 @@
     prov = BitmapProvider(bPool, mapFilesPool, tempDir,
                           imageWidth=640, imageHeight=480)
     prov.renderingStarted.connect(
-        lambda count: sys.stdout.write("Total number of maps: {}\n".format(count)))
+        lambda count: sys.stdout.write("Total number of maps: {c}\n".format(c=count)))
     prov.renderingContinues.connect(
-        lambda current, text: sys.stdout.write("Current number: {}\n".format(current)))
+        lambda current, text: sys.stdout.write("Current number: {c}\n".format(c=current)))
     prov.compositionStarted.connect(
-        lambda count: sys.stdout.write("Composition: total number of maps: {}\n".format(count)))
+        lambda count: sys.stdout.write("Composition: total number of maps: {c}\n".format(c=count)))
     prov.compositionContinues.connect(
-        lambda current, text: sys.stdout.write("Composition: Current number: {}\n".format(current)))
+        lambda current, text: sys.stdout.write("Composition: Current number: {c}\n".format(c=current)))
     prov.mapsLoaded.connect(
         lambda: sys.stdout.write("Maps loading finished\n"))
     cmdMatrix = layerListToCmdsMatrix(layerList)

Modified: grass/trunk/gui/wxpython/animation/utils.py
===================================================================
--- grass/trunk/gui/wxpython/animation/utils.py	2014-04-01 06:18:18 UTC (rev 59537)
+++ grass/trunk/gui/wxpython/animation/utils.py	2014-04-01 07:59:23 UTC (rev 59538)
@@ -290,7 +290,7 @@
                     cmd = layer.cmd[:]
                     cmds = []
                     for map_ in layer.maps:
-                        cmd[i] = 'map={}'.format(map_)
+                        cmd[i] = 'map={name}'.format(name=map_)
                         cmds.append(cmd[:])
                     cmdsForComposition.append(cmds)
         else:



More information about the grass-commit mailing list