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
…4052)

* style: Fix all flake8-gettext (INT) errors (INT001, INT002, INT003)

Ruff rules:
https://docs.astral.sh/ruff/rules/f-string-in-get-text-func-call/
https://docs.astral.sh/ruff/rules/format-in-get-text-func-call/
https://docs.astral.sh/ruff/rules/printf-in-get-text-func-call/

* Revert source string changes when unneeded.

* Update univar_statistics.py

Co-authored-by: Vaclav Petras <wenzeslaus@gmail.com>

* Update panels.py for Python script type string

* Update pyedit.py to keep path keyword in changed string

* Update univar_statistics.py to make already translated strings match again

* Update pyedit.py

* Update model.py

---------

Co-authored-by: Vaclav Petras <wenzeslaus@gmail.com>
  • Loading branch information
echoix and wenzeslaus authored Sep 14, 2024
1 parent d2f3477 commit 95da3ef
Show file tree
Hide file tree
Showing 88 changed files with 441 additions and 622 deletions.
6 changes: 3 additions & 3 deletions general/g.parser/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def main():

# test if parameter present:
if option1:
gs.message(_("Value of option1 option: '%s'" % option1))
gs.message(_("Value of option1 option: '%s'") % option1)

gs.message(_("Value of raster option: '%s'" % raster))
gs.message(_("Value of vector option: '%s'" % vector))
gs.message(_("Value of raster option: '%s'") % raster)
gs.message(_("Value of vector option: '%s'") % vector)

# End of your main code here

Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/animation/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,9 +1565,9 @@ def _export_file_validation(self, filebrowsebtn, file_path, file_postfix):
self.GetParent(),
message=_(
"Exported animation file <{file}> exists. "
"Do you want to overwrite it?".format(
file=file_path,
),
"Do you want to overwrite it?"
).format(
file=file_path,
),
caption=_("Overwrite?"),
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION,
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/animation/temporal_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def _gatherInformation(self, timeseries, etype, timeseriesList, infoDict):
maps = sp.get_registered_maps_as_objects()

if not sp.check_temporal_topology(maps):
raise GException(_("Topology of Space time dataset %s is invalid." % id))
raise GException(_("Topology of Space time dataset %s is invalid.") % id)

timeseriesList.append(id)
infoDict[id] = {}
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/core/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def SetLevel(self):
sys.stderr.write(
_(
"WARNING: Ignoring unsupported wx debug level (must be >=0 and "
"<=5). {0}\n".format(e)
)
"<=5). {0}\n"
).format(e)
)

def msg(self, level, message, *args):
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 @@ -706,7 +706,7 @@ def OnRenderDone(self, env):
self._rendering = False
if wx.IsBusy():
wx.EndBusyCursor()
raise GException(_("Rendering failed: %s" % msg))
raise GException(_("Rendering failed: %s") % msg)

stop = time.time()
Debug.msg(
Expand Down
9 changes: 4 additions & 5 deletions gui/wxpython/gcp/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,11 +1785,10 @@ def _getOverWriteDialog(self, maptype, overwrite):
return wx.MessageDialog(
self.GetParent(),
message=_(
"The {map_type} map {map_name} exists. "
"Do you want to overwrite?".format(
map_type=maptype,
map_name=map_name,
),
"The {map_type} map {map_name} exists. Do you want to overwrite?"
).format(
map_type=maptype,
map_name=map_name,
),
caption=_("Overwrite?"),
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION,
Expand Down
11 changes: 5 additions & 6 deletions gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2819,12 +2819,11 @@ def _getPythonActionCmd(self, item, task, cmdIndent, variables={}):
dlg = wx.MessageDialog(
self.model.canvas,
message=_(
f"Module {task.get_name()} in your model contains "
f"parameterized flags. actinia does not support "
f"parameterized flags. The following flags are therefore "
f"not being written in the generated json: "
f"{itemParameterizedFlags}"
),
"Module {task_name} in your model contains "
"parameterized flags. Actinia does not support "
"parameterized flags. The following flags are therefore "
"not being written in the generated JSON: {flags}"
).format(task_name=task.get_name(), flags=itemParameterizedFlags),
caption=_("Warning"),
style=wx.OK_DEFAULT | wx.ICON_WARNING,
)
Expand Down
28 changes: 11 additions & 17 deletions gui/wxpython/gmodeler/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,15 @@ def OnPageChanged(self, event):

if self.pythonPanel.IsModified():
self.SetStatusText(
_(
"{} script contains local modifications".format(
self.pythonPanel.body.script_type
)
_("{} script contains local modifications").format(
self.pythonPanel.body.script_type
),
0,
)
else:
self.SetStatusText(
_(
"{} script is up-to-date".format(
self.pythonPanel.body.script_type
)
_("{} script is up-to-date").format(
self.pythonPanel.body.script_type
),
0,
)
Expand Down Expand Up @@ -1261,7 +1257,7 @@ def OnDeleteData(self, event):

dlg = wx.MessageDialog(
parent=self,
message=_("Do you want to permanently delete data?%s" % msg),
message=_("Do you want to permanently delete data?%s") % msg,
caption=_("Delete intermediate data?"),
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION,
)
Expand Down Expand Up @@ -1645,9 +1641,7 @@ def _layout(self):
bodySizer.Add(self.body, proportion=1, flag=wx.EXPAND | wx.ALL, border=3)

btnSizer.Add(
StaticText(
parent=self, id=wx.ID_ANY, label="%s:" % _("Python script type")
),
StaticText(parent=self, id=wx.ID_ANY, label=_("Python script type:")),
flag=wx.ALIGN_CENTER_VERTICAL,
)
btnSizer.Add(self.script_type_box, proportion=0, flag=wx.RIGHT, border=5)
Expand Down Expand Up @@ -1676,7 +1670,7 @@ def GetScriptExt(self):
return ext

def SetWriteObject(self, script_type):
"""Set correct self.write_object dependng on the script type.
"""Set correct self.write_object depending on the script type.
:param script_type: script type name as a string
"""
if script_type == "PyWPS":
Expand Down Expand Up @@ -1704,8 +1698,8 @@ def RefreshScript(self):
message=_(
"{} script is locally modified. "
"Refresh will discard all changes. "
"Do you really want to continue?".format(self.body.script_type)
),
"Do you really want to continue?"
).format(self.body.script_type),
caption=_("Update"),
style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION | wx.CENTRE,
)
Expand Down Expand Up @@ -1835,7 +1829,7 @@ def OnChangeScriptType(self, event):
if self.RefreshScript():
self.body.script_type = new_script_type
self.parent.SetStatusText(
_("{} script is up-to-date".format(self.body.script_type)),
_("{} script is up-to-date").format(self.body.script_type),
0,
)

Expand All @@ -1854,7 +1848,7 @@ def OnRefresh(self, event):
"""Refresh the script."""
if self.RefreshScript():
self.parent.SetStatusText(
_("{} script is up-to-date".format(self.body.script_type)),
_("{} script is up-to-date").format(self.body.script_type),
0,
)
event.Skip()
Expand Down
12 changes: 6 additions & 6 deletions gui/wxpython/gui_core/ghelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,15 @@ def _langString(self, k, v):
"""Return string for the status of translation"""
allStr = "%s :" % k.upper()
try:
allStr += _(" %d translated" % v["good"])
allStr += _(" %d translated") % v["good"]
except:
pass
try:
allStr += _(" %d fuzzy" % v["fuzzy"])
allStr += _(" %d fuzzy") % v["fuzzy"]
except:
pass
try:
allStr += _(" %d untranslated" % v["bad"])
allStr += _(" %d untranslated") % v["bad"]
except:
pass
return allStr
Expand All @@ -584,7 +584,7 @@ def _langBox(self, par, k, v):
langBox.Add(tkey)
try:
tgood = StaticText(
parent=par, id=wx.ID_ANY, label=_("%d translated" % v["good"])
parent=par, id=wx.ID_ANY, label=_("%d translated") % v["good"]
)
tgood.SetForegroundColour(wx.Colour(35, 142, 35))
langBox.Add(tgood)
Expand All @@ -593,7 +593,7 @@ def _langBox(self, par, k, v):
langBox.Add(tgood)
try:
tfuzzy = StaticText(
parent=par, id=wx.ID_ANY, label=_(" %d fuzzy" % v["fuzzy"])
parent=par, id=wx.ID_ANY, label=_(" %d fuzzy") % v["fuzzy"]
)
tfuzzy.SetForegroundColour(wx.Colour(255, 142, 0))
langBox.Add(tfuzzy)
Expand All @@ -602,7 +602,7 @@ def _langBox(self, par, k, v):
langBox.Add(tfuzzy)
try:
tbad = StaticText(
parent=par, id=wx.ID_ANY, label=_(" %d untranslated" % v["bad"])
parent=par, id=wx.ID_ANY, label=_(" %d untranslated") % v["bad"]
)
tbad.SetForegroundColour(wx.Colour(255, 0, 0))
langBox.Add(tbad)
Expand Down
68 changes: 34 additions & 34 deletions gui/wxpython/gui_core/gselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def GetTable(self, layer):
:param layer: vector layer number
"""
if layer not in self.layers:
raise GException(_("No table linked to layer <{}>.".format(layer)))
raise GException(_("No table linked to layer <{}>.").format(layer))
return self.layers[layer]["table"]

def GetDbSettings(self, layer):
Expand Down Expand Up @@ -2259,18 +2259,18 @@ def hasRastSameProjAsLocation(dsn, table=None):
message=_(
"Getting raster <{table}> SRID from PostgreSQL"
" DB <{db}>, host <{host}> failed."
" {error}.".format(
table=table,
db=self._getPDDBConnectionParam(
dsn,
conn_param="dbname",
),
host=self._getPDDBConnectionParam(
dsn,
conn_param="host",
),
error=gs.utils.decode(error),
" {error}."
).format(
table=table,
db=self._getPDDBConnectionParam(
dsn,
conn_param="dbname",
),
host=self._getPDDBConnectionParam(
dsn,
conn_param="host",
),
error=gs.utils.decode(error),
),
)
if ret:
Expand Down Expand Up @@ -2522,17 +2522,17 @@ def _getPGDBtables(self, dsn):
parent=self,
message=_(
"Getting list of tables from PostgreSQL DB <{db}>,"
" host <{host}> failed. {error}.".format(
db=self._getPGDBConnectionParam(
dsn,
conn_param="dbname",
),
host=self._getPGDBConnectionParam(
dsn,
conn_param="host",
),
error=gs.utils.decode(error),
" host <{host}> failed. {error}."
).format(
db=self._getPGDBConnectionParam(
dsn,
conn_param="dbname",
),
host=self._getPGDBConnectionParam(
dsn,
conn_param="host",
),
error=gs.utils.decode(error),
),
)
if ret:
Expand Down Expand Up @@ -2614,17 +2614,17 @@ def _getPGDBRasters(self, dsn):
message=_(
"Getting list of tables columns data types"
" from PostGIS DB <{db}>, host <{host}> failed."
" {error}.".format(
db=self._getPGDBConnectionParam(
dsn,
conn_param="dbname",
),
host=self._getPGDBConnectionParam(
dsn,
conn_param="host",
),
error=gs.utils.decode(error),
" {error}."
).format(
db=self._getPGDBConnectionParam(
dsn,
conn_param="dbname",
),
host=self._getPGDBConnectionParam(
dsn,
conn_param="host",
),
error=gs.utils.decode(error),
),
)
if ret:
Expand All @@ -2644,8 +2644,8 @@ def _getPGDBRasters(self, dsn):
parent=self,
message=_(
"PostgreSQL DB <{psql}> program was not found."
" Please, install it.".format(psql=self._psql)
),
" Please, install it."
).format(psql=self._psql),
)
Debug.msg(3, f"GdalSelect._getPGDBRasters(): return {rasters}")
return rasters
Expand Down
29 changes: 13 additions & 16 deletions gui/wxpython/gui_core/pyedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,14 @@ def _openFile(self, file_path):
GError(
message=_(
"Permission denied <{}>. Please change file "
"permission for reading.".format(file_path)
),
"permission for reading."
).format(file_path),
parent=self.guiparent,
showTraceback=False,
)
except OSError:
GError(
message=_("Couldn't read file <{}>.".format(file_path)),
message=_("Couldn't read file <{}>.").format(file_path),
parent=self.guiparent,
)

Expand All @@ -333,20 +333,18 @@ def _writeFile(self, file_path, content, additional_err_message=""):
GError(
message=_(
"Permission denied <{}>. Please change file "
"permission for writing.{}".format(
file_path,
additional_err_message,
),
"permission for writing.{}"
).format(
file_path,
additional_err_message,
),
parent=self.guiparent,
showTraceback=False,
)
except OSError:
GError(
message=_(
"Couldn't write file <{}>.{}".format(
file_path, additional_err_message
),
message=_("Couldn't write file <{}>.{}").format(
file_path, additional_err_message
),
parent=self.guiparent,
)
Expand All @@ -359,7 +357,7 @@ def OnRun(self, event):
file_is_written = self._writeFile(
file_path=self.filename,
content=self.body.GetText(),
additional_err_message=" Unable to launch Python script.",
additional_err_message=_(" Unable to launch Python script."),
)
if file_is_written:
mode = stat.S_IMODE(os.lstat(self.filename)[stat.ST_MODE])
Expand All @@ -369,7 +367,7 @@ def OnRun(self, event):
file_is_written = self._writeFile(
file_path=self.filename,
content=self.body.GetText(),
additional_err_message=" Unable to launch Python script.",
additional_err_message=_(" Unable to launch Python script."),
)
if file_is_written:
# set executable file
Expand Down Expand Up @@ -509,9 +507,8 @@ def OpenRecentFile(self, path, file_exists, file_history):
if not file_exists:
GError(
_(
"File <{}> doesn't exist."
"It was probably moved or deleted.".format(path)
),
"File <{path}> doesn't exist. It was probably moved or deleted."
).format(path=path),
parent=self.guiparent,
)
return
Expand Down
Loading

0 comments on commit 95da3ef

Please sign in to comment.