frivalous list comprehensions converted to list()
parent
e2151659d7
commit
616ec6bbeb
|
@ -181,7 +181,7 @@ class FileSystemSource(DataSource):
|
||||||
a python STIX objects and then returned
|
a python STIX objects and then returned
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return [self.get(stix_id=stix_id, _composite_filters=_composite_filters)]
|
return list(self.get(stix_id=stix_id, _composite_filters=_composite_filters))
|
||||||
|
|
||||||
def query(self, query=None, _composite_filters=None):
|
def query(self, query=None, _composite_filters=None):
|
||||||
"""search and retrieve STIX objects based on the complete query
|
"""search and retrieve STIX objects based on the complete query
|
||||||
|
@ -279,12 +279,12 @@ class FileSystemSource(DataSource):
|
||||||
# since ID is specified in one of filters, can evaluate against filename first without loading
|
# since ID is specified in one of filters, can evaluate against filename first without loading
|
||||||
stix_obj = json.load(open(os.path.join(root, file_)))["objects"][0]
|
stix_obj = json.load(open(os.path.join(root, file_)))["objects"][0]
|
||||||
# check against other filters, add if match
|
# check against other filters, add if match
|
||||||
matches = [stix_obj_ for stix_obj_ in apply_common_filters([stix_obj], query)]
|
matches = list(apply_common_filters([stix_obj], query))
|
||||||
all_data.extend(matches)
|
all_data.extend(matches)
|
||||||
else:
|
else:
|
||||||
# have to load into memory regardless to evaluate other filters
|
# have to load into memory regardless to evaluate other filters
|
||||||
stix_obj = json.load(open(os.path.join(root, file_)))["objects"][0]
|
stix_obj = json.load(open(os.path.join(root, file_)))["objects"][0]
|
||||||
matches = [stix_obj_ for stix_obj_ in apply_common_filters([stix_obj], query)]
|
matches = list(apply_common_filters([stix_obj], query))
|
||||||
all_data.extend(matches)
|
all_data.extend(matches)
|
||||||
|
|
||||||
all_data = deduplicate(all_data)
|
all_data = deduplicate(all_data)
|
||||||
|
|
|
@ -281,7 +281,7 @@ class MemorySource(DataSource):
|
||||||
query.update(_composite_filters)
|
query.update(_composite_filters)
|
||||||
|
|
||||||
# Apply STIX common property filters.
|
# Apply STIX common property filters.
|
||||||
all_data = [stix_obj for stix_obj in apply_common_filters(self._data.values(), query)]
|
all_data = list(apply_common_filters(self._data.values(), query))
|
||||||
|
|
||||||
return all_data
|
return all_data
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ class TAXIICollectionSource(DataSource):
|
||||||
|
|
||||||
stix_objs = self.collection.get_object(stix_id, taxii_filters)["objects"]
|
stix_objs = self.collection.get_object(stix_id, taxii_filters)["objects"]
|
||||||
|
|
||||||
stix_obj = [stix_obj for stix_obj in apply_common_filters(stix_objs, query)]
|
stix_obj = list(apply_common_filters(stix_objs, query))
|
||||||
|
|
||||||
if len(stix_obj):
|
if len(stix_obj):
|
||||||
stix_obj = stix_obj[0]
|
stix_obj = stix_obj[0]
|
||||||
|
@ -204,7 +204,7 @@ class TAXIICollectionSource(DataSource):
|
||||||
all_data = deduplicate(all_data)
|
all_data = deduplicate(all_data)
|
||||||
|
|
||||||
# apply local (CompositeDataSource, TAXIICollectionSource and query filters)
|
# apply local (CompositeDataSource, TAXIICollectionSource and query filters)
|
||||||
all_data = [stix_obj for stix_obj in apply_common_filters(all_data, query)]
|
all_data = list(apply_common_filters(all_data, query))
|
||||||
|
|
||||||
# parse python STIX objects from the STIX object dicts
|
# parse python STIX objects from the STIX object dicts
|
||||||
stix_objs = [parse(stix_obj_dict) for stix_obj_dict in all_data]
|
stix_objs = [parse(stix_obj_dict) for stix_obj_dict in all_data]
|
||||||
|
|
Loading…
Reference in New Issue