Rename lastPath in build settings

This commit is contained in:
Veronica Berglyd Olsen
2024-06-16 11:23:59 +02:00
parent a3381f1f79
commit 14f1697428
4 changed files with 22 additions and 22 deletions
+3 -3
View File
@@ -219,7 +219,7 @@ class BuildSettings:
return self._order
@property
def lastPath(self) -> Path:
def lastBuildPath(self) -> Path:
"""The last used build path."""
if self._path.is_dir():
return self._path
@@ -293,7 +293,7 @@ class BuildSettings:
self._order = value
return
def setLastPath(self, path: Path | str | None) -> None:
def setLastBuildPath(self, path: Path | str | None) -> None:
"""Set the last used build path."""
if isinstance(path, str):
path = Path(path)
@@ -461,7 +461,7 @@ class BuildSettings:
self.setName(data.get("name", ""))
self.setBuildID(data.get("uuid", ""))
self.setOrder(data.get("order", 0))
self.setLastPath(data.get("path", None))
self.setLastBuildPath(data.get("path", None))
self.setLastBuildName(data.get("build", ""))
buildFmt = str(data.get("format", ""))
+3 -3
View File
@@ -220,7 +220,7 @@ class GuiManuscriptBuild(NDialog):
self.btnBuild.setFocus()
self._populateContentList()
self.buildPath.setText(str(self._build.lastPath))
self.buildPath.setText(str(self._build.lastBuildPath))
if self._build.lastBuildName:
self.buildName.setText(self._build.lastBuildName)
else:
@@ -274,7 +274,7 @@ class GuiManuscriptBuild(NDialog):
def _doSelectPath(self) -> None:
"""Select a folder for output."""
bPath = Path(self.buildPath.text())
bPath = bPath if bPath.is_dir() else self._build.lastPath
bPath = bPath if bPath.is_dir() else self._build.lastBuildPath
savePath = QFileDialog.getExistingDirectory(
self, self.tr("Select Folder"), str(bPath)
)
@@ -336,7 +336,7 @@ class GuiManuscriptBuild(NDialog):
for i, _ in docBuild.iterBuild(buildPath, bFormat):
self.buildProgress.setValue(i+1)
self._build.setLastPath(bPath)
self._build.setLastBuildPath(bPath)
self._build.setLastBuildName(bName)
self._build.setLastFormat(bFormat)
+14 -14
View File
@@ -73,29 +73,29 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
assert isUUID(build.buildID)
# Last path must be valid, if not it defaults to $HOME
build.setLastPath("/path/to/nowhere")
assert build.lastPath == CONFIG.homePath()
build.setLastBuildPath("/path/to/nowhere")
assert build.lastBuildPath == CONFIG.homePath()
build.setLastPath(None)
assert build.lastPath == CONFIG.homePath()
build.setLastBuildPath(None)
assert build.lastBuildPath == CONFIG.homePath()
(fncPath / "test.txt").write_text("foobar")
build.setLastPath(fncPath / "test.txt") # Can't be a file
assert build.lastPath == CONFIG.homePath()
build.setLastBuildPath(fncPath / "test.txt") # Can't be a file
assert build.lastBuildPath == CONFIG.homePath()
build.setLastPath(fncPath)
assert build.lastPath == fncPath
build.setLastBuildPath(fncPath)
assert build.lastBuildPath == fncPath
build.setLastPath(str(fncPath)) # String paths are also ok
assert build.lastPath == fncPath
build.setLastBuildPath(str(fncPath)) # String paths are also ok
assert build.lastBuildPath == fncPath
# Last path no longer exists -> fallback to $HOME
testDir = fncPath / "test_dir"
testDir.mkdir()
build.setLastPath(testDir)
assert build.lastPath == testDir
build.setLastBuildPath(testDir)
assert build.lastBuildPath == testDir
testDir.rmdir()
assert build.lastPath == CONFIG.homePath()
assert build.lastBuildPath == CONFIG.homePath()
# Last build name
build.setLastBuildName(None) # type: ignore
@@ -119,7 +119,7 @@ def testCoreBuildSettings_ClassAttributes(fncPath: Path):
# Set some sensible values
build.setName("Test Build")
build.setBuildID("5cf45d24-f496-42c9-8733-529a9e52a62b")
build.setLastPath(fncPath)
build.setLastBuildPath(fncPath)
build.setLastBuildName("Build Name")
build.setLastFormat(nwBuildFmt.HTML)
+2 -2
View File
@@ -47,7 +47,7 @@ def testToolManuscriptBuild_Main(
buildTestProject(nwGUI, projPath)
nwGUI.openProject(projPath)
build = BuildSettings()
build.setLastPath(fncPath)
build.setLastBuildPath(fncPath)
manus = GuiManuscriptBuild(nwGUI, build)
manus.show()
@@ -100,7 +100,7 @@ def testToolManuscriptBuild_Main(
assert build.lastBuildName == "TestBuild"
assert build.lastFormat == lastFmt
assert build.lastPath == fncPath
assert build.lastBuildPath == fncPath
# Error Handling
# ==============