Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/utils/countrycodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging
from itertools import chain

LOGGER = logging.getLogger(__name__)

# Default country code.
default_code = "XX"

Expand Down Expand Up @@ -374,4 +377,11 @@ def country_code(country):
country = synonyms[country]

# Get country or fallback to default_code.
return is_3166_1.get(country, default_code)
country_code = is_3166_1.get(country, default_code)

# Default picked?
if country_code == default_code:
LOGGER.warning(f"No country_code found for '{country}'. Using '{country_code}'!")

# Return.
return country_code
4 changes: 3 additions & 1 deletion app/utils/populations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from io import BytesIO, StringIO
from zipfile import ZipFile, ZipInfo

Expand All @@ -6,6 +7,7 @@

from .countrycodes import country_code

LOGGER = logging.getLogger(__name__)

# Fetching of the populations.
def fetch_populations():
Expand All @@ -15,7 +17,7 @@ def fetch_populations():
:returns: The mapping of populations.
:rtype: dict
"""
print("Fetching populations...")
LOGGER.info("Fetching populations...")

# Mapping of populations
mappings = {}
Expand Down