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