Revert changes to iterables.

stix2.0
Emmanuelle Vargas-Gonzalez 2018-06-12 15:03:25 -04:00
parent 78a480aa08
commit c12336b55a
1 changed files with 13 additions and 8 deletions

View File

@ -185,6 +185,7 @@ def _iterate_over_values(dict_values, tuple_to_find):
item.get(val) == tuple_to_find[1]): item.get(val) == tuple_to_find[1]):
return idx return idx
elif isinstance(pv, dict): elif isinstance(pv, dict):
if pv.get(tuple_to_find[0]) is not None:
for idx, item in enumerate(sorted(pv.keys())): for idx, item in enumerate(sorted(pv.keys())):
if ((item == tuple_to_find[0] and str.isdigit(item)) and if ((item == tuple_to_find[0] and str.isdigit(item)) and
(pv[item] == tuple_to_find[1])): (pv[item] == tuple_to_find[1])):
@ -193,17 +194,21 @@ def _iterate_over_values(dict_values, tuple_to_find):
return idx return idx
for item in pv.values(): for item in pv.values():
if isinstance(item, _STIXBase): if isinstance(item, _STIXBase):
return find_property_index( index = find_property_index(
item, item,
item.object_properties(), item.object_properties(),
tuple_to_find tuple_to_find
) )
if index is not None:
return index
elif isinstance(item, dict): elif isinstance(item, dict):
return find_property_index( index = find_property_index(
item, item,
item.keys(), item.keys(),
tuple_to_find tuple_to_find
) )
if index is not None:
return index
def find_property_index(obj, properties, tuple_to_find): def find_property_index(obj, properties, tuple_to_find):