Loading src/cli/entrypoint.py +29 −20 Changes for src/cli/entrypoint.py: 29 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ # Standard libraries from argparse import Namespace from enum import Enum # Modules libraries from gitlab.exceptions import GitlabGetError Loading @@ -20,13 +21,17 @@ from ..types.namespaces import Namespaces # Entrypoint class, pylint: disable=too-few-public-methods class Entrypoint: # Enumerations Result = Enum('Result', ['SUCCESS', 'FINALIZE', 'ERROR']) # CLI, pylint: disable=too-many-branches @staticmethod def cli(options: Namespace) -> bool: def cli(options: Namespace) -> Result: # Variables group: GitLabGroup = None project: GitLabProject = None result: Entrypoint.Result = Entrypoint.Result.ERROR user: GitLabUser = None # Header Loading Loading @@ -86,12 +91,13 @@ class Entrypoint: # Handle group if not options.exclude_group: if not Entrypoint.group( result = Entrypoint.group( options, gitlab, group.full_path, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Iterate through subgroups if not options.exclude_subgroups: Loading @@ -104,13 +110,14 @@ class Entrypoint: ), key=lambda item: item.full_path, ): if not Entrypoint.group( result = Entrypoint.group( options, gitlab, group_subgroup.full_path, True, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Iterate through projects if not options.exclude_projects: Loading @@ -123,12 +130,13 @@ class Entrypoint: ), key=lambda item: item.path_with_namespace, ): if not Entrypoint.project( result = Entrypoint.project( options, gitlab, group_project.path_with_namespace, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Handle user recursively elif user: Loading @@ -143,15 +151,16 @@ class Entrypoint: ), key=lambda item: item.path_with_namespace, ): if not Entrypoint.project( result = Entrypoint.project( options, gitlab, user_project.path_with_namespace, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Result return True return Entrypoint.Result.SUCCESS # Group @staticmethod Loading @@ -160,7 +169,7 @@ class Entrypoint: gitlab: GitLabFeature, criteria: str, subgroup: bool = False, ) -> bool: ) -> Result: # Acquire group group = gitlab.group(criteria) Loading Loading @@ -193,7 +202,7 @@ class Entrypoint: f'{Colors.RESET}') print(' ') Platform.flush() return subgroup return Entrypoint.Result.SUCCESS if subgroup else Entrypoint.Result.FINALIZE # Set group description if options.set_description: Loading Loading @@ -249,7 +258,7 @@ class Entrypoint: Platform.flush() # Result return True return Entrypoint.Result.SUCCESS # Project, pylint: disable=too-many-branches,too-many-statements @staticmethod Loading @@ -257,7 +266,7 @@ class Entrypoint: options: Namespace, gitlab: GitLabFeature, criteria: str, ) -> bool: ) -> Result: # Acquire project project = gitlab.project(criteria) Loading @@ -277,7 +286,7 @@ class Entrypoint: f'{Colors.RESET}') print(' ') Platform.flush() return True return Entrypoint.Result.SUCCESS # Set project description if options.set_description: Loading Loading @@ -402,4 +411,4 @@ class Entrypoint: Platform.flush() # Result return True return Entrypoint.Result.SUCCESS src/cli/main.py +2 −2 Changes for src/cli/main.py: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ def main() -> None: # Variables group: _ArgumentGroup result: bool = False result: Entrypoint.Result = Entrypoint.Result.ERROR subgroup: _MutuallyExclusiveGroup # Arguments creation Loading Loading @@ -232,7 +232,7 @@ def main() -> None: Platform.flush() # Result if result: if result in [Entrypoint.Result.SUCCESS, Entrypoint.Result.FINALIZE]: sys_exit(0) else: sys_exit(1) Loading Loading
src/cli/entrypoint.py +29 −20 Changes for src/cli/entrypoint.py: 29 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ # Standard libraries from argparse import Namespace from enum import Enum # Modules libraries from gitlab.exceptions import GitlabGetError Loading @@ -20,13 +21,17 @@ from ..types.namespaces import Namespaces # Entrypoint class, pylint: disable=too-few-public-methods class Entrypoint: # Enumerations Result = Enum('Result', ['SUCCESS', 'FINALIZE', 'ERROR']) # CLI, pylint: disable=too-many-branches @staticmethod def cli(options: Namespace) -> bool: def cli(options: Namespace) -> Result: # Variables group: GitLabGroup = None project: GitLabProject = None result: Entrypoint.Result = Entrypoint.Result.ERROR user: GitLabUser = None # Header Loading Loading @@ -86,12 +91,13 @@ class Entrypoint: # Handle group if not options.exclude_group: if not Entrypoint.group( result = Entrypoint.group( options, gitlab, group.full_path, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Iterate through subgroups if not options.exclude_subgroups: Loading @@ -104,13 +110,14 @@ class Entrypoint: ), key=lambda item: item.full_path, ): if not Entrypoint.group( result = Entrypoint.group( options, gitlab, group_subgroup.full_path, True, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Iterate through projects if not options.exclude_projects: Loading @@ -123,12 +130,13 @@ class Entrypoint: ), key=lambda item: item.path_with_namespace, ): if not Entrypoint.project( result = Entrypoint.project( options, gitlab, group_project.path_with_namespace, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Handle user recursively elif user: Loading @@ -143,15 +151,16 @@ class Entrypoint: ), key=lambda item: item.path_with_namespace, ): if not Entrypoint.project( result = Entrypoint.project( options, gitlab, user_project.path_with_namespace, ): return False ) if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]: return result # Result return True return Entrypoint.Result.SUCCESS # Group @staticmethod Loading @@ -160,7 +169,7 @@ class Entrypoint: gitlab: GitLabFeature, criteria: str, subgroup: bool = False, ) -> bool: ) -> Result: # Acquire group group = gitlab.group(criteria) Loading Loading @@ -193,7 +202,7 @@ class Entrypoint: f'{Colors.RESET}') print(' ') Platform.flush() return subgroup return Entrypoint.Result.SUCCESS if subgroup else Entrypoint.Result.FINALIZE # Set group description if options.set_description: Loading Loading @@ -249,7 +258,7 @@ class Entrypoint: Platform.flush() # Result return True return Entrypoint.Result.SUCCESS # Project, pylint: disable=too-many-branches,too-many-statements @staticmethod Loading @@ -257,7 +266,7 @@ class Entrypoint: options: Namespace, gitlab: GitLabFeature, criteria: str, ) -> bool: ) -> Result: # Acquire project project = gitlab.project(criteria) Loading @@ -277,7 +286,7 @@ class Entrypoint: f'{Colors.RESET}') print(' ') Platform.flush() return True return Entrypoint.Result.SUCCESS # Set project description if options.set_description: Loading Loading @@ -402,4 +411,4 @@ class Entrypoint: Platform.flush() # Result return True return Entrypoint.Result.SUCCESS
src/cli/main.py +2 −2 Changes for src/cli/main.py: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ def main() -> None: # Variables group: _ArgumentGroup result: bool = False result: Entrypoint.Result = Entrypoint.Result.ERROR subgroup: _MutuallyExclusiveGroup # Arguments creation Loading Loading @@ -232,7 +232,7 @@ def main() -> None: Platform.flush() # Result if result: if result in [Entrypoint.Result.SUCCESS, Entrypoint.Result.FINALIZE]: sys_exit(0) else: sys_exit(1) Loading