Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -187,14 +187,14 @@ def filter_results(results, country_filter, region_filter, end_year_range, crs_f
|
|
187 |
try:
|
188 |
parsed_country = json.loads(country.replace("'", '"'))
|
189 |
if isinstance(parsed_country, str):
|
190 |
-
|
191 |
else:
|
192 |
-
|
193 |
-
c_list = [code
|
194 |
except json.JSONDecodeError:
|
195 |
c_list = []
|
196 |
else:
|
197 |
-
c_list = [country
|
198 |
crs_key = metadata.get("crs_key", "").strip()
|
199 |
# Convert crs_key to a string and remove trailing ".0"
|
200 |
crs_key_clean = re.sub(r'\.0$', '', str(crs_key))
|
@@ -435,9 +435,10 @@ else:
|
|
435 |
c_list = [country_value]
|
436 |
matched_country = []
|
437 |
for code in c_list:
|
438 |
-
|
439 |
-
|
440 |
-
|
|
|
441 |
matched_country.append(resolved_name)
|
442 |
crs_key = metadata.get("crs_key", "").strip()
|
443 |
# Convert to string and remove trailing ".0"
|
@@ -518,9 +519,10 @@ else:
|
|
518 |
c_list = [country_value]
|
519 |
matched_country = []
|
520 |
for code in c_list:
|
521 |
-
|
522 |
-
|
523 |
-
|
|
|
524 |
matched_country.append(resolved_name)
|
525 |
crs_key = metadata.get("crs_key", "").strip()
|
526 |
# Convert to string and remove trailing ".0"
|
|
|
187 |
try:
|
188 |
parsed_country = json.loads(country.replace("'", '"'))
|
189 |
if isinstance(parsed_country, str):
|
190 |
+
country_list = [parsed_country]
|
191 |
else:
|
192 |
+
country_list = parsed_country
|
193 |
+
c_list = [clean_country_code(code) for code in country_list if len(clean_country_code(code)) == 2]
|
194 |
except json.JSONDecodeError:
|
195 |
c_list = []
|
196 |
else:
|
197 |
+
c_list = [clean_country_code(country)]
|
198 |
crs_key = metadata.get("crs_key", "").strip()
|
199 |
# Convert crs_key to a string and remove trailing ".0"
|
200 |
crs_key_clean = re.sub(r'\.0$', '', str(crs_key))
|
|
|
435 |
c_list = [country_value]
|
436 |
matched_country = []
|
437 |
for code in c_list:
|
438 |
+
cleaned = clean_country_code(code)
|
439 |
+
if len(cleaned) == 2:
|
440 |
+
resolved_name = get_country_name(cleaned, region_df)
|
441 |
+
if resolved_name.upper() != cleaned.upper():
|
442 |
matched_country.append(resolved_name)
|
443 |
crs_key = metadata.get("crs_key", "").strip()
|
444 |
# Convert to string and remove trailing ".0"
|
|
|
519 |
c_list = [country_value]
|
520 |
matched_country = []
|
521 |
for code in c_list:
|
522 |
+
cleaned = clean_country_code(code)
|
523 |
+
if len(cleaned) == 2:
|
524 |
+
resolved_name = get_country_name(cleaned, region_df)
|
525 |
+
if resolved_name.upper() != cleaned.upper():
|
526 |
matched_country.append(resolved_name)
|
527 |
crs_key = metadata.get("crs_key", "").strip()
|
528 |
# Convert to string and remove trailing ".0"
|