Skip to content

Commit

Permalink
wxGUI: address flake8 undefined variable (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa committed Feb 13, 2021
1 parent f3483cf commit f02ee9c
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 2,147 deletions.
3 changes: 2 additions & 1 deletion gui/wxpython/.flake8
Expand Up @@ -9,7 +9,6 @@ ignore =
E741, # ambiguous variable name 'l'
F403, # 'from gmodeler.model import *' used; unable to detect undefined names
F405, # '_' may be undefined, or defined from star imports: gmodeler.model
F821, # undefined name '_'
F841, # local variable 'dc' is assigned to but never used
E117, # over-indented
E122, # continuation line missing indentation or outdented
Expand Down Expand Up @@ -56,3 +55,5 @@ exclude =
ctypes,
pydispatch,
testsuite,
builtins =
_
10 changes: 0 additions & 10 deletions gui/wxpython/core/gcmd.py
Expand Up @@ -335,14 +335,6 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0):
return ''.join(y)


def send_all(p, data):
while len(data):
sent = p.send(data)
if sent is None:
raise Exception(message)
data = buffer(data, sent)


class Command:
"""Run command in separate thread. Used for commands launched
on the background.
Expand Down Expand Up @@ -511,8 +503,6 @@ def __GetError(self):

for type, msg in self.__ProcessStdErr():
if type == 'ERROR':
if _enc:
return unicode(msg, _enc)
return msg

return ''
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/render.py
Expand Up @@ -175,7 +175,7 @@ def Render(self, env=None):
first = False
else:
self.renderMgr.Render(self.cmd, env)
except GException:
except GException as e:
sys.stderr.write(
_("Command '%s' failed\n") %
self.GetCmd(
Expand Down
6 changes: 2 additions & 4 deletions gui/wxpython/gcp/manager.py
Expand Up @@ -1517,13 +1517,11 @@ def ReadGCPs(self):

if not sourceMapWin:
GError(parent=self,
message="%s. %s%s" % (_("source mapwin not defined"),
os.linesep, err))
message=_("source mapwin not defined"))

if not targetMapWin:
GError(parent=self,
message="%s. %s%s" % (_("target mapwin not defined"),
os.linesep, err))
message=_("target mapwin not defined"))

try:
f = open(self.file['points'], 'r')
Expand Down
9 changes: 2 additions & 7 deletions gui/wxpython/gui_core/ghelp.py
Expand Up @@ -24,12 +24,6 @@
import textwrap
import sys
import six

if sys.version_info.major == 2:
_unichr = unichr
else:
_unichr = chr

import wx
from wx.html import HtmlWindow
try:
Expand All @@ -44,6 +38,7 @@
from wx import AboutBox

import grass.script as grass
from grass.exceptions import CalledModuleError

# needed just for testing
if __name__ == '__main__':
Expand Down Expand Up @@ -924,7 +919,7 @@ def _grassDevTeam(start):
end = date.today().year

return '%(c)s %(start)s-%(end)s by the GRASS Development Team' % {
'c': _unichr(169), 'start': start, 'end': end}
'c': chr(169), 'start': start, 'end': end}


def main():
Expand Down
21 changes: 2 additions & 19 deletions gui/wxpython/gui_core/goutput.py
Expand Up @@ -19,7 +19,6 @@
@author Anna Kratochvilova <kratochanna gmail.com> (refactoring)
"""

import os
import textwrap

import wx
Expand All @@ -32,7 +31,7 @@
from grass.script.setup import set_gui_path
set_gui_path()

from core.gcmd import GError, EncodeString
from core.gcmd import GError
from core.gconsole import GConsole, \
EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, EVT_CMD_RUN, EVT_CMD_DONE, \
Notification
Expand Down Expand Up @@ -671,23 +670,7 @@ def AddTextWrapped(self, txt, wrap=None):
self.AddText(seg)
else:
self.linePos = self.GetCurrentPos()

try:
self.AddText(txt)
except UnicodeDecodeError:
# TODO: this might be dead code for Py3, txt is already unicode?
enc = UserSettings.Get(
group='atm', key='encoding', subkey='value')
if enc:
txt = unicode(txt, enc, errors='replace')
elif 'GRASS_DB_ENCODING' in os.environ:
txt = unicode(
txt, os.environ['GRASS_DB_ENCODING'],
errors='replace')
else:
txt = EncodeString(txt)

self.AddText(txt)
self.AddText(txt)

# reset output window to read only
self.SetReadOnly(True)
Expand Down
6 changes: 2 additions & 4 deletions gui/wxpython/image2target/ii2t_manager.py
Expand Up @@ -1510,13 +1510,11 @@ def ReadGCPs(self):

if not sourceMapWin:
GError(parent=self,
message="%s. %s%s" % (_("source mapwin not defined"),
os.linesep, err))
message=_("source mapwin not defined"))

if not targetMapWin:
GError(parent=self,
message="%s. %s%s" % (_("target mapwin not defined"),
os.linesep, err))
message=_("target mapwin not defined"))

try:
f = open(self.file['control_points'], 'r')
Expand Down

0 comments on commit f02ee9c

Please sign in to comment.