Re-enable python < 3.5 support.

pull/111/head
Raphaël Vinot 2017-08-23 16:33:07 +02:00
parent 77845bd813
commit 314f7eaed1
3 changed files with 11 additions and 4 deletions

View File

@ -18,7 +18,7 @@ try:
from urllib.parse import urljoin from urllib.parse import urljoin
except ImportError: except ImportError:
from urlparse import urljoin from urlparse import urljoin
warnings.warn("You're using python 2, it is strongly recommended to use python >=3.4") warnings.warn("You're using python 2, it is strongly recommended to use python >=3.5")
from io import BytesIO, open from io import BytesIO, open
import zipfile import zipfile

View File

@ -43,7 +43,7 @@ from .exceptions import PyMISPError, NewEventError, NewAttributeError
try: try:
basestring basestring
unicode unicode
warnings.warn("You're using python 2, it is strongly recommended to use python >=3.4") warnings.warn("You're using python 2, it is strongly recommended to use python >=3.5")
except NameError: except NameError:
basestring = str basestring = str
unicode = str unicode = str

View File

@ -21,7 +21,7 @@ class InvalidMISPObject(MISPObjectException):
if six.PY2: if six.PY2:
import warnings import warnings
warnings.warn("You're using python 2, it is strongly recommended to use python >=3.4") warnings.warn("You're using python 2, it is strongly recommended to use python >=3.5")
class MISPObjectReference(AbstractMISP): class MISPObjectReference(AbstractMISP):
@ -80,7 +80,14 @@ class MISPObjectGenerator(AbstractMISP):
if attribute.value is None: if attribute.value is None:
continue continue
# Finalize the actual MISP Object # Finalize the actual MISP Object
new_object['Attribute'].append({'object_relation': object_type, **attribute._json()}) # FIXME: This only works on python >= 3.5
# new_object['Attribute'].append({'object_relation': object_type, **attribute._json()})
# ### BEGIN ####
# Because we still need to support old python.
temp_attribute = {'object_relation': object_type}
temp_attribute.update(attribute._json())
new_object['Attribute'].append(temp_attribute)
# ### END ####
return new_object, [r.to_dict() for r in self.references] return new_object, [r.to_dict() for r in self.references]
def _validate(self): def _validate(self):