Skip to content

Commit 54174f6

Browse files
authored
Merge pull request #212 from ExpDev07/log_unknown_country_codes
Logs when using default country_code was picked
2 parents 9c9d045 + b9b22e8 commit 54174f6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

app/utils/countrycodes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import logging
12
from itertools import chain
23

4+
LOGGER = logging.getLogger(__name__)
5+
36
# Default country code.
47
default_code = "XX"
58

@@ -374,4 +377,11 @@ def country_code(country):
374377
country = synonyms[country]
375378

376379
# Get country or fallback to default_code.
377-
return is_3166_1.get(country, default_code)
380+
country_code = is_3166_1.get(country, default_code)
381+
382+
# Default picked?
383+
if country_code == default_code:
384+
LOGGER.warning(f"No country_code found for '{country}'. Using '{country_code}'!")
385+
386+
# Return.
387+
return country_code

app/utils/populations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from io import BytesIO, StringIO
23
from zipfile import ZipFile, ZipInfo
34

@@ -6,6 +7,7 @@
67

78
from .countrycodes import country_code
89

10+
LOGGER = logging.getLogger(__name__)
911

1012
# Fetching of the populations.
1113
def fetch_populations():
@@ -15,7 +17,7 @@ def fetch_populations():
1517
:returns: The mapping of populations.
1618
:rtype: dict
1719
"""
18-
print("Fetching populations...")
20+
LOGGER.info("Fetching populations...")
1921

2022
# Mapping of populations
2123
mappings = {}

0 commit comments

Comments
 (0)