diff --git a/gui/wxpython/history/tree.py b/gui/wxpython/history/tree.py index ed776864ef9..2ecfff9c7b9 100644 --- a/gui/wxpython/history/tree.py +++ b/gui/wxpython/history/tree.py @@ -117,9 +117,9 @@ def _popupMenuLayer(self): """Create popup menu for commands""" menu = Menu() - item = wx.MenuItem(menu, wx.ID_ANY, _("&Delete")) + item = wx.MenuItem(menu, wx.ID_ANY, _("&Remove")) menu.AppendItem(item) - self.Bind(wx.EVT_MENU, self.OnDeleteCmd, item) + self.Bind(wx.EVT_MENU, self.OnRemoveCmd, item) self.PopupMenu(menu) menu.Destroy() @@ -188,19 +188,19 @@ def RemoveEntryFromHistory(self, del_line_number): except OSError as e: GError(str(e)) - def OnDeleteCmd(self, event): - """Delete cmd from the history file""" + def OnRemoveCmd(self, event): + """Remove cmd from the history file""" tree_node = self._getSelectedNode() cmd = tree_node.data["command"] - question = _("Do you really want to delete <{}> command?").format(cmd) - if self._confirmDialog(question, title=_("Delete command")) == wx.ID_YES: - self.showNotification.emit(message=_("Deleting <{}>").format(cmd)) + question = _("Do you really want to remove <{}> command?").format(cmd) + if self._confirmDialog(question, title=_("Remove command")) == wx.ID_YES: + self.showNotification.emit(message=_("Removing <{}>").format(cmd)) tree_index = self._model.GetIndexOfNode(tree_node)[0] self.RemoveEntryFromHistory(tree_index) self._giface.entryFromHistoryRemoved.emit(index=tree_index) self._model.RemoveNode(tree_node) self._refreshTree() - self.showNotification.emit(message=_("<{}> deleted").format(cmd)) + self.showNotification.emit(message=_("<{}> removed").format(cmd)) def OnItemSelected(self, node): """Item selected""" diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index 7df727e73e7..a85f4fd6c7e 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -26,7 +26,7 @@ def get_current_mapset_gui_history_path(): def create_history_file(history_path): """Set up a new GUI history file.""" try: - fileHistory = open( + file_history = open( history_path, encoding="utf-8", mode="w", @@ -34,14 +34,14 @@ def create_history_file(history_path): except OSError as e: raise OSError(_("Unable to create history file {}").format(history_path)) from e finally: - fileHistory.close() + file_history.close() def read_history(history_path): """Get list of commands from history file.""" hist = list() try: - fileHistory = open( + file_history = open( history_path, encoding="utf-8", mode="r", @@ -52,10 +52,10 @@ def read_history(history_path): _("Unable to read commands from history file {}").format(history_path) ) from e try: - for line in fileHistory.readlines(): + for line in file_history.readlines(): hist.append(line.replace("\n", "")) finally: - fileHistory.close() + file_history.close() return hist @@ -65,48 +65,48 @@ def add_entry_to_history(command, history_path=None): :param str command: the command given as a string :param str|None history_path: history file path string """ - fileHistory = None + file_history = None if not history_path: history_path = get_current_mapset_gui_history_path() try: if os.path.exists(history_path): - fileHistory = open(history_path, encoding="utf-8", mode="a") + file_history = open(history_path, encoding="utf-8", mode="a") else: - fileHistory = open(history_path, encoding="utf-8", mode="w") - fileHistory.write(command + "\n") + file_history = open(history_path, encoding="utf-8", mode="w") + file_history.write(command + "\n") except OSError as e: raise OSError( _("Unable to add entry to history file {}").format(history_path) ) from e finally: - if fileHistory: - fileHistory.close() + if file_history: + file_history.close() def remove_entry_from_history(del_line_number, history_path=None): """Remove entry from history file. - :param int del_line_number: line number of deleted command + :param int del_line_number: line number of the command to be removed :param str|None history_path: history file path string """ - fileHistory = None + file_history = None if not history_path: history_path = get_current_mapset_gui_history_path() try: - fileHistory = open(history_path, encoding="utf-8", mode="r+") - lines = fileHistory.readlines() - fileHistory.seek(0) - fileHistory.truncate() + file_history = open(history_path, encoding="utf-8", mode="r+") + lines = file_history.readlines() + file_history.seek(0) + file_history.truncate() for number, line in enumerate(lines): if number not in [del_line_number]: - fileHistory.write(line) + file_history.write(line) except OSError as e: raise OSError( - _("Unable to delete entry from history file {}").format(history_path) + _("Unable to remove entry from history file {}").format(history_path) ) from e finally: - if fileHistory: - fileHistory.close() + if file_history: + file_history.close() def copy_history(target_path, history_path):