Make default config name OS specific in Getter
This commit is contained in:
parent
e1933972d6
commit
8597b826b3
@ -144,20 +144,26 @@ class ConfigurationGetter(object):
|
|||||||
|
|
||||||
def _checkForPortableFile(self):
|
def _checkForPortableFile(self):
|
||||||
path = utils.findWorkingDir()
|
path = utils.findWorkingDir()
|
||||||
for name in constants.DEFAULT_CONFIG_NAMES:
|
for name in constants.CONFIG_NAMES:
|
||||||
if(os.path.isfile(os.path.join(path, name))):
|
if(os.path.isfile(os.path.join(path, name))):
|
||||||
return os.path.join(path, name)
|
return os.path.join(path, name)
|
||||||
|
|
||||||
def _getConfigurationFilePath(self):
|
def _getConfigurationFilePath(self):
|
||||||
configFile = self._checkForPortableFile()
|
configFile = self._checkForPortableFile()
|
||||||
if not configFile:
|
if not configFile:
|
||||||
for name in constants.DEFAULT_CONFIG_NAMES:
|
for name in constants.CONFIG_NAMES:
|
||||||
if(configFile and os.path.isfile(configFile)):
|
if(configFile and os.path.isfile(configFile)):
|
||||||
break
|
break
|
||||||
if(os.name <> 'nt'):
|
if(os.name <> 'nt'):
|
||||||
configFile = os.path.join(os.getenv('HOME', '.'), name)
|
configFile = os.path.join(os.getenv('HOME', '.'), name)
|
||||||
else:
|
else:
|
||||||
configFile = os.path.join(os.getenv('APPDATA', '.'), name)
|
configFile = os.path.join(os.getenv('APPDATA', '.'), name)
|
||||||
|
if(configFile and not os.path.isfile(configFile)):
|
||||||
|
if(os.name <> 'nt'):
|
||||||
|
configFile = os.path.join(os.getenv('HOME', '.'), constants.DEFAULT_CONFIG_NAME_LINUX)
|
||||||
|
else:
|
||||||
|
configFile = os.path.join(os.getenv('APPDATA', '.'), constants.DEFAULT_CONFIG_NAME_WINDOWS)
|
||||||
|
|
||||||
return configFile
|
return configFile
|
||||||
|
|
||||||
def _parseConfigFile(self, iniPath, createConfig = True):
|
def _parseConfigFile(self, iniPath, createConfig = True):
|
||||||
@ -246,7 +252,7 @@ class ConfigurationGetter(object):
|
|||||||
def _loadRelativeConfiguration(self):
|
def _loadRelativeConfiguration(self):
|
||||||
locations = self.__getRelativeConfigLocations()
|
locations = self.__getRelativeConfigLocations()
|
||||||
for location in locations:
|
for location in locations:
|
||||||
for name in constants.DEFAULT_CONFIG_NAMES:
|
for name in constants.CONFIG_NAMES:
|
||||||
path = location + os.path.sep + name
|
path = location + os.path.sep + name
|
||||||
self._parseConfigFile(path, createConfig = False)
|
self._parseConfigFile(path, createConfig = False)
|
||||||
self._checkConfig()
|
self._checkConfig()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user