Commit 18abccfc authored by Adrian DC's avatar Adrian DC
Browse files

feat(gitlab): isolate 'ProtectionLevels' enumeration

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 2288ccb8
Loading
Loading
Loading
Loading
+5 −5
Changes for src/features/gitlab.py: 5 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ from gitlab.exceptions import GitlabDeleteError, GitlabGetError, GitlabListError
from gitlab.v4.objects import Group, Namespace, Project, User

# Components
from ..types.gitlab import AccessLevels, ProjectFeatures
from ..types.gitlab import AccessLevels, ProjectFeatures, ProtectionLevels

# GitLabFeature class, pylint: disable=too-many-public-methods
class GitLabFeature:
@@ -349,13 +349,13 @@ class GitLabFeature:

        # Prepare access level
        access_level: int
        if protect_level == 'no-one':
        if protect_level == ProtectionLevels.NO_ONE:
            access_level = 0
        elif protect_level == 'admins':
        elif protect_level == ProtectionLevels.ADMINS:
            access_level = 60
        elif protect_level == 'maintainers':
        elif protect_level == ProtectionLevels.MAINTAINERS:
            access_level = 40
        elif protect_level == 'developers':
        elif protect_level == ProtectionLevels.DEVELOPERS:
            access_level = 30
        else:
            raise SyntaxError(f'Unknown protection level: {access_level}')
+7
Changes for src/types/gitlab.py: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,13 @@ class AccessLevels:
    PRIVATE: str = 'private'
    ENABLED: str = 'enabled'

# ProtectionLevels class, pylint: disable=too-few-public-methods
class ProtectionLevels:
    NO_ONE: str = 'no-one'
    ADMINS: str = 'admins'
    MAINTAINERS: str = 'maintainers'
    DEVELOPERS: str = 'developers'

# Visibility class, pylint: disable=too-few-public-methods
class Visibility:
    PRIVATE: str = 'private'