python 3.7 support
parent
f47bb6ca3a
commit
e80fb4f59a
|
@ -6,6 +6,7 @@ python:
|
|||
- "3.4"
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
- "3.7"
|
||||
install:
|
||||
- pip install -U pip setuptools
|
||||
- pip install tox-travis pre-commit
|
||||
|
|
1
setup.py
1
setup.py
|
@ -43,6 +43,7 @@ setup(
|
|||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
],
|
||||
keywords="stix stix2 json cti cyber threat intelligence",
|
||||
packages=find_packages(exclude=['*.test']),
|
||||
|
|
|
@ -331,3 +331,8 @@ class _Extension(_STIXBase):
|
|||
def _check_object_constraints(self):
|
||||
super(_Extension, self)._check_object_constraints()
|
||||
self._check_at_least_one_property()
|
||||
|
||||
|
||||
def _cls_init(cls, obj, kwargs):
|
||||
if getattr(cls, '__init__', object.__init__) is not object.__init__:
|
||||
cls.__init__(obj, **kwargs)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from collections import OrderedDict
|
||||
|
||||
from ..base import _STIXBase
|
||||
from ..base import _cls_init, _STIXBase
|
||||
from ..markings import _MarkingsMixin
|
||||
from ..properties import (HashesProperty, IDProperty, ListProperty, Property,
|
||||
ReferenceProperty, SelectorProperty, StringProperty,
|
||||
|
@ -169,14 +169,7 @@ def CustomMarking(type='x-custom-marking', properties=None):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
_STIXBase.__init__(self, **kwargs)
|
||||
try:
|
||||
cls.__init__(self, **kwargs)
|
||||
except (AttributeError, TypeError) as e:
|
||||
# Don't accidentally catch errors raised in a custom __init__()
|
||||
if ("has no attribute '__init__'" in str(e) or
|
||||
str(e) == "object.__init__() takes no parameters"):
|
||||
return
|
||||
raise e
|
||||
_cls_init(cls, self, kwargs)
|
||||
|
||||
_register_marking(_Custom)
|
||||
return _Custom
|
||||
|
|
|
@ -9,7 +9,7 @@ from collections import OrderedDict
|
|||
import copy
|
||||
import re
|
||||
|
||||
from ..base import _Extension, _Observable, _STIXBase
|
||||
from ..base import _cls_init, _Extension, _Observable, _STIXBase
|
||||
from ..exceptions import (AtLeastOnePropertyError, CustomContentError,
|
||||
DependentPropertiesError, ParseError)
|
||||
from ..properties import (BinaryProperty, BooleanProperty, DictionaryProperty,
|
||||
|
@ -1027,14 +1027,7 @@ def CustomObservable(type='x-custom-observable', properties=None):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
_Observable.__init__(self, **kwargs)
|
||||
try:
|
||||
cls.__init__(self, **kwargs)
|
||||
except (AttributeError, TypeError) as e:
|
||||
# Don't accidentally catch errors raised in a custom __init__()
|
||||
if ("has no attribute '__init__'" in str(e) or
|
||||
str(e) == "object.__init__() takes no parameters"):
|
||||
return
|
||||
raise e
|
||||
_cls_init(cls, self, kwargs)
|
||||
|
||||
_register_observable(_Custom)
|
||||
return _Custom
|
||||
|
@ -1090,14 +1083,7 @@ def CustomExtension(observable=None, type='x-custom-observable', properties=None
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
_Extension.__init__(self, **kwargs)
|
||||
try:
|
||||
cls.__init__(self, **kwargs)
|
||||
except (AttributeError, TypeError) as e:
|
||||
# Don't accidentally catch errors raised in a custom __init__()
|
||||
if ("has no attribute '__init__'" in str(e) or
|
||||
str(e) == "object.__init__() takes no parameters"):
|
||||
return
|
||||
raise e
|
||||
_cls_init(cls, self, kwargs)
|
||||
|
||||
_register_extension(observable, _Custom)
|
||||
return _Custom
|
||||
|
|
|
@ -6,7 +6,7 @@ import re
|
|||
|
||||
import stix2
|
||||
|
||||
from ..base import _STIXBase
|
||||
from ..base import _cls_init, _STIXBase
|
||||
from ..markings import _MarkingsMixin
|
||||
from ..properties import (BooleanProperty, IDProperty, IntegerProperty,
|
||||
ListProperty, PatternProperty, ReferenceProperty,
|
||||
|
@ -400,14 +400,7 @@ def CustomObject(type='x-custom-type', properties=None):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
_STIXBase.__init__(self, **kwargs)
|
||||
try:
|
||||
cls.__init__(self, **kwargs)
|
||||
except (AttributeError, TypeError) as e:
|
||||
# Don't accidentally catch errors raised in a custom __init__()
|
||||
if ("has no attribute '__init__'" in str(e) or
|
||||
str(e) == "object.__init__() takes no parameters"):
|
||||
return
|
||||
raise e
|
||||
_cls_init(cls, self, kwargs)
|
||||
|
||||
stix2._register_type(_Custom, version="2.0")
|
||||
return _Custom
|
||||
|
|
Loading…
Reference in New Issue