From a18804a19537f354b80a9de96470ebaa9f565577 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Tue, 15 Aug 2017 14:12:21 -0400 Subject: [PATCH] Add ordereddict dependency for 2.6 support. Import change in utils.py --- setup.py | 1 + stix2/common.py | 5 ++++- stix2/core.py | 5 ++++- stix2/observables.py | 5 ++++- stix2/sdo.py | 5 ++++- stix2/sro.py | 5 ++++- stix2/utils.py | 3 +-- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 3a681fa..7b544ca 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,7 @@ setup( keywords="stix stix2 json cti cyber threat intelligence", packages=find_packages(), install_requires=[ + 'ordereddict' 'python-dateutil', 'pytz', 'requests', diff --git a/stix2/common.py b/stix2/common.py index 555ca98..c126d76 100644 --- a/stix2/common.py +++ b/stix2/common.py @@ -1,6 +1,9 @@ """STIX 2 Common Data Types and Properties""" -from collections import OrderedDict +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict from .base import _STIXBase from .properties import (BooleanProperty, HashesProperty, IDProperty, diff --git a/stix2/core.py b/stix2/core.py index be2a53d..0d0d1d2 100644 --- a/stix2/core.py +++ b/stix2/core.py @@ -1,6 +1,9 @@ """STIX 2.0 Objects that are neither SDOs nor SROs""" -from collections import OrderedDict +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict from . import exceptions from .base import _STIXBase diff --git a/stix2/observables.py b/stix2/observables.py index 87f95e2..4a1319c 100644 --- a/stix2/observables.py +++ b/stix2/observables.py @@ -5,7 +5,10 @@ embedded in Email Message objects, inherit from _STIXBase instead of Observable and do not have a '_type' attribute. """ -from collections import OrderedDict +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict from .base import _Extension, _Observable, _STIXBase from .exceptions import (AtLeastOnePropertyError, DependentPropertiesError, diff --git a/stix2/sdo.py b/stix2/sdo.py index 4904a53..b2b0e7e 100644 --- a/stix2/sdo.py +++ b/stix2/sdo.py @@ -1,6 +1,9 @@ """STIX 2.0 Domain Objects""" -from collections import OrderedDict +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict import stix2 diff --git a/stix2/sro.py b/stix2/sro.py index af483bc..05a29ed 100644 --- a/stix2/sro.py +++ b/stix2/sro.py @@ -1,6 +1,9 @@ """STIX 2.0 Relationship Objects.""" -from collections import OrderedDict +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict from .base import _STIXBase from .common import ExternalReference, GranularMarking diff --git a/stix2/utils.py b/stix2/utils.py index aa0caa6..9e0f33a 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -6,8 +6,6 @@ import json from dateutil import parser import pytz -from .base import _STIXBase - # Sentinel value for properties that should be set to the current time. # We can't use the standard 'default' approach, since if there are multiple # timestamps in a single object, the timestamps will vary by a few microseconds. @@ -124,6 +122,7 @@ def find_property_index(obj, properties, tuple_to_find): according to the _properties OrderedDict. If its a list look for individual objects. """ + from .base import _STIXBase try: if tuple_to_find[1] in obj._inner.values(): return properties.index(tuple_to_find[0])