Skip to content

Commit

Permalink
Merge pull request #155 from fvaleye/fix/country-code-lower-case-second
Browse files Browse the repository at this point in the history
Fix the country code for EU file when launching Tracarbon
  • Loading branch information
fvaleye authored Mar 22, 2023
2 parents 7697239 + 690e36f commit 1049e44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "tracarbon"
authors = ["Florian Valeye <[email protected]>"]
version = "0.6.1"
version = "0.6.2"
description = "Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions."
readme = "README.md"
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions tracarbon/locations/country.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def from_eu_file(cls, country_code_alpha_iso_2: str) -> "Country":
with open(str(resource)) as json_file:
countries_values = ujson.load(json_file)["countries"]
for country in countries_values:
if country_code_alpha_iso_2 == country["name"]:
if country_code_alpha_iso_2.lower() == country["name"]:
return cls.parse_obj(country)
raise CountryIsMissing(
f"The country [{country_code_alpha_iso_2}] is not in the co2 emission file."
Expand All @@ -56,7 +56,7 @@ def get_current_country(
logger.debug(f"Send request to this url: {url}, timeout {timeout}s")
text = requests.get(url, timeout=timeout).text
content_json = ujson.loads(text)
return content_json["country"].lower()
return content_json["country"]
except Exception as exception:
logger.error(f"Failed to request this url: {url}")
raise exception
Expand Down

0 comments on commit 1049e44

Please sign in to comment.