Rename lastPath in build settings
This commit is contained in:
@@ -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", ""))
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
# ==============
|
||||
|
||||
Reference in New Issue
Block a user