Skip to content

Commit

Permalink
Merge branch 'main' into 405-core_c
Browse files Browse the repository at this point in the history
  • Loading branch information
arohanajit authored Oct 1, 2024
2 parents 90d4cfd + 13cda73 commit 8122126
Show file tree
Hide file tree
Showing 59 changed files with 124 additions and 157 deletions.
7 changes: 0 additions & 7 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ per-file-ignores =
doc/python/m.distance.py: E501
doc/gui/wxpython/example/dialogs.py: F401
gui/scripts/d.wms.py: E501
gui/wxpython/gcp/manager.py: E722
gui/wxpython/gui_core/*: E722
gui/wxpython/gui_core/dialogs.py: E722
gui/wxpython/gui_core/forms.py: E722
gui/wxpython/gui_core/ghelp.py: E722
gui/wxpython/gui_core/gselect.py: E722
gui/wxpython/gui_core/widgets.py: E722
gui/wxpython/image2target/*: F841, E722
gui/wxpython/image2target/g.gui.image2target.py: E501, F841
gui/wxpython/iscatt/*: F841, E722
Expand Down
2 changes: 1 addition & 1 deletion display/d.mon/render_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def remove_mapfile(mapfile):
# read environment variables from file
def read_env_file(env_file):
width = height = legfile = None
fd = open(env_file, "r")
fd = open(env_file)
if fd is None:
grass.fatal("Unable to open file '{0}'".format(env_file))
lines = fd.readlines()
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gui/wxpython/core/gconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ def load_source(modname, filename):
skipInterface = True
if os.path.splitext(command[0])[1] in {".py", ".sh"}:
try:
with open(command[0], "r") as sfile:
with open(command[0]) as sfile:
for line in sfile:
if len(line) < 3:
continue
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def GetWindow(self):
env["GISDBASE"], env["LOCATION_NAME"], env["MAPSET"], "WIND"
)
try:
windfile = open(filename, "r")
windfile = open(filename)
except OSError as e:
sys.exit(
_("Error: Unable to open '%(file)s'. Reason: %(ret)s. wxGUI exited.\n")
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def update_nested_dict_by_dict(dictionary, update):
return dictionary

try:
with open(self.filePath, "r") as f:
with open(self.filePath) as f:
update = json.load(f, object_hook=settings_JSON_decode_hook)
update_nested_dict_by_dict(settings, update)
except json.JSONDecodeError as e:
Expand All @@ -942,7 +942,7 @@ def _readLegacyFile(self, settings=None):
settings = self.userSettings

try:
fd = open(self.legacyFilePath, "r")
fd = open(self.legacyFilePath)
except OSError:
sys.stderr.write(
_("Unable to read settings file <%s>\n") % self.legacyFilePath
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def on_modified(self, event):
self.modified_time = timestamp
# wait to make sure file writing is done
time.sleep(0.1)
with open(event.src_path, "r") as f:
with open(event.src_path) as f:
gisrc = {}
for line in f:
key, val = line.split(":")
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ def read(self, parent):
:return: list of map layers
"""
try:
file = open(self.filename, "r")
file = open(self.filename)
except OSError:
wx.MessageBox(
parent=parent,
Expand Down
18 changes: 2 additions & 16 deletions gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(self, parent, giface):
self.target_gisrc = os.environ["GISRC"]
self.gisrc_dict = {}
try:
f = open(self.target_gisrc, "r")
f = open(self.target_gisrc)
for line in f:
line = line.replace("\n", "").strip()
if len(line) < 1:
Expand Down Expand Up @@ -880,20 +880,6 @@ def OnSrcSelection(self, event):
else:
wx.FindWindowById(wx.ID_FORWARD).Enable(True)

try:
# set computational region to match selected map and zoom display
# to region
if maptype == "raster":
p = RunCommand("g.region", "raster=src_map")
elif maptype == "vector":
p = RunCommand("g.region", "vector=src_map")

if p.returncode == 0:
print("returncode = ", str(p.returncode))
self.parent.Map.region = self.parent.Map.GetRegion()
except:
pass

def OnTgtRastSelection(self, event):
"""Source map to display selected"""
global tgt_map
Expand Down Expand Up @@ -1603,7 +1589,7 @@ def ReadGCPs(self):
GError(parent=self, message=_("target mapwin not defined"))

try:
f = open(self.file["points"], "r")
f = open(self.file["points"])
GCPcnt = 0

for line in f:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def _substituteFile(self, item, params=None, checkOnly=False):

for finput in self.fileInput:
# read lines
fd = open(finput, "r")
fd = open(finput)
try:
data = self.fileInput[finput] = fd.read()
finally:
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ def _filter(self, data):
try:
if re.compile(self.flt_pattern).search(dt):
flt_data.append(dt)
except:
except re.error:
pass

return flt_data
Expand Down Expand Up @@ -1656,7 +1656,7 @@ def OnFilter(self, event):
try:
if re.compile(event.GetString()).search(layer):
list.append(layer)
except:
except re.error:
pass
list = naturally_sorted(list)

Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ def __init__(self, parent, giface, task, id=wx.ID_ANY, frame=None, *args, **kwar
# check wildcard
try:
fExt = os.path.splitext(p.get("key_desc", ["*.*"])[0])[1]
except:
except IndexError:
fExt = None
if not fExt:
fMask = "*"
Expand Down Expand Up @@ -2588,7 +2588,7 @@ def OnFileLoad(self, event):

data = ""
try:
f = open(path, "r")
f = open(path)
except OSError as e:
gcmd.GError(
parent=self,
Expand Down
18 changes: 9 additions & 9 deletions gui/wxpython/gui_core/ghelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _pageCopyright(self):
"""Copyright information"""
copyfile = os.path.join(os.getenv("GISBASE"), "COPYING")
if os.path.exists(copyfile):
copyrightFile = open(copyfile, "r")
copyrightFile = open(copyfile)
copytext = copyrightFile.read()
copyrightFile.close()
else:
Expand Down Expand Up @@ -303,7 +303,7 @@ def _pageLicense(self):
"""Licence about"""
licfile = os.path.join(os.getenv("GISBASE"), "GPL.TXT")
if os.path.exists(licfile):
licenceFile = open(licfile, "r")
licenceFile = open(licfile)
license = "".join(licenceFile.readlines())
licenceFile.close()
else:
Expand Down Expand Up @@ -566,15 +566,15 @@ def _langString(self, k, v):
allStr = "%s :" % k.upper()
try:
allStr += _(" %d translated") % v["good"]
except:
except KeyError:
pass
try:
allStr += _(" %d fuzzy") % v["fuzzy"]
except:
except KeyError:
pass
try:
allStr += _(" %d untranslated") % v["bad"]
except:
except KeyError:
pass
return allStr

Expand All @@ -589,7 +589,7 @@ def _langBox(self, par, k, v):
)
tgood.SetForegroundColour(wx.Colour(35, 142, 35))
langBox.Add(tgood)
except:
except KeyError:
tgood = StaticText(parent=par, id=wx.ID_ANY, label="")
langBox.Add(tgood)
try:
Expand All @@ -598,7 +598,7 @@ def _langBox(self, par, k, v):
)
tfuzzy.SetForegroundColour(wx.Colour(255, 142, 0))
langBox.Add(tfuzzy)
except:
except KeyError:
tfuzzy = StaticText(parent=par, id=wx.ID_ANY, label="")
langBox.Add(tfuzzy)
try:
Expand All @@ -607,7 +607,7 @@ def _langBox(self, par, k, v):
)
tbad.SetForegroundColour(wx.Colour(255, 0, 0))
langBox.Add(tbad)
except:
except KeyError:
tbad = StaticText(parent=par, id=wx.ID_ANY, label="")
langBox.Add(tbad)
return langBox
Expand Down Expand Up @@ -844,7 +844,7 @@ def fillContentsFromFile(self, htmlFile, skipDescription=True):
contents.append(line)
self.SetPage("".join(contents))
self.loaded = True
except: # The Manual file was not found
except Exception: # The Manual file was not found
self.loaded = False


Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def GetElementList(self, elements=None, exclude=False):
try:
self.seltree.EnsureVisible(item)
self.seltree.SelectItem(item)
except:
except Exception:
pass

def _getElementList(self, element, mapsets=None, elements=None, exclude=False):
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ def _validate(self, win):
if text:
try:
datetime.strptime(text, "%Y-%m-%d")
except:
except ValueError:
self._notvalid()
return False

Expand Down Expand Up @@ -1566,7 +1566,7 @@ def _loadSettings(self):
return data

try:
fd = open(self.settingsFile, "r")
fd = open(self.settingsFile)
except OSError:
return data

Expand Down
3 changes: 2 additions & 1 deletion gui/wxpython/image2target/g.gui.image2target.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def main():

app = wx.App()

wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())
GCPWizard(parent=None, giface=StandaloneGrassInterface())

app.MainLoop()


Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/image2target/ii2t_gis_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def _readGisRC(self):

if gisrc and os.path.isfile(gisrc):
try:
rc = open(gisrc, "r")
rc = open(gisrc)
for line in rc:
try:
key, val = line.split(":", 1)
Expand Down
Loading

0 comments on commit 8122126

Please sign in to comment.