From 515a975e515af13fa3754e78fd15591762416a61 Mon Sep 17 00:00:00 2001 From: Jonas L Date: Wed, 4 May 2022 14:12:06 +0200 Subject: [PATCH] feat(shared): remove unused abstract app (#1828) --- shared/README.md | 22 ------------------- shared/libretime_shared/app.py | 39 ---------------------------------- 2 files changed, 61 deletions(-) delete mode 100644 shared/libretime_shared/app.py diff --git a/shared/README.md b/shared/README.md index e0bf43ca4..4658ae956 100644 --- a/shared/README.md +++ b/shared/README.md @@ -34,28 +34,6 @@ config = Config(filepath="/etc/libretime/config.yml") > Don't instantiate a sub model if it has a required field, otherwise the `Config` class import will raise a `ValidationError`. -### App - -Create an app class that inherit from `libretime_shared.app.AbstractApp`. - -```py -from libretime_shared.app import AbstractApp - -class LiquidsoapApp(AbstractApp): - name = "liquidsoap" - - def __init__(self, some_arg, **kwargs): - super().__init__(**kwargs) - self.some_arg = some_arg - - def run(self): - ... - - -app = LiquidsoapApp(**kwargs) -app.run() -``` - ### CLI Decorate your CLI commands with the shared decorators to add extra flags. diff --git a/shared/libretime_shared/app.py b/shared/libretime_shared/app.py deleted file mode 100644 index 114db3398..000000000 --- a/shared/libretime_shared/app.py +++ /dev/null @@ -1,39 +0,0 @@ -from abc import ABC, abstractmethod -from os import PathLike -from pathlib import Path -from typing import Optional - -from loguru import logger - -from .logging import LogLevel, level_from_name, setup_logger - - -# pylint: disable=too-few-public-methods -class AbstractApp(ABC): - """ - Abstracts the creation of an application to reduce boilerplate code such - as logging setup. - """ - - log_level: LogLevel - log_filepath: Optional[Path] = None - - @property - @abstractmethod - def name(self) -> str: - ... - - def __init__( - self, - *, - log_level: str, - log_filepath: Optional[PathLike] = None, - ): - self.log_level = level_from_name(log_level) - - if log_filepath is not None: - self.log_filepath = Path(log_filepath) - - setup_logger(level=self.log_level, filepath=self.log_filepath) - - logger.info(f"Starting {self.name}...")