diff options
author | Joost Evertse <joustie@gmail.com> | 2019-01-21 13:36:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-21 13:36:56 +0100 |
commit | b51d2969ad34a9aad79e42a69f275caf2a4059cb (patch) | |
tree | a4519d935a0b5ae5361cb178318402e09da17d75 /gitlab/config.py | |
parent | 53f7de7bfe0056950a8e7271632da3f89e3ba3b3 (diff) | |
parent | 52d76312660109d3669d459b11b448a3a60b9603 (diff) | |
download | gitlab-b51d2969ad34a9aad79e42a69f275caf2a4059cb.tar.gz |
Merge branch 'master' into master
Diffstat (limited to 'gitlab/config.py')
-rw-r--r-- | gitlab/config.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gitlab/config.py b/gitlab/config.py index 9f4c11d..1c76594 100644 --- a/gitlab/config.py +++ b/gitlab/config.py @@ -37,10 +37,27 @@ class GitlabDataError(ConfigError): pass +class GitlabConfigMissingError(ConfigError): + pass + + class GitlabConfigParser(object): def __init__(self, gitlab_id=None, config_files=None): self.gitlab_id = gitlab_id _files = config_files or _DEFAULT_FILES + file_exist = False + for file in _files: + if os.path.exists(file): + file_exist = True + if not file_exist: + raise GitlabConfigMissingError( + "Config file not found. \nPlease create one in " + "one of the following locations: {} \nor " + "specify a config file using the '-c' parameter.".format( + ", ".join(_DEFAULT_FILES) + ) + ) + self._config = configparser.ConfigParser() self._config.read(_files) |