fix: Grouped two if conditions to avoid issues with variable unassigned if the second condition is not true

pull/341/head
chrisr3d 2019-10-13 20:23:02 +02:00
parent b1ae8deb6b
commit 6d19549184
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 1 additions and 5 deletions

View File

@ -23,11 +23,7 @@ def handler(q=False):
r = requests.post(hashddapi_url, data={'hash': v})
if r.status_code == 200:
state = json.loads(r.text)
if state:
if state.get(v):
summary = state[v]['known_level']
else:
summary = 'Unknown hash'
summary = state[v]['known_level'] if state and state.get(v) else 'Unknown hash'
else:
misperrors['error'] = '{} API not accessible'.format(hashddapi_url)
return misperrors['error']