separate support triggers from main package

This commit is contained in:
Evgenii Alekseev 2024-10-27 14:28:12 +02:00
parent e88d35cf24
commit 2376603de9
4 changed files with 73 additions and 39 deletions

View File

@ -50,42 +50,6 @@ class Triggers(Handler):
application.on_start()
application.on_result(Result())
@staticmethod
def _set_repo_create_keyring_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for create-keyring subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-create-keyring", help="create keyring package",
description="create package which contains list of trusted keys as set by "
"configuration. Note, that this action will only create package, "
"the package itself has to be built manually")
parser.set_defaults(trigger=["ahriman.core.support.KeyringTrigger"])
return parser
@staticmethod
def _set_repo_create_mirrorlist_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for create-mirrorlist subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-create-mirrorlist", help="create mirrorlist package",
description="create package which contains list of available mirrors as set by "
"configuration. Note, that this action will only create package, "
"the package itself has to be built manually")
parser.set_defaults(trigger=["ahriman.core.support.MirrorlistTrigger"])
return parser
@staticmethod
def _set_repo_report_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
@ -138,8 +102,6 @@ class Triggers(Handler):
return parser
arguments = [
_set_repo_create_keyring_parser,
_set_repo_create_mirrorlist_parser,
_set_repo_report_parser,
_set_repo_sync_parser,
_set_repo_triggers_parser,

View File

@ -0,0 +1,70 @@
#
# Copyright (c) 2021-2024 ahriman team.
#
# This file is part of ahriman
# (see https://github.com/arcan1s/ahriman).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import argparse
from ahriman.application.handlers.handler import SubParserAction
from ahriman.application.handlers.triggers import Triggers
class TriggersSupport(Triggers):
"""
additional triggers handlers for support commands
"""
@staticmethod
def _set_repo_create_keyring_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for create-keyring subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-create-keyring", help="create keyring package",
description="create package which contains list of trusted keys as set by "
"configuration. Note, that this action will only create package, "
"the package itself has to be built manually")
parser.set_defaults(trigger=["ahriman.core.support.KeyringTrigger"])
return parser
@staticmethod
def _set_repo_create_mirrorlist_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for create-mirrorlist subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("repo-create-mirrorlist", help="create mirrorlist package",
description="create package which contains list of available mirrors as set by "
"configuration. Note, that this action will only create package, "
"the package itself has to be built manually")
parser.set_defaults(trigger=["ahriman.core.support.MirrorlistTrigger"])
return parser
arguments = [
_set_repo_create_keyring_parser,
_set_repo_create_mirrorlist_parser,
]

View File

@ -32,10 +32,11 @@ SUBPACKAGES = {
prefix / "bin",
prefix / "lib" / "systemd",
prefix / "share",
site_packages / "ahriman",
site_packages,
],
"ahriman-triggers": [
prefix / "share" / "ahriman" / "settings" / "ahriman.ini.d" / "00-triggers.ini",
site_packages / "ahriman" / "application" / "handlers" / "triggers_support.py",
site_packages / "ahriman" / "core" / "distributed",
site_packages / "ahriman" / "core" / "support",
],

View File

@ -0,0 +1 @@
# nothing to test here