From d2be76be90015d973d5defab89839299e807494d Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 21 Oct 2024 12:50:41 -0400 Subject: [PATCH 1/2] fixed 722 --- .flake8 | 1 - scripts/d.rast.edit/d.rast.edit.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.flake8 b/.flake8 index 90686370f67..719f93d3134 100644 --- a/.flake8 +++ b/.flake8 @@ -108,7 +108,6 @@ per-file-ignores = scripts/i.pansharpen/i.pansharpen.py: E722, E501 scripts/r.in.srtm/r.in.srtm.py: E722 scripts/r.fillnulls/r.fillnulls.py: E722 - scripts/d.rast.edit/d.rast.edit.py: E722 scripts/v.what.strds/v.what.strds.py: E501 # Line too long (esp. module interface definitions) scripts/*/*.py: E501 diff --git a/scripts/d.rast.edit/d.rast.edit.py b/scripts/d.rast.edit/d.rast.edit.py index ea6cc1e46bf..0cb52d3003e 100755 --- a/scripts/d.rast.edit/d.rast.edit.py +++ b/scripts/d.rast.edit/d.rast.edit.py @@ -666,7 +666,7 @@ def get_color(self, val): if val not in self.colors: try: self.force_color(val) - except: + except ValueError: self.colors[val] = "#ffffff" return self.colors[val] From 2321064bdb68c575fda7fdbd7be0fba98e33e243 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Mon, 21 Oct 2024 16:53:49 -0400 Subject: [PATCH 2/2] updated force colors --- scripts/d.rast.edit/d.rast.edit.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/scripts/d.rast.edit/d.rast.edit.py b/scripts/d.rast.edit/d.rast.edit.py index 0cb52d3003e..8b36c5a9198 100755 --- a/scripts/d.rast.edit/d.rast.edit.py +++ b/scripts/d.rast.edit/d.rast.edit.py @@ -647,28 +647,9 @@ def update_status(self, row, col): if self.angles: self.status["aspect"] = self.angles[row][col] - def force_color(self, val): - run("g.region", rows=1, cols=1) - run("r.mapcalc", expression="%s = %d" % (self.tempmap, val)) - run("r.colors", map=self.tempmap, rast=self.inmap) - run("r.out.ppm", input=self.tempmap, out=self.tempfile) - run("g.remove", flags="f", type="raster", name=self.tempmap) - - tempimg = wx.Image(self.tempfile) - gs.try_remove(self.tempfile) - - rgb = tempimg.get(0, 0) - color = "#%02x%02x%02x" % rgb - self.colors[val] = color - tempimg.delete() - def get_color(self, val): if val not in self.colors: - try: - self.force_color(val) - except ValueError: - self.colors[val] = "#ffffff" - + self.colors[val] = "#ffffff" return self.colors[val] def refresh_canvas(self):