Skip to content

Commit

Permalink
Merge branch 'main' into gui_core_722
Browse files Browse the repository at this point in the history
  • Loading branch information
arohanajit authored Oct 1, 2024
2 parents b3a7c71 + e427da0 commit b74d2b0
Show file tree
Hide file tree
Showing 54 changed files with 81 additions and 101 deletions.
1 change: 0 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +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/image2target/*: F841, E722
gui/wxpython/image2target/g.gui.image2target.py: E501, F841
gui/wxpython/iscatt/*: F841, E722, F405, F403
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
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/forms.py
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 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
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/widgets.py
Original file line number Diff line number Diff line change
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
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
4 changes: 2 additions & 2 deletions gui/wxpython/image2target/ii2t_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,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 @@ -1627,7 +1627,7 @@ def ReadGCPs(self):
GError(parent=self, message=_("target mapwin not defined"))

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

for line in f:
Expand Down
12 changes: 5 additions & 7 deletions gui/wxpython/location_wizard/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ def __readData(self):
"""Get georeferencing information from tables in $GISBASE/etc/proj"""

# read projection and parameters
f = open(os.path.join(globalvar.ETCDIR, "proj", "parms.table"), "r")
f = open(os.path.join(globalvar.ETCDIR, "proj", "parms.table"))
self.projections = {}
self.projdesc = {}
for line in f:
Expand All @@ -2566,7 +2566,7 @@ def __readData(self):
f.close()

# read datum definitions
f = open(os.path.join(globalvar.ETCDIR, "proj", "datum.table"), "r")
f = open(os.path.join(globalvar.ETCDIR, "proj", "datum.table"))
self.datums = {}
paramslist = []
for line in f:
Expand All @@ -2584,7 +2584,7 @@ def __readData(self):
f.close()

# read Earth-based ellipsiod definitions
f = open(os.path.join(globalvar.ETCDIR, "proj", "ellipse.table"), "r")
f = open(os.path.join(globalvar.ETCDIR, "proj", "ellipse.table"))
self.ellipsoids = {}
for line in f:
line = line.expandtabs(1)
Expand All @@ -2600,9 +2600,7 @@ def __readData(self):
f.close()

# read Planetary ellipsiod definitions
f = open(
os.path.join(globalvar.ETCDIR, "proj", "ellipse.table.solar.system"), "r"
)
f = open(os.path.join(globalvar.ETCDIR, "proj", "ellipse.table.solar.system"))
self.planetary_ellipsoids = {}
for line in f:
line = line.expandtabs(1)
Expand All @@ -2618,7 +2616,7 @@ def __readData(self):
f.close()

# read projection parameter description and parsing table
f = open(os.path.join(globalvar.ETCDIR, "proj", "desc.table"), "r")
f = open(os.path.join(globalvar.ETCDIR, "proj", "desc.table"))
self.paramdesc = {}
for line in f:
line = line.strip()
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/mapdisp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __init__(self, giface, cmdfile=None, mapfile=None):
self.renderMgr = RenderMapMgr(self)

# update legend file variable with the one d.mon uses
with open(monFile["env"], "r") as f:
with open(monFile["env"]) as f:
lines = f.readlines()
for line in lines:
if "GRASS_LEGEND_FILE" in line:
Expand All @@ -123,7 +123,7 @@ def GetLayersFromCmdFile(self):

nlayers = 0
try:
fd = open(self.cmdfile, "r")
fd = open(self.cmdfile)
lines = fd.readlines()
fd.close()
# detect d.out.file, delete the line from the cmd file and export
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/modules/colorrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ def OnLoadRulesFile(self, event):

self.rulesPanel.Clear()

fd = open(path, "r")
fd = open(path)
self.ReadColorTable(ctable=fd.read())
fd.close()

Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/modules/mcalc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def OnLoadExpression(self, event):
return

try:
fobj = open(path, "r")
fobj = open(path)
mctxt = fobj.read()
finally:
fobj.close()
Expand Down
8 changes: 4 additions & 4 deletions gui/wxpython/photo2image/ip2i_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(
self.source_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 @@ -429,7 +429,7 @@ def __init__(
import re

try:
fc = open(self.file["camera"], mode="r")
fc = open(self.file["camera"])
fc_count = 0
for line in fc:
fc_count += 1
Expand All @@ -438,7 +438,7 @@ def __init__(
numberOfFiducial = int(line.split()[-1])
dataFiducialX = []
dataFiducialY = []
fc = open(self.file["camera"], mode="r")
fc = open(self.file["camera"])
fc_count = 0
for line in fc:
fc_count += 1
Expand Down Expand Up @@ -955,7 +955,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/psmap/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ def GetImageOrigSize(self, imagePath):
# if eps, read info from header
if os.path.splitext(fileName)[1].lower() == ".eps":
bbInfo = "%%BoundingBox"
file = open(imagePath, "r")
file = open(imagePath)
w = h = 0
while file:
line = file.readline()
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/vnet/vnet_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ def GetLastModified(self):
"head",
)
try:
head = open(headPath, "r")
head = open(headPath)
for line in head:
i = line.find(
"MAP DATE:",
Expand Down
2 changes: 1 addition & 1 deletion imagery/i.atcorr/create_iwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def read_input(csvfile):
first column is wavelength
values are those of the discrete band filter functions
"""
infile = open(csvfile, "r")
infile = open(csvfile)

# get number of bands and band names
bands = infile.readline().split(",")
Expand Down
8 changes: 4 additions & 4 deletions lib/init/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def create_gisrc(tmpdir, gisrcrc):
def read_gisrc(filename):
kv = {}
try:
f = open(filename, "r")
f = open(filename)
except OSError:
return kv

Expand All @@ -522,7 +522,7 @@ def write_gisrcrc(gisrcrc, gisrc, skip_variable=None):
"""Reads gisrc file and write to gisrcrc"""
debug("Reading %s" % gisrc)
number = 0
with open(gisrc, "r") as f:
with open(gisrc) as f:
lines = f.readlines()
for line in lines:
if skip_variable in line:
Expand All @@ -535,7 +535,7 @@ def write_gisrcrc(gisrcrc, gisrc, skip_variable=None):

def read_env_file(path):
kv = {}
f = open(path, "r")
f = open(path)
for line in f:
k, v = line.split(":", 1)
kv[k.strip()] = v.strip()
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def set_language(grass_config_dir):

# Override value is stored in wxGUI preferences file.
try:
with open(os.path.join(grass_config_dir, "wx.json"), "r") as json_file:
with open(os.path.join(grass_config_dir, "wx.json")) as json_file:
try:
language = json.load(json_file)["language"]["locale"]["lc_all"]
except KeyError:
Expand Down
4 changes: 2 additions & 2 deletions man/build_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def check_for_desc_override(basename):


def read_file(name):
f = open(name, "r")
f = open(name)
s = f.read()
f.close()
return s
Expand Down Expand Up @@ -476,7 +476,7 @@ def write_html_footer(f, index_url, year=None):


def get_desc(cmd):
f = open(cmd, "r")
f = open(cmd)
while True:
line = f.readline()
if not line:
Expand Down
Loading

0 comments on commit b74d2b0

Please sign in to comment.