Skip to content

Commit 1049e44

Browse files
authored
Merge pull request #155 from fvaleye/fix/country-code-lower-case-second
Fix the country code for EU file when launching Tracarbon
2 parents 7697239 + 690e36f commit 1049e44

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
name = "tracarbon"
33
authors = ["Florian Valeye <[email protected]>"]
4-
version = "0.6.1"
4+
version = "0.6.2"
55
description = "Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions."
66
readme = "README.md"
77
license = "Apache-2.0"

tracarbon/locations/country.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def from_eu_file(cls, country_code_alpha_iso_2: str) -> "Country":
3535
with open(str(resource)) as json_file:
3636
countries_values = ujson.load(json_file)["countries"]
3737
for country in countries_values:
38-
if country_code_alpha_iso_2 == country["name"]:
38+
if country_code_alpha_iso_2.lower() == country["name"]:
3939
return cls.parse_obj(country)
4040
raise CountryIsMissing(
4141
f"The country [{country_code_alpha_iso_2}] is not in the co2 emission file."
@@ -56,7 +56,7 @@ def get_current_country(
5656
logger.debug(f"Send request to this url: {url}, timeout {timeout}s")
5757
text = requests.get(url, timeout=timeout).text
5858
content_json = ujson.loads(text)
59-
return content_json["country"].lower()
59+
return content_json["country"]
6060
except Exception as exception:
6161
logger.error(f"Failed to request this url: {url}")
6262
raise exception

0 commit comments

Comments
 (0)