Commit cfb36369 authored by Adrian DC's avatar Adrian DC
Browse files

chore(cli, package): minor Python codestyle improvements

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 055804a9
Loading
Loading
Loading
Loading
Loading
+22 −5
Changes for src/cli/entrypoint.py: 22 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -37,7 +37,12 @@ from ..types.namespaces import Namespaces
class Entrypoint:

    # Enumerations
    Result = Enum('Result', ['SUCCESS', 'FINALIZE', 'ERROR', 'CRITICAL'])
    Result = Enum('Result', [
        'SUCCESS',
        'FINALIZE',
        'ERROR',
        'CRITICAL',
    ])

    # CLI, pylint: disable=too-many-branches,too-many-locals,too-many-statements
    @staticmethod
@@ -149,7 +154,10 @@ class Entrypoint:
                    gitlab,
                    group.full_path,
                )
                if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]:
                if result in [
                        Entrypoint.Result.FINALIZE,
                        Entrypoint.Result.ERROR,
                ]:
                    return result

            # Iterate through subgroups
@@ -169,7 +177,10 @@ class Entrypoint:
                        group_subgroup.full_path,
                        True,
                    )
                    if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]:
                    if result in [
                            Entrypoint.Result.FINALIZE,
                            Entrypoint.Result.ERROR,
                    ]:
                        return result

            # Iterate through projects
@@ -188,7 +199,10 @@ class Entrypoint:
                        gitlab,
                        group_project.path_with_namespace,
                    )
                    if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]:
                    if result in [
                            Entrypoint.Result.FINALIZE,
                            Entrypoint.Result.ERROR,
                    ]:
                        return result

        # Handle user recursively
@@ -209,7 +223,10 @@ class Entrypoint:
                        gitlab,
                        user_project.path_with_namespace,
                    )
                    if result in [Entrypoint.Result.FINALIZE, Entrypoint.Result.ERROR]:
                    if result in [
                            Entrypoint.Result.FINALIZE,
                            Entrypoint.Result.ERROR,
                    ]:
                        return result

        # Result
+12 −3
Changes for src/cli/main.py: 12 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -453,7 +453,10 @@ def main() -> None:
        sys_exit(0)

    # Instantiate updates
    updates: Updates = Updates(name=Bundle.NAME, settings=settings)
    updates: Updates = Updates(
        name=Bundle.NAME,
        settings=settings,
    )

    # Version informations
    if options.version:
@@ -486,7 +489,10 @@ def main() -> None:

    # CLI entrypoint
    if result != Entrypoint.Result.CRITICAL:
        result = Entrypoint.cli(options, environments)
        result = Entrypoint.cli(
            options,
            environments,
        )

    # CLI helper
    else:
@@ -501,7 +507,10 @@ def main() -> None:
        updates.check()

    # Result
    if result in [Entrypoint.Result.SUCCESS, Entrypoint.Result.FINALIZE]:
    if result in [
            Entrypoint.Result.SUCCESS,
            Entrypoint.Result.FINALIZE,
    ]:
        sys_exit(0)
    else:
        sys_exit(1)
+9 −2
Changes for src/package/updates.py: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -23,7 +23,11 @@ class Updates:
    __settings: Settings

    # Constructor
    def __init__(self, name: str, settings: Settings) -> None:
    def __init__(
        self,
        name: str,
        settings: Settings,
    ) -> None:

        # Initialize members
        self.__name = name
@@ -54,7 +58,10 @@ class Updates:
            self.__settings.set('package', 'version', current_version)

    # Checker
    def check(self, older: bool = False) -> bool:
    def check(
        self,
        older: bool = False,
    ) -> bool:

        # Reference version
        version = '0.0.0' if older else Version.get()