Minor changes.

stix2.1
Emmanuelle Vargas-Gonzalez 2017-08-29 15:08:26 -04:00
parent 415c53066f
commit b1ac24d46e
4 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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]))

View File

@ -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):

View File

@ -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