feat: use split packages (#135)

* move argument parsers to handlers themselves

* use hatchling instead of flit

* Revert "use hatchling instead of flit"

This reverts commit d18d146d79.

* add package-splitt script

* replace simplify walk method

* split packages

* explicitly install packages

* separate support triggers from main package

* add docs examples

* sort actions

* docs update

* add metapackage

* review fixes
This commit is contained in:
2024-11-01 16:07:04 +02:00
committed by GitHub
parent 6fe77eb465
commit 93ce7f9a51
105 changed files with 1982 additions and 1631 deletions

View File

@ -20,12 +20,14 @@
import argparse
from collections.abc import Generator
from pathlib import Path
from ahriman.application.handlers.handler import Handler
from ahriman.application.handlers.handler import Handler, SubParserAction
from ahriman.core.configuration import Configuration
from ahriman.core.spawn import Spawn
from ahriman.core.triggers import TriggerLoader
from ahriman.models.repository_id import RepositoryId
from ahriman.web.web import run_server, setup_server
class Web(Handler):
@ -47,9 +49,6 @@ class Web(Handler):
configuration(Configuration): configuration instance
report(bool): force enable or disable reporting
"""
# we are using local import for optional dependencies
from ahriman.web.web import run_server, setup_server
spawner_args = Web.extract_arguments(args, configuration)
spawner = Spawn(args.parser(), list(spawner_args))
spawner.start()
@ -71,6 +70,21 @@ class Web(Handler):
spawner.stop()
spawner.join()
@staticmethod
def _set_web_parser(root: SubParserAction) -> argparse.ArgumentParser:
"""
add parser for web subcommand
Args:
root(SubParserAction): subparsers for the commands
Returns:
argparse.ArgumentParser: created argument parser
"""
parser = root.add_parser("web", help="web server", description="start web server")
parser.set_defaults(architecture="", lock=Path("ahriman-web.pid"), report=False, repository="")
return parser
@staticmethod
def extract_arguments(args: argparse.Namespace, configuration: Configuration) -> Generator[str, None, None]:
"""
@ -100,3 +114,5 @@ class Web(Handler):
# arguments from configuration
if (wait_timeout := configuration.getint("web", "wait_timeout", fallback=None)) is not None:
yield from ["--wait-timeout", str(wait_timeout)]
arguments = [_set_web_parser]