1
0
Fork 0

Merge pull request #389 from jmencak/cond-profile-loading

Add conditional profile loading
This commit is contained in:
Jaroslav Škarvada 2021-12-08 23:37:59 +01:00 committed by GitHub
commit 7d62870d7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,6 +31,10 @@ class Locator(object):
def get_config(self, profile_name, skip_files=None):
ret = None
conditional_load = profile_name[0:1] == "-"
if conditional_load:
profile_name = profile_name[1:]
for dir_name in reversed(self._load_directories):
# basename is protection not to get out of the path
config_file = self._get_config_filename(dir_name, os.path.basename(profile_name))
@ -42,6 +46,9 @@ class Locator(object):
if os.path.isfile(config_file):
return config_file
if conditional_load and ret is None:
ret = ""
return ret
def check_profile_name_format(self, profile_name):