[GRASS-SVN] r54033 - grass/trunk/gui/wxpython/core
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 25 05:52:43 PST 2012
Author: annakrat
Date: 2012-11-25 05:52:42 -0800 (Sun, 25 Nov 2012)
New Revision: 54033
Modified:
grass/trunk/gui/wxpython/core/gcmd.py
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/core/settings.py
grass/trunk/gui/wxpython/core/utils.py
grass/trunk/gui/wxpython/core/workspace.py
Log:
wxGUI: fix indentation, remove unused code
Modified: grass/trunk/gui/wxpython/core/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/core/gcmd.py 2012-11-25 13:27:20 UTC (rev 54032)
+++ grass/trunk/gui/wxpython/core/gcmd.py 2012-11-25 13:52:42 UTC (rev 54033)
@@ -188,7 +188,7 @@
import win32api
handle = win32api.OpenProcess(1, 0, self.pid)
return (0 != win32api.TerminateProcess(handle, 0))
- else:
+ else:
try:
os.kill(-self.pid, signal.SIGTERM) # kill whole group
except OSError:
@@ -342,7 +342,7 @@
Debug.msg(1, "gcmd.Command(): %s" % ' '.join(cmd))
self.cmd = cmd
self.stderr = stderr
-
+
#
# set verbosity level
#
@@ -561,14 +561,14 @@
if self.stdout:
# make module stdout/stderr non-blocking
out_fileno = self.module.stdout.fileno()
- if not subprocess.mswindows:
+ if not subprocess.mswindows:
flags = fcntl.fcntl(out_fileno, fcntl.F_GETFL)
fcntl.fcntl(out_fileno, fcntl.F_SETFL, flags| os.O_NONBLOCK)
if self.stderr:
# make module stdout/stderr non-blocking
out_fileno = self.module.stderr.fileno()
- if not subprocess.mswindows:
+ if not subprocess.mswindows:
flags = fcntl.fcntl(out_fileno, fcntl.F_GETFL)
fcntl.fcntl(out_fileno, fcntl.F_SETFL, flags| os.O_NONBLOCK)
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2012-11-25 13:27:20 UTC (rev 54032)
+++ grass/trunk/gui/wxpython/core/render.py 2012-11-25 13:52:42 UTC (rev 54033)
@@ -127,8 +127,8 @@
{'type' : self.type, 'name' : self.name})
# start monitor
- if self.mapfile:
- os.environ["GRASS_PNGFILE"] = self.mapfile
+ if self.mapfile:
+ os.environ["GRASS_PNGFILE"] = self.mapfile
# execute command
try:
@@ -482,7 +482,7 @@
# new values to use for saving to region file
new = {}
n = s = e = w = 0.0
- nwres = ewres = 0.0
+ nsres = ewres = 0.0
# Get current values for region and display
reg = self.GetRegion()
@@ -540,7 +540,7 @@
try:
self.width = int(width)
self.height = int(height)
- except:
+ except ValueError:
self.width = 640
self.height = 480
@@ -871,7 +871,7 @@
return maps, masks, opacities
- def GetMapsMasksAndOpacities(self, force, guiFrame, windres):
+ def GetMapsMasksAndOpacities(self, force, guiFrame):
"""!
Used by Render function.
@@ -907,23 +907,21 @@
else:
os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"
- maps, masks, opacities = self.GetMapsMasksAndOpacities(force, mapWindow, windres)
+ maps, masks, opacities = self.GetMapsMasksAndOpacities(force, mapWindow)
# ugly hack for MSYS
if sys.platform != 'win32':
mapstr = ",".join(maps)
maskstr = ",".join(masks)
- mapoutstr = self.mapfile
else:
mapstr = ""
for item in maps:
- mapstr += item.replace('\\', '/')
+ mapstr += item.replace('\\', '/')
mapstr = mapstr.rstrip(',')
maskstr = ""
for item in masks:
maskstr += item.replace('\\', '/')
maskstr = maskstr.rstrip(',')
- mapoutstr = self.mapfile.replace('\\', '/')
# run g.pngcomp to get composite image
bgcolor = ':'.join(map(str, UserSettings.Get(group = 'display', key = 'bgcolor',
@@ -1093,7 +1091,7 @@
if render and not layer.Render():
raise GException(_("Unable to render map layer <%s>.") %
- name)
+ layer.GetName())
return layer
@@ -1152,7 +1150,7 @@
os.remove(layer.mapfile)
os.remove(layer.maskfile)
self.layers.remove(layer)
- return layer
+ return retlayer
# del by id
elif id != None:
return self.layers.pop(id)
@@ -1169,7 +1167,7 @@
@return -1 if layer not found
"""
if overlay:
- list = self.overlay
+ list = self.overlays
else:
list = self.layers
@@ -1202,7 +1200,7 @@
if l_render and command != '' and not overlay.Render():
raise GException(_("Unable to render overlay <%s>.") %
- name)
+ type)
return self.overlays[-1]
@@ -1241,7 +1239,7 @@
if render and overlay.GetCmd() != [] and not overlay.Render():
raise GException(_("Unable to render overlay <%s>.") %
- name)
+ overlay.GetType())
return overlay
Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py 2012-11-25 13:27:20 UTC (rev 54032)
+++ grass/trunk/gui/wxpython/core/settings.py 2012-11-25 13:52:42 UTC (rev 54033)
@@ -23,7 +23,6 @@
import sys
import copy
import types
-import locale
from core import globalvar
from core.gcmd import GException, GError
@@ -54,8 +53,6 @@
def _generateLocale(self):
"""!Generate locales
"""
- import os
-
try:
self.locs = os.listdir(os.path.join(os.environ['GISBASE'], 'locale'))
self.locs.append('en') # GRASS doesn't ship EN po files
@@ -1168,8 +1165,8 @@
settings.append('size=%s' % UserSettings.Get(group = 'vectorLayer', key = 'point', subkey = 'size'))
types = []
for ftype in ['point', 'line', 'boundary', 'centroid', 'area', 'face']:
- if UserSettings.Get(group = 'vectorLayer', key = 'showType', subkey = [ftype, 'enabled']):
- types.append(ftype)
+ if UserSettings.Get(group = 'vectorLayer', key = 'showType', subkey = [ftype, 'enabled']):
+ types.append(ftype)
settings.append('type=%s' % ','.join(types))
return settings
Modified: grass/trunk/gui/wxpython/core/utils.py
===================================================================
--- grass/trunk/gui/wxpython/core/utils.py 2012-11-25 13:27:20 UTC (rev 54032)
+++ grass/trunk/gui/wxpython/core/utils.py 2012-11-25 13:52:42 UTC (rev 54033)
@@ -61,13 +61,13 @@
# FIXME
# ugly hack for MSYS (MS Windows)
if platform.system() == 'Windows':
- tempfile = tempfile.replace("/", "\\")
+ tempfile = tempfile.replace("/", "\\")
try:
path, file = os.path.split(tempfile)
if pref:
return os.path.join(pref, file)
- else:
- return tempfile
+ else:
+ return tempfile
except:
return None
@@ -147,7 +147,7 @@
else:
findType = layerType
mapset = grass.find_file(mapname, element = findType)['mapset']
- except AttributeError, e: # not found
+ except AttributeError: # not found
return '', False
if not mapset:
found = False
@@ -292,7 +292,7 @@
"""!Sort list items (not case-sensitive)"""
list.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
-def GetVectorNumberOfLayers(parent, vector):
+def GetVectorNumberOfLayers(vector):
"""!Get list of vector layers"""
layers = list()
if not vector:
@@ -536,8 +536,7 @@
f = open(path, "r")
except IOError:
return _("failed to open '%s'" % path)
-
- i = 0
+
code = None
for line in f.readlines():
line = line.strip()
@@ -550,13 +549,12 @@
code, params = line.split(" ", 1)
try:
code = int(code.replace('<', '').replace('>', ''))
- except ValueError:
+ except ValueError, e:
return e
if code is not None:
epsgCodeDict[code] = (descr, params)
code = None
- i += 1
f.close()
except StandardError, e:
Modified: grass/trunk/gui/wxpython/core/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/core/workspace.py 2012-11-25 13:27:20 UTC (rev 54032)
+++ grass/trunk/gui/wxpython/core/workspace.py 2012-11-25 13:52:42 UTC (rev 54033)
@@ -545,7 +545,7 @@
node_constants = node_state.find('constant_planes')
constants = []
if node_constants:
- for i, node_plane in enumerate(node_constants.findall('plane')):
+ for node_plane in node_constants.findall('plane'):
plane = {}
plane['color'] = self.__processLayerNvizNode(node_plane, 'color', str)
plane['resolution'] = self.__processLayerNvizNode(node_plane, 'fine_resolution', int)
@@ -671,12 +671,12 @@
if type == 'command':
cmd = mapTree.GetLayerInfo(item, key = 'maplayer').GetCmd(string=True)
self.file.write('%s<layer type="%s" name="%s" checked="%d">\n' % \
- (' ' * self.indent, type, EncodeString(cmd), checked));
- self.file.write('%s</layer>\n' % (' ' * self.indent));
+ (' ' * self.indent, type, EncodeString(cmd), checked))
+ self.file.write('%s</layer>\n' % (' ' * self.indent))
elif type == 'group':
name = mapTree.GetItemText(item)
self.file.write('%s<group name="%s" checked="%d">\n' % \
- (' ' * self.indent, EncodeString(name), checked));
+ (' ' * self.indent, EncodeString(name), checked))
self.indent += 4
subItem = mapTree.GetFirstChild(item)[0]
self.__writeLayer(mapTree, subItem)
@@ -714,9 +714,9 @@
self.file.write('%s<value>%s</value>\n' %
(' ' * self.indent, self.__filterValue(val)))
self.indent -= 4
- self.file.write('%s</parameter>\n' % (' ' * self.indent));
+ self.file.write('%s</parameter>\n' % (' ' * self.indent))
self.indent -= 4
- self.file.write('%s</task>\n' % (' ' * self.indent));
+ self.file.write('%s</task>\n' % (' ' * self.indent))
# vector digitizer
vdigit = mapTree.GetLayerInfo(item, key = 'vdigit')
if vdigit:
@@ -804,12 +804,10 @@
# position
elif attrb == 'position':
self.file.write('%s<%s>\n' %(' ' * self.indent, attrb))
- i = 0
for tag in ('x', 'y', 'z'):
self.indent += 4
self.file.write('%s<%s>%d</%s>\n' % (' ' * self.indent, tag,
data[attrb][tag], tag))
- i += 1
self.indent -= 4
if attrb != 'attribute':
More information about the grass-commit
mailing list