diff options
| author | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2015-08-21 19:05:20 +0200 |
|---|---|---|
| committer | Gauvain Pocentek <gauvain.pocentek@objectif-libre.com> | 2015-08-21 19:07:21 +0200 |
| commit | fef8c7f7bc9f4a853012a5294f0731cc7f266625 (patch) | |
| tree | c83317455a0f96e597f21c77712d5966443a4607 /gitlab/__init__.py | |
| parent | 6cc8126381d0d241aeaca69d9932f0b425538f4f (diff) | |
| download | gitlab-fef8c7f7bc9f4a853012a5294f0731cc7f266625.tar.gz | |
Provide a Gitlab.from_config method
It provides the Gitlab object creation from the ~/.python-gitlab.cfg,
just like the CLI does.
Diffstat (limited to 'gitlab/__init__.py')
| -rw-r--r-- | gitlab/__init__.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index bc11071..93770f9 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -26,6 +26,9 @@ import warnings import requests import six +import gitlab.config + + __title__ = 'python-gitlab' __version__ = '0.9.1' __author__ = 'Gauvain Pocentek' @@ -155,6 +158,13 @@ class Gitlab(object): #: (Passed to requests-library) self.ssl_verify = ssl_verify + @staticmethod + def from_config(gitlab_id=None, config_files=None): + config = gitlab.config.GitlabConfigParser(gitlab_id=gitlab_id, + config_files=config_files) + return Gitlab(config.url, private_token=config.token, + ssl_verify=config.ssl_verify, timeout=config.timeout) + def auth(self): """Performs an authentication. |
