diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-08 09:39:40 +0500 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-03-08 09:39:40 +0500 |
commit | 44c603004ac302cf3f93f3fbf6bd2d22e7fe763c (patch) | |
tree | 352c5d17a2b3820a4a347a79784cbf846b11cf28 | |
parent | Makefile: preserve the header (diff) | |
download | cgitize-44c603004ac302cf3f93f3fbf6bd2d22e7fe763c.tar.gz cgitize-44c603004ac302cf3f93f3fbf6bd2d22e7fe763c.zip |
minor refactoring
-rw-r--r-- | cgitize/config.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/cgitize/config.py b/cgitize/config.py index 8922d17..a6862b2 100644 --- a/cgitize/config.py +++ b/cgitize/config.py @@ -55,12 +55,14 @@ class MainSection(Section): return self._get_config_value('owner', required=False) -class GitHubSection(Section): +class ServiceSection(Section): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.users = UsersSection(self.impl.get('users', {})) self.repositories = RepositoriesSection(self.impl.get('repositories', {})) + self.users = UsersSection(self.impl.get('users', {})) + +class GitHubSection(ServiceSection): @property def access_token(self): return self._get_config_or_env('access_token', 'CGITIZE_GITHUB_ACCESS_TOKEN') @@ -76,12 +78,7 @@ def two_part_url_auth(username, password): return f'{username}:{password}' -class BitbucketSection(Section): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.users = UsersSection(self.impl.get('users', {})) - self.repositories = RepositoriesSection(self.impl.get('repositories', {})) - +class BitbucketSection(ServiceSection): @property def app_password(self): return self._get_config_or_env('app_password', 'CGITIZE_BITBUCKET_APP_PASSWORD') @@ -98,12 +95,7 @@ class BitbucketSection(Section): return map(HostedRepo, self.repositories.enum_repositories()) -class GitLabSection(Section): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.users = UsersSection(self.impl.get('users', {})) - self.repositories = RepositoriesSection(self.impl.get('repositories', {})) - +class GitLabSection(ServiceSection): @property def access_token(self): return self._get_config_or_env('access_token', 'CGITIZE_GITLAB_ACCESS_TOKEN') |