mirror of https://github.com/MISP/PyMISP
chg: Remove dependency on six
parent
2c877f2aec
commit
fe91d06b91
|
@ -1,13 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import abc
|
|
||||||
import sys
|
import sys
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
from json import JSONEncoder
|
from json import JSONEncoder
|
||||||
import collections
|
import collections
|
||||||
import six # Remove that import when discarding python2 support.
|
|
||||||
import logging
|
import logging
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
@ -16,7 +14,7 @@ from .exceptions import PyMISPInvalidFormat
|
||||||
|
|
||||||
logger = logging.getLogger('pymisp')
|
logger = logging.getLogger('pymisp')
|
||||||
|
|
||||||
if six.PY2:
|
if sys.version_info < (3, 0):
|
||||||
logger.warning("You're using python 2, it is strongly recommended to use python >=3.6")
|
logger.warning("You're using python 2, it is strongly recommended to use python >=3.6")
|
||||||
|
|
||||||
# This is required because Python 2 is a pain.
|
# This is required because Python 2 is a pain.
|
||||||
|
@ -77,7 +75,6 @@ class MISPEncode(JSONEncoder):
|
||||||
return JSONEncoder.default(self, obj)
|
return JSONEncoder.default(self, obj)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta) # Remove that line when discarding python2 support.
|
|
||||||
class AbstractMISP(collections.MutableMapping):
|
class AbstractMISP(collections.MutableMapping):
|
||||||
|
|
||||||
__not_jsonable = []
|
__not_jsonable = []
|
||||||
|
|
|
@ -15,13 +15,11 @@ from . import deprecated
|
||||||
from .abstract import AbstractMISP
|
from .abstract import AbstractMISP
|
||||||
from .exceptions import UnknownMISPObjectTemplate, InvalidMISPObject, PyMISPError, NewEventError, NewAttributeError
|
from .exceptions import UnknownMISPObjectTemplate, InvalidMISPObject, PyMISPError, NewEventError, NewAttributeError
|
||||||
|
|
||||||
import six # Remove that import when discarding python2 support.
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger('pymisp')
|
logger = logging.getLogger('pymisp')
|
||||||
|
|
||||||
|
|
||||||
if six.PY2:
|
if sys.version_info < (3, 0):
|
||||||
logger.warning("You're using python 2, it is strongly recommended to use python >=3.6")
|
logger.warning("You're using python 2, it is strongly recommended to use python >=3.6")
|
||||||
|
|
||||||
# This is required because Python 2 is a pain.
|
# This is required because Python 2 is a pain.
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import abc
|
|
||||||
import six
|
|
||||||
from .. import MISPObject
|
from .. import MISPObject
|
||||||
from ..exceptions import InvalidMISPObject
|
from ..exceptions import InvalidMISPObject
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta) # Remove that line when discarding python2 support.
|
|
||||||
# Python3 way: class MISPObjectGenerator(metaclass=abc.ABCMeta):
|
|
||||||
class AbstractMISPObjectGenerator(MISPObject):
|
class AbstractMISPObjectGenerator(MISPObject):
|
||||||
|
|
||||||
def _detect_epoch(self, timestamp):
|
def _detect_epoch(self, timestamp):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import six
|
import sys
|
||||||
|
|
||||||
from . import FileObject, PEObject, ELFObject, MachOObject
|
from . import FileObject, PEObject, ELFObject, MachOObject
|
||||||
from ..exceptions import MISPObjectException
|
from ..exceptions import MISPObjectException
|
||||||
|
@ -57,7 +57,7 @@ def make_binary_objects(filepath=None, pseudofile=None, filename=None, standalon
|
||||||
if filepath:
|
if filepath:
|
||||||
lief_parsed = lief.parse(filepath=filepath)
|
lief_parsed = lief.parse(filepath=filepath)
|
||||||
else:
|
else:
|
||||||
if six.PY2:
|
if sys.version_info < (3, 0):
|
||||||
logger.critical('Pseudofile is not supported in python2. Just update.')
|
logger.critical('Pseudofile is not supported in python2. Just update.')
|
||||||
lief_parsed = None
|
lief_parsed = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -5,7 +5,6 @@ import unittest
|
||||||
import requests_mock
|
import requests_mock
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
import sys
|
import sys
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
@ -308,7 +307,7 @@ class TestOffline(unittest.TestCase):
|
||||||
return json.dumps(to_return, cls=MISPEncode)
|
return json.dumps(to_return, cls=MISPEncode)
|
||||||
|
|
||||||
def test_objects_pseudofile(self, m):
|
def test_objects_pseudofile(self, m):
|
||||||
if six.PY2:
|
if sys.version_info < (3, 0):
|
||||||
return unittest.SkipTest()
|
return unittest.SkipTest()
|
||||||
paths = ['cmd.exe', 'tmux', 'MachO-OSX-x64-ls']
|
paths = ['cmd.exe', 'tmux', 'MachO-OSX-x64-ls']
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue