Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 5a43307

Browse files
author
clittle
committed
Patches edge case bugs
1 parent 36a2815 commit 5a43307

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

layers/manipulators/layerops.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,13 @@ def _build_template(self, data):
211211
for key in temp:
212212
for elm in temp[key]:
213213
if not any(elm['techniqueID'] == x['techniqueID']
214+
and elm['tactic'] == x['tactic']
214215
for x in t2):
215216
t2.append(elm)
216217
else:
217218
[x.update(elm)
218219
if x['techniqueID'] == elm['techniqueID']
220+
and elm['tactic'] == x['tactic']
219221
else x for x in t2]
220222
return t2
221223

@@ -231,8 +233,13 @@ def _template(self, data):
231233
temp.append([{"techniqueID": x.techniqueID, "tactic": x.tactic}
232234
if x.tactic else {"techniqueID": x.techniqueID}
233235
for x in entry])
234-
return list({v['techniqueID']: v
235-
for v in [elm for list in temp for elm in list]}.values())
236+
complete = []
237+
for entry in temp:
238+
for val in entry:
239+
if val in complete:
240+
continue
241+
complete.append(val)
242+
return complete
236243

237244
def _grabList(self, search, collection):
238245
"""
@@ -303,7 +310,10 @@ def _applyOperation(self, corpus, element, name, lda, defaults, glob=None):
303310
listing = [getattr(x.layer, glob) for x in corpus]
304311
listing = [{name: x} for x in listing]
305312
else:
306-
listing = self._grabList(element, corpus)
313+
te = dict(techniqueID=element['techniqueID'])
314+
if 'tactic' in element:
315+
te['tactic'] = element['tactic']
316+
listing = self._grabList(te, corpus)
307317
listing = [x.get_dict() if not isinstance(x, dict)
308318
else dict() for x in listing]
309319
values = []
@@ -323,7 +333,10 @@ def _applyOperation(self, corpus, element, name, lda, defaults, glob=None):
323333
for k in corpus.keys():
324334
listing[k] = {glob: getattr(corpus[k].layer, glob)}
325335
else:
326-
temp = self._grabDict(element, corpus)
336+
te = dict(techniqueID=element['techniqueID'])
337+
if 'tactic' in element:
338+
te['tactic'] = element['tactic']
339+
temp = self._grabDict(te, corpus)
327340
listing = {}
328341
for k in temp.keys():
329342
if temp[k] != {}:

0 commit comments

Comments
 (0)