From 00732bc0c0b37bf2499110a992bac02a57c822b6 Mon Sep 17 00:00:00 2001 From: ShubhamSwati Date: Sun, 16 May 2021 02:31:48 +0530 Subject: [PATCH 1/4] i.in.spotvgt.py: fixed E722 do not use bare 'except' warning --- scripts/.flake8 | 2 +- scripts/i.in.spotvgt/i.in.spotvgt.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/.flake8 b/scripts/.flake8 index 87c27e2a455..e6870d5291e 100644 --- a/scripts/.flake8 +++ b/scripts/.flake8 @@ -34,7 +34,7 @@ per-file-ignores = v.in.wfs/v.in.wfs.py: E722 r.plane/r.plane.py: E722 v.what.strds/v.what.strds.py: E722 - i.in.spotvgt/i.in.spotvgt.py: E722 + max-line-length = 88 exclude = diff --git a/scripts/i.in.spotvgt/i.in.spotvgt.py b/scripts/i.in.spotvgt/i.in.spotvgt.py index 8af40b2ebf8..8c1f6afcf3f 100755 --- a/scripts/i.in.spotvgt/i.in.spotvgt.py +++ b/scripts/i.in.spotvgt/i.in.spotvgt.py @@ -155,7 +155,8 @@ def main(): s = p.communicate()[0] if s == "application/x-zip": gscript.fatal(_("Please extract %s before import.") % infile) - except: + # code changed here, Exception included instead of bare except + except Exception: pass # create VRT header for NDVI From e98d1b846950f4b0b34bd11116c3c7644ac81d58 Mon Sep 17 00:00:00 2001 From: ShubhamSwati Date: Sun, 30 May 2021 14:32:35 +0530 Subject: [PATCH 2/4] r.unpack.py:fixed E722 do not use bare 'except' warning --- scripts/.flake8 | 2 +- scripts/r.unpack/r.unpack.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/.flake8 b/scripts/.flake8 index e6870d5291e..7cd4f9e3724 100644 --- a/scripts/.flake8 +++ b/scripts/.flake8 @@ -19,7 +19,7 @@ per-file-ignores = v.report/v.report.py: F841 db.out.ogr/db.out.ogr.py: F841 g.extension/g.extension.py: F841, E722 - r.unpack/r.unpack.py: E722 + v.unpack/v.unpack.py: F841, E722 v.import/v.import.py: F841, E722 db.univar/db.univar.py: E741 diff --git a/scripts/r.unpack/r.unpack.py b/scripts/r.unpack/r.unpack.py index cc9c995278c..ed0b4c8730b 100644 --- a/scripts/r.unpack/r.unpack.py +++ b/scripts/r.unpack/r.unpack.py @@ -73,10 +73,9 @@ def main(): os.chdir(tmp_dir) tar = tarfile.TarFile.open(name=input_base, mode="r") try: - data_names = [ - tarinfo.name for tarinfo in tar.getmembers() if "/" not in tarinfo.name - ] - except: + data_names = [tarinfo.name for tarinfo in tar.getmembers() if "/" not in tarinfo.name] + # code changed here, Exception included instead of bare except + except Exception: grass.fatal(_("Pack file unreadable")) if flags["p"]: From 4b06fab3e9b12bccdc22db83fc815e5f70348eb9 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Tue, 14 Feb 2023 13:01:08 -0500 Subject: [PATCH 3/4] Apply changes from review --- scripts/.flake8 | 2 -- scripts/i.in.spotvgt/i.in.spotvgt.py | 1 - scripts/r.unpack/r.unpack.py | 1 - 3 files changed, 4 deletions(-) diff --git a/scripts/.flake8 b/scripts/.flake8 index 7cd4f9e3724..b6da2a587cd 100644 --- a/scripts/.flake8 +++ b/scripts/.flake8 @@ -19,7 +19,6 @@ per-file-ignores = v.report/v.report.py: F841 db.out.ogr/db.out.ogr.py: F841 g.extension/g.extension.py: F841, E722 - v.unpack/v.unpack.py: F841, E722 v.import/v.import.py: F841, E722 db.univar/db.univar.py: E741 @@ -34,7 +33,6 @@ per-file-ignores = v.in.wfs/v.in.wfs.py: E722 r.plane/r.plane.py: E722 v.what.strds/v.what.strds.py: E722 - max-line-length = 88 exclude = diff --git a/scripts/i.in.spotvgt/i.in.spotvgt.py b/scripts/i.in.spotvgt/i.in.spotvgt.py index 8c1f6afcf3f..e0e0911c81a 100755 --- a/scripts/i.in.spotvgt/i.in.spotvgt.py +++ b/scripts/i.in.spotvgt/i.in.spotvgt.py @@ -155,7 +155,6 @@ def main(): s = p.communicate()[0] if s == "application/x-zip": gscript.fatal(_("Please extract %s before import.") % infile) - # code changed here, Exception included instead of bare except except Exception: pass diff --git a/scripts/r.unpack/r.unpack.py b/scripts/r.unpack/r.unpack.py index ed0b4c8730b..48a44b21b11 100644 --- a/scripts/r.unpack/r.unpack.py +++ b/scripts/r.unpack/r.unpack.py @@ -74,7 +74,6 @@ def main(): tar = tarfile.TarFile.open(name=input_base, mode="r") try: data_names = [tarinfo.name for tarinfo in tar.getmembers() if "/" not in tarinfo.name] - # code changed here, Exception included instead of bare except except Exception: grass.fatal(_("Pack file unreadable")) From 37e03c87417c2d8a56b87ff74cd15694371dc968 Mon Sep 17 00:00:00 2001 From: Vaclav Petras Date: Tue, 14 Feb 2023 13:47:29 -0500 Subject: [PATCH 4/4] Apply Black --- scripts/r.unpack/r.unpack.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/r.unpack/r.unpack.py b/scripts/r.unpack/r.unpack.py index 48a44b21b11..cb622352700 100644 --- a/scripts/r.unpack/r.unpack.py +++ b/scripts/r.unpack/r.unpack.py @@ -73,7 +73,9 @@ def main(): os.chdir(tmp_dir) tar = tarfile.TarFile.open(name=input_base, mode="r") try: - data_names = [tarinfo.name for tarinfo in tar.getmembers() if "/" not in tarinfo.name] + data_names = [ + tarinfo.name for tarinfo in tar.getmembers() if "/" not in tarinfo.name + ] except Exception: grass.fatal(_("Pack file unreadable"))