Skip to content

Commit

Permalink
Rework display element and pydantic transform model
Browse files Browse the repository at this point in the history
displays.py and plugins.py
  • Loading branch information
jerlendds committed Dec 11, 2023
1 parent 6e6daa7 commit b4c60e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/osintbuddy/elements/displays.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 9 additions & 7 deletions src/osintbuddy/plugins.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit b4c60e9

Please sign in to comment.