From b1ac24d46ed2a974e1d7a67175a414dc4210535c Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Tue, 29 Aug 2017 15:08:26 -0400 Subject: [PATCH] Minor changes. --- .isort.cfg | 2 +- stix2/base.py | 6 +++--- stix2/exceptions.py | 2 +- stix2/utils.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index e8d95f8..622e7a5 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,7 +1,7 @@ [settings] check=1 diff=1 -known_third_party=dateutil,pytest,pytz,six,requests,taxii2client +known_third_party=ordereddict,dateutil,pytest,pytz,requests,simplejson,six,stix2patterns,stix2validator,taxii2client known_first_party=stix2 not_skip=__init__.py force_sort_within_sections=1 diff --git a/stix2/base.py b/stix2/base.py index a302eb5..60dd78a 100644 --- a/stix2/base.py +++ b/stix2/base.py @@ -38,7 +38,7 @@ def get_required_properties(properties): class _STIXBase(collections.Mapping): """Base class for STIX object types""" - def _object_properties(self): + def object_properties(self): return list(self._properties.keys()) def _check_property(self, prop_name, prop, kwargs): @@ -146,7 +146,7 @@ class _STIXBase(collections.Mapping): super(_STIXBase, self).__setattr__(name, value) def __str__(self): - properties = self._object_properties() + properties = self.object_properties() def sort_by(element): return find_property_index(self, properties, element) @@ -157,7 +157,7 @@ class _STIXBase(collections.Mapping): separators=(",", ": ")) def __repr__(self): - props = [(k, self[k]) for k in self._object_properties() if self.get(k)] + props = [(k, self[k]) for k in self.object_properties() if self.get(k)] return "{0}({1})".format(self.__class__.__name__, ", ".join(["{0!s}={1!r}".format(k, v) for k, v in props])) diff --git a/stix2/exceptions.py b/stix2/exceptions.py index ef47dd0..5a9e7b2 100644 --- a/stix2/exceptions.py +++ b/stix2/exceptions.py @@ -121,7 +121,7 @@ class DependentPropertiesError(STIXError, TypeError): def __str__(self): msg = "The property dependencies for {0}: ({1}) are not met." return msg.format(self.cls.__name__, - ", ".join(x for x in self.dependencies)) + ", ".join(name for x in self.dependencies for name in x)) class AtLeastOnePropertyError(STIXError, TypeError): diff --git a/stix2/utils.py b/stix2/utils.py index 9e0f33a..de481fc 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -133,7 +133,7 @@ def find_property_index(obj, properties, tuple_to_find): for item in pv: if isinstance(item, _STIXBase): val = find_property_index(item, - item._object_properties(), + item.object_properties(), tuple_to_find) if val is not None: return val @@ -146,7 +146,7 @@ def find_property_index(obj, properties, tuple_to_find): for item in pv.values(): if isinstance(item, _STIXBase): val = find_property_index(item, - item._object_properties(), + item.object_properties(), tuple_to_find) if val is not None: return val