From 89a24d49230a30f8249e54969f3d928cf8664be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 6 Aug 2019 14:26:54 +0200 Subject: [PATCH] chg: Some more code cleanup --- pymisp/aping.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pymisp/aping.py b/pymisp/aping.py index 4dd6489..1c103fe 100644 --- a/pymisp/aping.py +++ b/pymisp/aping.py @@ -363,22 +363,22 @@ class ExpandedPyMISP(PyMISP): if 'errors' in new_attribute: to_return['errors'] = new_attribute['errors'] - for attribute in new_attribute['Attribute']: + for new_attr in new_attribute['Attribute']: a = MISPAttribute() a.from_dict(**attribute) to_return['attributes'].append(a) return to_return - else: - if ('errors' in new_attribute and new_attribute['errors'][0] == 403 - and new_attribute['errors'][1]['message'] == 'You do not have permission to do that.'): - # At this point, we assume the user tried to add an attribute on an event they don't own - # Re-try with a proposal - return self.add_attribute_proposal(event_id, attribute, pythonify) - if not (self.global_pythonify or pythonify) or 'errors' in new_attribute: - return new_attribute - a = MISPAttribute() - a.from_dict(**new_attribute) - return a + + if ('errors' in new_attribute and new_attribute['errors'][0] == 403 + and new_attribute['errors'][1]['message'] == 'You do not have permission to do that.'): + # At this point, we assume the user tried to add an attribute on an event they don't own + # Re-try with a proposal + return self.add_attribute_proposal(event_id, attribute, pythonify) + if not (self.global_pythonify or pythonify) or 'errors' in new_attribute: + return new_attribute + a = MISPAttribute() + a.from_dict(**new_attribute) + return a def update_attribute(self, attribute: MISPAttribute, attribute_id: int=None, pythonify: bool=False): '''Update an attribute on a MISP instance'''