Coverage for src/paperap/plugins/base.py: 95%
21 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-11 21:37 -0400
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-11 21:37 -0400
1"""
2----------------------------------------------------------------------------
4 METADATA:
6 File: base.py
7 Project: paperap
8 Created: 2025-03-04
9 Version: 0.0.5
10 Author: Jess Mann
11 Email: jess@jmann.me
12 Copyright (c) 2025 Jess Mann
14----------------------------------------------------------------------------
16 LAST MODIFIED:
18 2025-03-04 By Jess Mann
20"""
22from __future__ import annotations
24from abc import ABC, abstractmethod
25from typing import TYPE_CHECKING, Any
27if TYPE_CHECKING:
28 from paperap.client import PaperlessClient
31class Plugin(ABC):
32 """Base class for all plugins."""
34 # Class attributes for plugin metadata
35 name: str | None = None
36 description: str = "No description provided"
37 version: str = "0.0.1"
38 client: PaperlessClient
39 config: dict[str, Any]
41 def __init__(self, client: "PaperlessClient", **kwargs: Any) -> None:
42 """
43 Initialize the plugin.
45 Args:
46 client: The PaperlessClient instance.
47 **kwargs: Plugin-specific configuration.
49 """
50 self.client = client
51 self.config = kwargs
52 self.setup()
53 super().__init__()
55 @abstractmethod
56 def setup(self):
57 """Register signal handlers and perform other initialization tasks."""
59 @abstractmethod
60 def teardown(self):
61 """Clean up resources when the plugin is disabled or the application exits."""
63 @classmethod
64 def get_config_schema(cls) -> dict[str, Any]:
65 """
66 Get the configuration schema for this plugin.
68 Returns:
69 A dictionary describing the expected configuration parameters.
71 """
72 return {}