From b4c60e94368a1acb8fad8d9fd1f55c5d1e5071ea Mon Sep 17 00:00:00 2001 From: jerlendds Date: Mon, 11 Dec 2023 16:14:38 -0700 Subject: [PATCH] Rework display element and pydantic transform model displays.py and plugins.py --- src/osintbuddy/elements/displays.py | 6 ++---- src/osintbuddy/plugins.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/osintbuddy/elements/displays.py b/src/osintbuddy/elements/displays.py index 5c792e4..3a620a4 100644 --- a/src/osintbuddy/elements/displays.py +++ b/src/osintbuddy/elements/displays.py @@ -4,12 +4,10 @@ class Title(BaseDisplay): element_type: str = 'title' - def __init__(self, title='', subtitle='', text='', **kwargs): + def __init__(self, value='', **kwargs): super().__init__(**kwargs) self.element = { - "title": title, - "subtitle": subtitle, - "text": text + "value": value, } def to_dict(self): diff --git a/src/osintbuddy/plugins.py b/src/osintbuddy/plugins.py index cff4352..168c4c8 100755 --- a/src/osintbuddy/plugins.py +++ b/src/osintbuddy/plugins.py @@ -1,18 +1,21 @@ -import os, imp, importlib, sys +import os, imp, importlib from typing import List, Any, Callable from collections import defaultdict -from pydantic import create_model, BaseModel +from pydantic import BaseModel, ConfigDict # from osintbuddy.utils import slugify from osintbuddy.elements.base import BaseElement from osintbuddy.errors import OBPluginError from osintbuddy.utils import to_snake_case -# @todo add permission system and display what parts of system plugin can access +OBNodeConfig = ConfigDict(extra="allow", frozen=False, populate_by_name=True, arbitrary_types_allowed=True) + +class OBNode(BaseModel): + model_config = OBNodeConfig + + class OBAuthorUse(BaseModel): - # @todo get_driver: Callable[[], None] - get_graph: Callable[[], None] class OBRegistry(type): @@ -300,5 +303,4 @@ def _map_to_transform_data(cls, node: dict): [cls._map_element(transform_map, elm) for elm in element] else: cls._map_element(transform_map, element) - model = create_model(model_label, **transform_map) - return model() + return OBNode(**transform_map)