Skip to content

Commit

Permalink
style: Fixes sys-exit-alias (PLR1722)
Browse files Browse the repository at this point in the history
Using  `ruff check --select "PLR1722" --unsafe-fixes --output-format=concise --fix`.
  • Loading branch information
echoix committed Jun 30, 2024
1 parent b5bfcd5 commit 1bffcf6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion man/build_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_module_man_html_file_path(module):
except:
pass
if not key:
exit("Empty keyword from file %s line: %s" % (fname, lines[index_keys]))
sys.exit("Empty keyword from file %s line: %s" % (fname, lines[index_keys]))
if key not in keywords.keys():
keywords[key] = []
keywords[key].append(fname)
Expand Down
7 changes: 4 additions & 3 deletions python/grass/temporal/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:authors: Soeren Gebbert
"""

import sys
from .core import (
get_tgis_message_interface,
get_current_mapset,
Expand Down Expand Up @@ -320,7 +321,7 @@ def run_mapcalc2d(expr):
"r.mapcalc", expression=expr, overwrite=gscript.overwrite(), quiet=True
)
except CalledModuleError:
exit(1)
sys.exit(1)


def run_mapcalc3d(expr):
Expand All @@ -330,7 +331,7 @@ def run_mapcalc3d(expr):
"r3.mapcalc", expression=expr, overwrite=gscript.overwrite(), quiet=True
)
except CalledModuleError:
exit(1)
sys.exit(1)


def run_vector_extraction(input, output, layer, type, where):
Expand All @@ -347,4 +348,4 @@ def run_vector_extraction(input, output, layer, type, where):
quiet=True,
)
except CalledModuleError:
exit(1)
sys.exit(1)
5 changes: 3 additions & 2 deletions python/grass/temporal/mapcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:authors: Soeren Gebbert
"""

import sys
import copy
from datetime import datetime
from multiprocessing import Process
Expand Down Expand Up @@ -412,7 +413,7 @@ def _run_mapcalc2d(expr):
"r.mapcalc", expression=expr, overwrite=gscript.overwrite(), quiet=True
)
except CalledModuleError:
exit(1)
sys.exit(1)


###############################################################################
Expand All @@ -425,7 +426,7 @@ def _run_mapcalc3d(expr):
"r3.mapcalc", expression=expr, overwrite=gscript.overwrite(), quiet=True
)
except CalledModuleError:
exit(1)
sys.exit(1)


###############################################################################
Expand Down
10 changes: 5 additions & 5 deletions raster/r.topidx/arc_to_gridatb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ def match(pattern, string):

if len(sys.argv) != 3 or re.match("^-*help", sys.argv[1]):
print("Usage: arc.to.gridatb.py arc_file gridatb_file")
exit()
sys.exit()

infname = sys.argv[1]
outfname = sys.argv[2]

if not os.path.isfile(infname):
print(f"{infname}: File not found")
exit()
sys.exit()

if os.path.isfile(outfname):
print(f"{outfname}: File already exists")
exit()
sys.exit()

inf = open(infname)

Expand All @@ -54,14 +54,14 @@ def match(pattern, string):
else:
print(f"{infname}: Invalid input file format")
inf.close()
exit()
sys.exit()
if head == 0x3F:
break

if head != 0x3F:
print(f"{infname}: Invalid input file format")
inf.close()
exit()
sys.exit()

outf = open(outfname, "w")
outf.write(
Expand Down
8 changes: 4 additions & 4 deletions raster/r.topidx/gridatb_to_arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
or re.match("^-*help", sys.argv[1])
):
print("Usage: gridatb.to.arc.py gridatb_file arc_file [xllcorner yllcorner]")
exit()
sys.exit()

xllcorner = 0
yllcorner = 0
Expand All @@ -23,11 +23,11 @@

if not os.path.isfile(infname):
print(f"{infname}: File not found")
exit()
sys.exit()

if os.path.isfile(outfname):
print(f"{outfname}: File already exists")
exit()
sys.exit()

inf = open(infname)

Expand All @@ -37,7 +37,7 @@
if not m:
print(f"{infname}: Invalid input file format")
inf.close()
exit()
sys.exit()

ncols = m.group(1)
nrows = m.group(2)
Expand Down

0 comments on commit 1bffcf6

Please sign in to comment.