Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jerlendds committed Dec 13, 2023
2 parents 63311ff + 10ba171 commit b459f1a
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 147 deletions.
24 changes: 12 additions & 12 deletions src/osintbuddy/elements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class BaseElement(object):
"""
def __init__(self, **kwargs):
self.label: str = ''
self.placeholder: str = ''

for key, value in kwargs.items():
if key == 'label' or key == 'placeholder':
setattr(self, key, value)

def _base_blueprint(self):
return {
'type': self.node_type,
'label': self.label,
}

if entity_type := kwargs.get('label'):
setattr(self, 'label', entity_type)

def _base_entity_element(self, **kwargs):
base_element = {}
if kwargs:
base_element = {
k: v for k, v in kwargs.items()
}
base_element['label'] = self.label
base_element['type'] = self.element_type
return base_element

class BaseInput(BaseElement):
pass
Expand Down
106 changes: 47 additions & 59 deletions src/osintbuddy/elements/displays.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,135 +2,123 @@


class Title(BaseDisplay):
node_type: str = 'title'
element_type: str = 'title'

def __init__(self, title='', subtitle='', text='', **kwargs):
def __init__(self, value='', **kwargs):
super().__init__(**kwargs)
self.title: str = title
self.subtitle: str = subtitle
self.text: str = text
self.element = {
"value": value,
}

def json(self):
blueprint = self._base_blueprint()
blueprint['title'] = self.title
blueprint['subtitle'] = self.subtitle
blueprint['text'] = self.text
return blueprint
def to_dict(self):
return self._base_entity_element(**self.element)


class Text(BaseDisplay):
node_type: str = 'section'
element_type: str = 'section'

def __init__(self, value='', icon="123", **kwargs):
super().__init__(**kwargs)
self.value = value
self.icon = icon
self.element = {
"value": value,
"icon": icon
}

def json(self):
blueprint = self._base_blueprint()
blueprint['value'] = self.value
blueprint['icon'] = self.icon
return blueprint
def to_dict(self):
return self._base_entity_element(**self.element)


class Empty(BaseDisplay):
node_type: str = 'empty'
element_type: str = 'empty'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()


class CopyText(BaseDisplay):
node_type: str = 'copy-text'
element_type: str = 'copy-text'

def __init__(self, value='', **kwargs):
super().__init__(**kwargs)
self.value = value
self.element = {
"value": value
}

def json(self):
blueprint = self._base_blueprint()
blueprint['value'] = self.value
return blueprint
def to_dict(self):
return self._base_entity_element(**self.element)


class CopyCode(BaseDisplay):
node_type: str = 'copy-code'
element_type: str = 'copy-code'

def __init__(self, value='', **kwargs):
super().__init__(**kwargs)
self.value = value
self.element = {
"value": value
}

def json(self):
blueprint = self._base_blueprint()
blueprint['value'] = self.value
return blueprint
def to_dict(self):
return self._base_entity_element(**self.element)


class Json(BaseDisplay):
node_type: str = 'json'
element_type: str = 'json'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()


class Image(BaseDisplay):
node_type: str = 'image'
element_type: str = 'image'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()


class Pdf(BaseDisplay):
node_type: str = 'pdf'
element_type: str = 'pdf'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()


class Video(BaseDisplay):
node_type: str = 'video'
element_type: str = 'video'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()


class List(BaseDisplay):
node_type: str = 'list'
element_type: str = 'list'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()


class Table(BaseDisplay):
node_type: str = 'table'
element_type: str = 'table'

def __init__(self, **kwargs):
super().__init__(**kwargs)

def json(self):
blueprint = self._base_blueprint()
return blueprint
def to_dict(self):
return self._base_entity_element()
89 changes: 42 additions & 47 deletions src/osintbuddy/elements/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class UploadFileInput(BaseInput):
"""
The UploadFileInput class represents an upload file input node used
!!WORK_IN_PROGRESS!! The UploadFileInput class represents an upload file input node used
in the OsintBuddy plugin system.
value : Any
The initial value for the input node.
Expand All @@ -17,20 +17,18 @@ class UploadFileInput(BaseInput):
class Plugin(OBPlugin):
node = [UploadFileInput(supported_files=['.pdf', '.docx'])]
"""
node_type: str = "upload"
element_type: str = "upload"

def __init__(self, value="", supported_files=[], icon="IconFileUpload", **kwargs):
super().__init__(**kwargs)
self.value: Any = value
self.icon: str = icon
self.supported_files: List[str] = supported_files
self.element = {
"value": value,
"icon": icon,
"supported_files": supported_files,
}

def json(self):
node = self._base_blueprint()
node["value"] = self.value
node["icon"] = self.icon
node["supported_files"] = self.supported_files
return node
def to_dict(self):
return self._base_entity_element(**self.element)


class TextInput(BaseInput):
Expand All @@ -47,18 +45,16 @@ class TextInput(BaseInput):
class Plugin(OBPlugin):
node = [TextInput(label='Email search', placeholder='Enter email')]
"""
node_type: str = "text"
element_type: str = "text"

def __init__(self, value="", default="", icon="IconAlphabetLatin", **kwargs):
super().__init__(**kwargs)
self.value: str = value
self.icon: str = icon

def json(self):
node = self._base_blueprint()
node["value"] = self.value
node["icon"] = self.icon
return node
self.element = {
"value": value,
"icon": icon
}
def to_dict(self):
return self._base_entity_element(**self.element)


class DropdownInput(BaseInput):
Expand All @@ -79,23 +75,23 @@ class Plugin(OBPlugin):
)
]
"""
node_type: str = "dropdown"
element_type: str = "dropdown"

def __init__(self, options=[], value={'label': '', 'tooltip': '', 'value': ''}, **kwargs):
super().__init__(**kwargs)
self.options: List[any] = options
self.value: dict = value
self.element = {
"options": options,
"value": value
}

def to_dict(self):
return self._base_entity_element(**self.element)

def json(self):
node = self._base_blueprint()
node["options"] = self.options
node["value"] = self.value
return node


class NumberInput(BaseInput):
"""
The NumberInput class represents a whole number input node used
!!WORK_IN_PROGRESS!! The NumberInput class represents a whole number input node used
in the OsintBuddy plugin system.
value : int
Expand All @@ -105,23 +101,22 @@ class NumberInput(BaseInput):
class Plugin(OBPlugin):
node = [NumberInput(value=10, placeholder='Enter a whole number')]
"""
node_type: str = "number"
element_type: str = "number"

def __init__(self, value=1, icon="123", **kwargs):
super().__init__(**kwargs)
self.value: int = value
self.icon = icon
self.element = {
"value": value,
"icon": icon
}

def json(self):
node = self._base_blueprint()
node["value"] = self.value
node["icon"] = self.icon
return node
def to_dict(self):
return self._base_entity_element(**self.element)


class DecimalInput(BaseInput):
"""
The DecimalInput class represents a decimal number input node used
!!WORK_IN_PROGRESS!! The DecimalInput class represents a decimal number input node used
in the OsintBuddy plugin system.
value : float
The float value stored in the node.
Expand All @@ -130,15 +125,15 @@ class DecimalInput(BaseInput):
class Plugin(OBPlugin):
node = [DecimalInput(value=3.14, placeholder='Enter a decimal number')]
"""
node_type: str = "decimal"
element_type: str = "decimal"

def __init__(self, value=3.14, icon="123", **kwargs):
super().__init__(**kwargs)
self.value: float = value
self.icon = icon

def json(self):
node = self._base_blueprint()
node["value"] = self.value
node["icon"] = self.icon
return node
self.element = {
"value": value,
"icon": icon
}

def to_dict(self):
return self._base_entity_element(**self.element)

Loading

0 comments on commit b459f1a

Please sign in to comment.