frivalous list comprehensions converted to list()

stix2.1
= 2017-10-03 16:20:03 -04:00
parent e2151659d7
commit 616ec6bbeb
3 changed files with 6 additions and 6 deletions

View File

@ -181,7 +181,7 @@ class FileSystemSource(DataSource):
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):
"""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
stix_obj = json.load(open(os.path.join(root, file_)))["objects"][0]
# 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)
else:
# have to load into memory regardless to evaluate other filters
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 = deduplicate(all_data)

View File

@ -281,7 +281,7 @@ class MemorySource(DataSource):
query.update(_composite_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

View File

@ -126,7 +126,7 @@ class TAXIICollectionSource(DataSource):
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):
stix_obj = stix_obj[0]
@ -204,7 +204,7 @@ class TAXIICollectionSource(DataSource):
all_data = deduplicate(all_data)
# 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
stix_objs = [parse(stix_obj_dict) for stix_obj_dict in all_data]