Skip to content

Commit

Permalink
style: Fix all flake8-gettext (INT) errors (INT001, INT002, INT003)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Jul 14, 2024
1 parent 3cd99a0 commit f3e7a4f
Show file tree
Hide file tree
Showing 27 changed files with 116 additions and 144 deletions.
37 changes: 3 additions & 34 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,6 @@ ignore = [

[tool.ruff.lint.per-file-ignores]
# See https://docs.astral.sh/ruff/settings/#lint_per-file-ignores
# "INT002", # f-string-in-get-text-func-call
# "INT001", # format-in-get-text-func-call
# "INT003", # printf-in-get-text-func-call
# Ignore `E402` (import violations) in all `__init__.py` files
"*/testsuite/**.py" = ["PT009", "PT027"]
"__init__.py" = ["E402"]
Expand All @@ -316,7 +313,6 @@ ignore = [
"gui/wxpython/tplot/frame.py" = ["FLY002"]
"gui/wxpython/wxplot/profile.py" = ["NPY001"]
"lib/imagery/testsuite/test_imagery_sigsetfile.py" = ["FURB152"]
"lib/init/grass.py" = ["INT003"]
"python/grass/__init__.py" = ["PYI056"]
"python/grass/exp*/tests/grass_script_mapset_session_test.py" = ["SIM117"]
"python/grass/exp*/tests/grass_script_tmp_mapset_session_test.py" = ["SIM117"]
Expand All @@ -335,43 +331,16 @@ ignore = [
"python/grass/pygrass/vector/testsuite/test_vector3d.py" = ["NPY002"]
"raster3d/r3.flow/testsuite/r3flow_test.py" = ["FLY002"]
"raster3d/r3.gradient/testsuite/r3gradient_test.py" = ["FLY002"]
"scripts/d.polar/d.polar.py" = ["FURB154", "INT002"]
"scripts/g.extension.all/g.extension.all.py" = ["INT002"]
"scripts/g.extension/g.extension.py" = ["INT002"]
"scripts/i.oif/i.oif.py" = ["INT003"]
"scripts/i.pansharpen/i.pansharpen.py" = ["FLY002", "INT003"]
"scripts/i.spectral/i.spectral.py" = ["FLY002", "INT002"]
"scripts/d.polar/d.polar.py" = ["FURB154"]
"scripts/i.pansharpen/i.pansharpen.py" = ["FLY002"]
"scripts/i.spectral/i.spectral.py" = ["FLY002"]
"scripts/r.in.srtm/r.in.srtm.py" = ["FLY002"]
"scripts/r.in.wms/wms_base.py" = ["INT003"]
"scripts/r.in.wms/wms_cap_parsers.py" = ["INT003"]
"scripts/r.in.wms/wms_drv.py" = ["INT003"]
"scripts/r.in.wms/wms_gdal_drv.py" = ["INT003"]
"scripts/r.pack/r.pack.py" = ["INT003"]
"scripts/r.tileset/r.tileset.py" = ["INT003"]
"scripts/r.unpack/r.unpack.py" = ["INT002"]
"scripts/v.rast.stats/v.rast.stats.py" = ["INT002"]
"scripts/v.to.lines/v.to.lines.py" = ["INT003"]
"scripts/v.unpack/v.unpack.py" = ["INT002", "INT003"]
"scripts/v.what.strds/v.what.strds.py" = ["INT003"]
"temporal/t.rast.accdetect/t.rast.accdetect.py" = ["INT003"]
"temporal/t.rast.accumulate/t.rast.accumulate.py" = ["INT003"]
"temporal/t.rast.algebra/testsu*/*_algebra_arithmetic.py" = ["FLY002"]
"temporal/t.rast.export/t.rast.export.py" = ["INT002"]
"temporal/t.rast.gapfill/t.rast.gapfill.py" = ["INT003"]
"temporal/t.rast.list/t.rast.list.py" = ["INT002"]
"temporal/t.rast.out.vtk/t.rast.out.vtk.py" = ["INT003"]
"temporal/t.rast.series/t.rast.series.py" = ["INT002"]
"temporal/t.rast.to.rast3/t.rast.to.rast3.py" = ["INT003"]
"temporal/t.rast.what/t.rast.what.py" = ["INT003"]
"temporal/t.register/testsu*/*_raster_different_local.py" = ["FLY002"]
"temporal/t.register/testsu*/*_raster_mapmetadata.py" = ["FLY002"]
"temporal/t.register/testsuite/test_t_register_raster.py" = ["FLY002"]
"temporal/t.register/testsuite/test_t_register_raster_file.py" = ["FLY002"]
"temporal/t.remove/t.remove.py" = ["INT002", "INT003"]
"temporal/t.unregister/t.unregister.py" = ["INT003"]
"temporal/t.vect.observe.strds/t.vect.observe.strds.py" = ["INT003"]
"utils/generate_release_notes.py" = ["PGH004"]
"utils/mkhtml.py" = ["INT002"]
"vector/v.fill.holes/examples.ipynb" = ["PTH201"]

[tool.ruff.lint.flake8-import-conventions.extend-aliases]
Expand Down
8 changes: 4 additions & 4 deletions scripts/d.polar/d.polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ def main():
gcore.fatal(
_(
"EPS output file path <{}>, doesn't exists. "
"Set new output file path.".format(eps)
)
"Set new output file path."
).format(eps)
)
else:
eps = basename(eps, "eps") + ".eps"
Expand All @@ -445,8 +445,8 @@ def main():
gcore.fatal(
_(
"option <output>: <{}> exists. To overwrite, "
"use the --overwrite flag.".format(eps)
)
"use the --overwrite flag."
).format(eps)
)

# check if we have xgraph (if no EPS output requested)
Expand Down
34 changes: 15 additions & 19 deletions scripts/g.extension.all/g.extension.all.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
_(
"Download file from <{url}>, "
"return status code {code}, "
"{desc}".format(
url=url,
code=response.code,
desc=desc,
),
"{desc}"
).format(
url=url,
code=response.code,
desc=desc,
),
)
if response_format not in response.getheader("Content-Type"):
gs.fatal(
_(
"Wrong file format downloaded. "
"Check url <{url}>. Allowed file format is "
"{response_format}.".format(
url=url,
response_format=response_format,
),
"{response_format}."
).format(
url=url,
response_format=response_format,
),
)
return response
Expand All @@ -138,8 +138,8 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
"The download of the modules.xml file "
"from the server was not successful. "
"File on the server <{url}> doesn't "
"exists.".format(url=url),
),
"exists."
).format(url=url),
)
else:
return download_modules_xml_file(
Expand All @@ -148,11 +148,8 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
)
except URLError:
gs.fatal(
_(
"Download file from <{url}>, "
"failed. Check internet connection.".format(
url=url,
),
_("Download file from <{url}> failed. Check internet connection.").format(
url=url
),
)

Expand Down Expand Up @@ -199,9 +196,8 @@ def find_addon_name(addons):
gs.warning(
_(
"The <{}> addon cannot be reinstalled. "
"Addon wasn't found among the official "
"addons.".format(addon)
),
"Addon wasn't found among the official addons."
).format(addon),
)
return set(result)

Expand Down
12 changes: 4 additions & 8 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,8 @@ def get_default_branch(full_url):
organization, repository = url_parts.path.split("/")[1:3]
except URLError:
gs.fatal(
_(
"Cannot retrieve organization and repository from URL: <{}>.".format(
full_url
)
_("Cannot retrieve organization and repository from URL: <{}>.").format(
full_url
)
)
# Construct API call and retrieve default branch
Expand Down Expand Up @@ -583,10 +581,8 @@ def etree_fromurl(url):
_(
"Download file from <{url}>,"
" failed. File is not on the server or"
" check your internet connection.".format(
url=url,
),
),
" check your internet connection."
).format(url=url),
)
return etree.fromstring(file_.read())

Expand Down
2 changes: 1 addition & 1 deletion scripts/i.oif/i.oif.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@


def oifcalc(sdev, corr, k1, k2, k3):
grass.debug(_("Calculating OIF for combination: %s, %s, %s" % (k1, k2, k3)), 1)
grass.debug(_("Calculating OIF for combination: %s, %s, %s") % (k1, k2, k3), 1)
# calculate SUM of Stddeviations:
ssdev = [sdev[k1], sdev[k2], sdev[k3]]
numer = sum(ssdev)
Expand Down
6 changes: 3 additions & 3 deletions scripts/i.pansharpen/i.pansharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def main():
gs.run_command("g.region", res=panres, align=pan)

# Select sharpening method
gs.message(_("Performing pan sharpening with hi res pan image: %f" % panres))
gs.message(_("Performing pan sharpening with hi res pan image: %f") % panres)
if sharpen == "brovey":
brovey(pan, ms1, ms2, ms3, out, pid, sproc)
elif sharpen == "ihs":
Expand Down Expand Up @@ -437,8 +437,8 @@ def main():
for ch in ["red", "green", "blue"]:
gs.verbose(_("%s_%s") % (out, ch))

gs.verbose(_("To visualize output, run: g.region -p raster=%s_red" % out))
gs.verbose(_("d.rgb r=%s_red g=%s_green b=%s_blue" % (out, out, out)))
gs.verbose(_("To visualize output, run: g.region -p raster=%s_red") % out)
gs.verbose(_("d.rgb r=%s_red g=%s_green b=%s_blue") % (out, out, out))
gs.verbose(
_("If desired, combine channels into a single RGB map with 'r.composite'.")
)
Expand Down
14 changes: 6 additions & 8 deletions scripts/i.spectral/i.spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def draw_linegraph(what):
gcore.fatal(
_(
"Supported monitor isn't running. Please launch one of the"
" monitors {}.".format(", ".join(supported_monitors))
)
" monitors {}."
).format(", ".join(supported_monitors))
)
selected_monitor = gcore.read_command("d.mon", flags="p", quiet=True).replace(
"\n", ""
Expand All @@ -207,17 +207,15 @@ def draw_linegraph(what):
gcore.fatal(
_(
"Supported monitor isn't selected. Please select one of the"
" monitors {}.".format(", ".join(supported_monitors))
)
" monitors {}."
).format(", ".join(supported_monitors))
)
with open(gcore.parse_command("d.mon", flags="g", quiet=True)["env"]) as f:
for line in f:
if "GRASS_RENDER_FILE=" in line:
gcore.info(
_(
"{} monitor is used, output file {}".format(
selected_monitor.capitalize(), line.split("=")[-1]
)
_("{} monitor is used, output file {}").format(
selected_monitor.capitalize(), line.split("=")[-1]
)
)
break
Expand Down
12 changes: 5 additions & 7 deletions scripts/r.in.wms/wms_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ def _initializeParameters(self, options, flags):
self.params["password"] == "" and self.params["username"]
):
gs.fatal(
_(
"Please insert both %s and %s parameters or none of them."
% ("password", "username")
)
_("Please insert both %s and %s parameters or none of them.")
% ("password", "username")
)

self.params["bgcolor"] = options["bgcolor"].strip()
Expand Down Expand Up @@ -202,8 +200,8 @@ def _checkIgnoeredParams(self, options, flags, driver_props):
_(
"These parameter are ignored: %s\n\
%s driver does not support the parameters."
% (",".join(not_relevant_params), options["driver"])
)
% (",".join(not_relevant_params), options["driver"])
)

not_relevant_flags = []
Expand All @@ -216,8 +214,8 @@ def _checkIgnoeredParams(self, options, flags, driver_props):
_(
"These flags are ignored: %s\n\
%s driver does not support the flags."
% (",".join(not_relevant_flags), options["driver"])
)
% (",".join(not_relevant_flags), options["driver"])
)

def GetMap(self, options, flags):
Expand Down Expand Up @@ -308,7 +306,7 @@ def GetCapabilities(self, options):
Path(capfile_output).write_text(cap)
return
except OSError as error:
gs.fatal(_("Unable to open file '%s'.\n%s\n" % (capfile_output, error)))
gs.fatal(_("Unable to open file '%s'.\n%s\n") % (capfile_output, error))

# print to output
print(cap)
Expand Down
2 changes: 1 addition & 1 deletion scripts/r.in.wms/wms_cap_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, cap_file):
raise ParseError(_("Unable to parse XML file"))
except OSError as error:
raise ParseError(
_("Unable to open XML file '%s'.\n%s\n" % (cap_file, error))
_("Unable to open XML file '%s'.\n%s\n") % (cap_file, error)
)
else:
try:
Expand Down
2 changes: 1 addition & 1 deletion scripts/r.in.wms/wms_drv.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _pct2rgb(self, src_filename, dst_filename):
# open source file
src_ds = gdal.Open(src_filename)
if src_ds is None:
gs.fatal(_("Unable to open %s " % src_filename))
gs.fatal(_("Unable to open %s ") % src_filename)

src_band = src_ds.GetRasterBand(band_number)

Expand Down
2 changes: 1 addition & 1 deletion scripts/r.in.wms/wms_gdal_drv.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _download(self):

driver = gdal.GetDriverByName(self.gdal_drv_format)
if driver is None:
gs.fatal(_("Unable to find %s driver" % format))
gs.fatal(_("Unable to find %s driver") % self.gdal_drv_format)

metadata = driver.GetMetadata()
if (
Expand Down
2 changes: 1 addition & 1 deletion scripts/r.pack/r.pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def main():

os.chdir(olddir)

grass.verbose(_("Raster map saved to '%s'" % outfile))
grass.verbose(_("Raster map saved to '%s'") % outfile)


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions scripts/r.tileset/r.tileset.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,16 @@ def main():
_(
"It is not possible to set 'maxcols=%s' and "
"'overlap=%s'. Please set maxcols>overlap"
% (options["maxcols"], options["overlap"])
)
% (options["maxcols"], options["overlap"])
)
elif max_rows == 0:
gcore.fatal(
_(
"It is not possible to set 'maxrows=%s' and "
"'overlap=%s'. Please set maxrows>overlap"
% (options["maxrows"], options["overlap"])
)
% (options["maxrows"], options["overlap"])
)
# destination projection
if not options["destproj"]:
Expand Down Expand Up @@ -400,7 +400,7 @@ def main():

if errors_dest > 0:
gcore.warning(
_("During computation %i tiles could not be created" % errors_dest)
_("During computation %i tiles could not be created") % errors_dest
)

while xi < ximax:
Expand Down
Loading

0 comments on commit f3e7a4f

Please sign in to comment.