--- a/src/eric7/EricUtilities/__init__.py Wed Sep 25 14:07:40 2024 +0200 +++ b/src/eric7/EricUtilities/__init__.py Wed Sep 25 14:48:57 2024 +0200 @@ -7,11 +7,48 @@ Package containing utility modules and functions. """ +import os + import semver from PyQt6.QtCore import QByteArray, QCoreApplication ############################################################################### +## Functions dealing with the configuration directory. +############################################################################### + +_configDir = None + + +def getConfigDir(): + """ + Module function to get the name of the directory storing the config data. + + @return directory name of the config dir + @rtype str + """ + if _configDir is not None and os.path.exists(_configDir): + return _configDir + else: + confDir = os.path.join(os.path.expanduser("~"), ".eric7") + if not os.path.exists(confDir): + os.mkdir(confDir) + return confDir + + +def setConfigDir(d): + """ + Module function to set the name of the directory storing the config data. + + @param d name of an existing directory + @type str + """ + global _configDir + + _configDir = os.path.expanduser(d) + + +############################################################################### ## Functions for converting QSetting return types to valid types. ###############################################################################