diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-10-16 18:01:37 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-10-16 18:02:18 +0300 |
commit | 9acf33ecb4efcfa8f537e76552ec290e1b76a51c (patch) | |
tree | 0b977f3b00dbdec025d17e0f9c022573c2adee20 /cgit | |
parent | examples/cgitize.toml: add comment-headers (diff) | |
download | cgitize-9acf33ecb4efcfa8f537e76552ec290e1b76a51c.tar.gz cgitize-9acf33ecb4efcfa8f537e76552ec290e1b76a51c.zip |
Gitlab -> GitLab
Diffstat (limited to '')
-rw-r--r-- | cgitize/config.py | 8 | ||||
-rw-r--r-- | cgitize/gitlab.py | 15 |
2 files changed, 12 insertions, 11 deletions
diff --git a/cgitize/config.py b/cgitize/config.py index 0e42357..821dd6d 100644 --- a/cgitize/config.py +++ b/cgitize/config.py @@ -9,7 +9,7 @@ import tomli from cgitize.bitbucket import Bitbucket from cgitize.github import GitHub -from cgitize.gitlab import Gitlab +from cgitize.gitlab import GitLab from cgitize.repo import Repo @@ -96,7 +96,7 @@ class BitbucketSection(Section): return map(HostedRepo, self.repositories.enum_repositories()) -class GitlabSection(Section): +class GitLabSection(Section): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.users = UsersSection(self.impl.get('users', {})) @@ -170,7 +170,7 @@ class Config: self.repositories = RepositoriesSection(self.impl.get('repositories', {})) self.github = GitHubSection(self.impl.get('github', {})) self.bitbucket = BitbucketSection(self.impl.get('bitbucket', {})) - self.gitlab = GitlabSection(self.impl.get('gitlab', {})) + self.gitlab = GitLabSection(self.impl.get('gitlab', {})) def _parse_explicit_repositories(self): for r in self.repositories.enum_repositories(): @@ -197,7 +197,7 @@ class Config: return self._parse_hosted_repositories(self.bitbucket, bitbucket) def _parse_gitlab_repositories(self): - gitlab = Gitlab(self.gitlab.access_token) + gitlab = GitLab(self.gitlab.access_token) return self._parse_hosted_repositories(self.gitlab, gitlab) def parse_repositories(self): diff --git a/cgitize/gitlab.py b/cgitize/gitlab.py index 77612cb..3589472 100644 --- a/cgitize/gitlab.py +++ b/cgitize/gitlab.py @@ -5,34 +5,35 @@ import logging -import gitlab +from gitlab import Gitlab +from gitlab.exceptions import GitlabGetError from cgitize.repo import Repo -class Gitlab: +class GitLab: def __init__(self, access_token): - self._impl = gitlab.Gitlab('https://gitlab.com', private_token=access_token) + self._impl = Gitlab('https://gitlab.com', private_token=access_token) def get_repo(self, repo): try: return self._impl.projects.get(repo.id) - except gitlab.exceptions.GitlabGetError: + except GitlabGetError: logging.error("Couldn't fetch repository: %s", repo.id) raise def get_user_repos(self, user): try: - # Strictly speaking, Gitlab supports the /users/:username/projects + # Strictly speaking, GitLab supports the /users/:username/projects # endpoint, which means you shouldn't need to fetch the user first, # but I don't think python-gitlab 2.10.0 supports that? users = self._impl.users.list(username=user.name) if not users: - raise RuntimeError(f"Couldn't find Gitlab user: {user.name}") + raise RuntimeError(f"Couldn't find GitLab user: {user.name}") assert len(users) == 1 user = users[0] return user.projects.list() - except gitlab.exceptions.GitlabGetError: + except GitlabGetError: logging.error("Couldn't fetch user repositories: %s", user.name) raise |