fix: Python2 SyntaxError...

pull/470/head
Raphaël Vinot 2019-10-10 08:58:06 +02:00
parent 02659a5782
commit 7c42a5f748
1 changed files with 6 additions and 8 deletions

View File

@ -1074,10 +1074,9 @@ class MISPObjectAttribute(MISPAttribute):
self.to_ids = self._definition.get('to_ids') self.to_ids = self._definition.get('to_ids')
if not self.type: if not self.type:
raise NewAttributeError("The type of the attribute is required. Is the object template missing?") raise NewAttributeError("The type of the attribute is required. Is the object template missing?")
if sys.version_info < (3, 5): super(MISPObjectAttribute, self).from_dict(**dict(self, **kwargs))
super(MISPObjectAttribute, self).from_dict(**dict(self, **kwargs)) # FIXME New syntax python3 only, keep for later.
else: # super(MISPObjectAttribute, self).from_dict(**{**self, **kwargs})
super(MISPObjectAttribute, self).from_dict(**{**self, **kwargs})
def __repr__(self): def __repr__(self):
if hasattr(self, 'value'): if hasattr(self, 'value'):
@ -1320,10 +1319,9 @@ class MISPObject(AbstractMISP):
else: else:
attribute = MISPObjectAttribute({}) attribute = MISPObjectAttribute({})
# Overwrite the parameters of self._default_attributes_parameters with the ones of value # Overwrite the parameters of self._default_attributes_parameters with the ones of value
if sys.version_info < (3, 5): attribute.from_dict(object_relation=object_relation, **dict(self._default_attributes_parameters, **value))
attribute.from_dict(object_relation=object_relation, **dict(self._default_attributes_parameters, **value)) # FIXME New syntax python3 only, keep for later.
else: # attribute.from_dict(object_relation=object_relation, **{**self._default_attributes_parameters, **value})
attribute.from_dict(object_relation=object_relation, **{**self._default_attributes_parameters, **value})
self.__fast_attribute_access[object_relation].append(attribute) self.__fast_attribute_access[object_relation].append(attribute)
self.Attribute.append(attribute) self.Attribute.append(attribute)
self.edited = True self.edited = True