From 1b5a080544127903a00a734626f9a5899e4a9831 Mon Sep 17 00:00:00 2001 From: oddluck <39967334+oddluck@users.noreply.github.com> Date: Wed, 4 Mar 2020 00:05:24 +0000 Subject: [PATCH] Corona: better state/province searching --- Corona/plugin.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Corona/plugin.py b/Corona/plugin.py index 878cac1..64b2619 100644 --- a/Corona/plugin.py +++ b/Corona/plugin.py @@ -84,19 +84,26 @@ class Corona(callbacks.Plugin): recovered += r.get('Recovered') local_ratio_dead = "{0:.00%}".format(deaths/confirmed) elif state: - state = state.split(',', 1) - if search.lower() == state[0].lower().strip(): - location = state[0].strip() - confirmed += r.get('Confirmed') - deaths += r.get('Deaths') - recovered += r.get('Recovered') - local_ratio_dead = "{0:.00%}".format(deaths/confirmed) - elif len(state) > 1 and search.lower() == state[1].lower().strip(): - location = state[1].strip() + if search.lower() == state.lower(): + location = state confirmed += r.get('Confirmed') deaths += r.get('Deaths') recovered += r.get('Recovered') local_ratio_dead = "{0:.00%}".format(deaths/confirmed) + else: + state = state.split(',', 1) + if search.lower() == state[0].lower().strip(): + location = r.get('Province_State') + confirmed += r.get('Confirmed') + deaths += r.get('Deaths') + recovered += r.get('Recovered') + local_ratio_dead = "{0:.00%}".format(deaths/confirmed) + elif len(state) > 1 and search.lower() == state[1].lower().strip(): + location = state[1].strip() + confirmed += r.get('Confirmed') + deaths += r.get('Deaths') + recovered += r.get('Recovered') + local_ratio_dead = "{0:.00%}".format(deaths/confirmed) total_confirmed += r.get('Confirmed') total_deaths += r.get('Deaths')