Skip to content

Commit

Permalink
chg: Some more code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Aug 6, 2019
1 parent 5286462 commit 89a24d4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pymisp/aping.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,22 @@ def add_attribute(self, event: Union[MISPEvent, int, str, UUID], attribute: MISP
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'''
Expand Down

0 comments on commit 89a24d4

Please sign in to comment.