Skip to content

Commit

Permalink
Fix console script editor tries to save as ".py.py"
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 17, 2024
1 parent 9946a1d commit b1947bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion python/console/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,9 @@ def saveAsScriptFile(self, index=None):
if not index:
index = self.tabEditorWidget.currentIndex()
if not tabWidget.file_path():
fileName = self.tabEditorWidget.tabText(index).replace('*', '') + '.py'
fileName = self.tabEditorWidget.tabText(index).replace('*', '')
fileName = QgsFileUtils.ensureFileNameHasExtension(fileName,
['py'])
folder = QgsSettings().value("pythonConsole/lastDirPath", QDir.homePath())
pathFileName = os.path.join(folder, fileName)
fileNone = True
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/processing/script/ScriptEditorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
)
from qgis.core import (
QgsApplication,
QgsFileUtils,
QgsSettings,
QgsError,
QgsProcessingAlgorithm,
Expand Down Expand Up @@ -228,9 +229,7 @@ def saveScript(self, saveAs):
self.tr("Processing scripts (*.py *.PY)"))

if newPath:
if not newPath.lower().endswith(".py"):
newPath += ".py"

newPath = QgsFileUtils.ensureFileNameHasExtension(newPath, ['py'])
self.code_editor_widget.setFilePath(newPath)

if self.code_editor_widget.filePath():
Expand Down

0 comments on commit b1947bf

Please sign in to comment.