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,25 +185,30 @@ 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):
for idx, item in enumerate(sorted(pv.keys())): if pv.get(tuple_to_find[0]) is not None:
if ((item == tuple_to_find[0] and str.isdigit(item)) and for idx, item in enumerate(sorted(pv.keys())):
(pv[item] == tuple_to_find[1])): if ((item == tuple_to_find[0] and str.isdigit(item)) and
return int(tuple_to_find[0]) (pv[item] == tuple_to_find[1])):
elif pv[item] == tuple_to_find[1]: return int(tuple_to_find[0])
return idx elif pv[item] == tuple_to_find[1]:
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):