Change dataPath to a Path object

This commit is contained in:
Veronica Berglyd Olsen
2022-11-09 00:25:50 +01:00
parent 6f5539de90
commit 6792c11a71
5 changed files with 44 additions and 59 deletions
+8 -8
View File
@@ -29,6 +29,7 @@ import logging
import novelwriter
from math import ceil
from pathlib import Path
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import qApp
@@ -122,9 +123,8 @@ class GuiTheme:
self._listConf(self._availSyntax, os.path.join(self.mainConf.assetPath, "syntax"))
self._listConf(self._availThemes, os.path.join(self.mainConf.assetPath, "themes"))
if self.mainConf.dataPath: # Not guaranteed to be set
self._listConf(self._availSyntax, os.path.join(self.mainConf.dataPath, "syntax"))
self._listConf(self._availThemes, os.path.join(self.mainConf.dataPath, "themes"))
self._listConf(self._availSyntax, self.mainConf.getDataPath("syntax"))
self._listConf(self._availThemes, self.mainConf.getDataPath("themes"))
self.loadTheme()
self.loadSyntax()
@@ -380,13 +380,13 @@ class GuiTheme:
def _listConf(self, targetDict, checkDir):
"""Scan for theme config files and populate the dictionary.
"""
if not os.path.isdir(checkDir):
checkDir = Path(checkDir)
if not checkDir.is_dir():
return False
for checkFile in os.listdir(checkDir):
confPath = os.path.join(checkDir, checkFile)
if os.path.isfile(confPath) and confPath.endswith(".conf"):
targetDict[checkFile[:-5]] = confPath
for checkFile in checkDir.iterdir():
if checkFile.is_file() and checkFile.name.endswith(".conf"):
targetDict[checkFile.name[:-5]] = checkFile
return True