mirror of https://github.com/MISP/PyMISP
chg: Add __repr__ methods
parent
19a50a7ba7
commit
56c74f1f50
|
@ -147,6 +147,9 @@ class MISPAttribute(AbstractMISP):
|
|||
# to be deprecated
|
||||
self.from_dict(**kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return '<{self.__class__.__name__}(self.type, self.value)'.format(self=self)
|
||||
|
||||
def from_dict(self, **kwargs):
|
||||
if kwargs.get('type') and kwargs.get('category'):
|
||||
if kwargs['type'] not in self.__category_type_mapping[kwargs['category']]:
|
||||
|
@ -438,6 +441,9 @@ class MISPEvent(AbstractMISP):
|
|||
# to be deprecated
|
||||
self.from_dict(**kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return '<{self.__class__.__name__}(self.info, self.date)'.format(self=self)
|
||||
|
||||
def from_dict(self, **kwargs):
|
||||
# Required value
|
||||
self.info = kwargs.pop('info', None)
|
||||
|
@ -618,6 +624,9 @@ class MISPObjectReference(AbstractMISP):
|
|||
def __init__(self):
|
||||
super(MISPObjectReference, self).__init__()
|
||||
|
||||
def __repr__(self):
|
||||
return '<{self.__class__.__name__}(self.object_uuid, self.referenced_uuid, self.relationship_type)'.format(self=self)
|
||||
|
||||
def from_dict(self, object_uuid, referenced_uuid, relationship_type, comment=None, **kwargs):
|
||||
self.object_uuid = object_uuid
|
||||
self.referenced_uuid = referenced_uuid
|
||||
|
@ -653,6 +662,9 @@ class MISPObjectAttribute(MISPAttribute):
|
|||
super(MISPObjectAttribute, self).__init__()
|
||||
self.__definition = definition
|
||||
|
||||
def __repr__(self):
|
||||
return '<{self.__class__.__name__}(self.object_relation, self.value)'.format(self=self)
|
||||
|
||||
def from_dict(self, object_relation, value, **kwargs):
|
||||
self.object_relation = object_relation
|
||||
self.value = value
|
||||
|
@ -733,6 +745,9 @@ class MISPObject(AbstractMISP):
|
|||
# Mark as non_jsonable because we need to add the references manually after the object(s) have been created
|
||||
self.update_not_jsonable('ObjectReference')
|
||||
|
||||
def __repr__(self):
|
||||
return '<{self.__class__.__name__}(self.name)'.format(self=self)
|
||||
|
||||
def from_dict(self, **kwargs):
|
||||
if self.__known_template:
|
||||
if kwargs.get('template_uuid') and kwargs['template_uuid'] != self.template_uuid:
|
||||
|
|
Loading…
Reference in New Issue