From b74e558f75b5cf664f91281a9a72ccb83cf5c9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 31 Aug 2017 10:40:18 +0200 Subject: [PATCH] Some more refactoring --- pymisp/mispevent.py | 11 ----------- pymisp/tools/abstractgenerator.py | 16 ++++++++++++++++ pymisp/tools/elfobject.py | 2 +- pymisp/tools/fileobject.py | 2 +- pymisp/tools/machoobject.py | 2 +- pymisp/tools/peobject.py | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 pymisp/tools/abstractgenerator.py diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 4853c75..29ca271 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -10,7 +10,6 @@ import base64 from io import BytesIO from zipfile import ZipFile import hashlib -import abc import sys import uuid from collections import Counter @@ -796,13 +795,3 @@ class MISPObject(AbstractMISP): attribute.from_dict(object_relation, **value) self.Attribute.append(attribute) return attribute - - -@six.add_metaclass(abc.ABCMeta) # Remove that line when discarding python2 support. -# Python3 way: class MISPObjectGenerator(metaclass=abc.ABCMeta): -class AbstractMISPObjectGenerator(MISPObject): - - @abc.abstractmethod - def generate_attributes(self): - """Contains the logic where all the values of the object are gathered""" - pass diff --git a/pymisp/tools/abstractgenerator.py b/pymisp/tools/abstractgenerator.py new file mode 100644 index 0000000..2645bb5 --- /dev/null +++ b/pymisp/tools/abstractgenerator.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import abc +import six +from .. import MISPObject + + +@six.add_metaclass(abc.ABCMeta) # Remove that line when discarding python2 support. +# Python3 way: class MISPObjectGenerator(metaclass=abc.ABCMeta): +class AbstractMISPObjectGenerator(MISPObject): + + @abc.abstractmethod + def generate_attributes(self): + """Contains the logic where all the values of the object are gathered""" + pass diff --git a/pymisp/tools/elfobject.py b/pymisp/tools/elfobject.py index 28b0cb1..e5b90fa 100644 --- a/pymisp/tools/elfobject.py +++ b/pymisp/tools/elfobject.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from .. import AbstractMISPObjectGenerator +from .abstractgenerator import AbstractMISPObjectGenerator from io import BytesIO from hashlib import md5, sha1, sha256, sha512 import warnings diff --git a/pymisp/tools/fileobject.py b/pymisp/tools/fileobject.py index 95b39af..5df7055 100644 --- a/pymisp/tools/fileobject.py +++ b/pymisp/tools/fileobject.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from .. import AbstractMISPObjectGenerator +from .abstractgenerator import AbstractMISPObjectGenerator import os from io import BytesIO from hashlib import md5, sha1, sha256, sha512 diff --git a/pymisp/tools/machoobject.py b/pymisp/tools/machoobject.py index 84b5000..10a9bad 100644 --- a/pymisp/tools/machoobject.py +++ b/pymisp/tools/machoobject.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from .. import AbstractMISPObjectGenerator +from .abstractgenerator import AbstractMISPObjectGenerator from io import BytesIO from hashlib import md5, sha1, sha256, sha512 import warnings diff --git a/pymisp/tools/peobject.py b/pymisp/tools/peobject.py index 65a7123..a6af720 100644 --- a/pymisp/tools/peobject.py +++ b/pymisp/tools/peobject.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from .. import AbstractMISPObjectGenerator +from .abstractgenerator import AbstractMISPObjectGenerator from io import BytesIO from hashlib import md5, sha1, sha256, sha512 from datetime import datetime