Browse Source

fix: Handling cases where there is no result from the query

pull/340/head
chrisr3d 2 years ago
parent
commit
5d4a0bff98
No known key found for this signature in database GPG Key ID: 6BBED1B63A6D639F
  1. 7
      misp_modules/modules/expansion/wiki.py

7
misp_modules/modules/expansion/wiki.py

@ -26,13 +26,12 @@ def handler(q=False):
sparql.setQuery(query_string)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
summary = ''
try:
result = results["results"]["bindings"][0]
summary = result["item"]["value"]
result = results["results"]["bindings"]
summary = result[0]["item"]["value"] if result else 'No additional data found on Wikidata'
except Exception as e:
misperrors['error'] = 'wikidata API not accessible' + e
misperrors['error'] = 'wikidata API not accessible {}'.format(e)
return misperrors['error']
r = {'results': [{'types': mispattributes['output'], 'values': summary}]}

Loading…
Cancel
Save