Skip to content

Commit

Permalink
Find country code from adminlevel
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-mills committed Mar 22, 2024
1 parent 95d4f4a commit 2d218d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/hapi/pipelines/app/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def output(self):
session=self.session,
metadata=self.metadata,
admins=self.admins,
adminone=self.adminone,
admintwo=self.admintwo,
org=self.org,
org_type=self.org_type,
sector=self.sector,
Expand Down
17 changes: 15 additions & 2 deletions src/hapi/pipelines/database/operational_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Dict

from hapi_schema.db_operational_presence import DBOperationalPresence
from hdx.location.adminlevel import AdminLevel
from hdx.location.names import clean_name
from hdx.utilities.dateparse import parse_date
from hdx.utilities.dictandlist import write_list_to_csv
Expand All @@ -26,6 +27,8 @@ def __init__(
session: Session,
metadata: Metadata,
admins: admins.Admins,
adminone: AdminLevel,
admintwo: AdminLevel,
org: Org,
org_type: OrgType,
sector: Sector,
Expand All @@ -34,6 +37,8 @@ def __init__(
super().__init__(session)
self._metadata = metadata
self._admins = admins
self._adminone = adminone
self._admintwo = admintwo
self._org = org
self._org_type = org_type
self._sector = sector
Expand Down Expand Up @@ -85,9 +90,17 @@ def populate(self, debug=False):
org_type_orig = values[org_type_name_index][
admin_code
][i]
# TODO: find the country code for get_org_info parameter "location"
country_code = None
if admin_level == "admintwo":
country_code = self._admintwo.pcode_to_iso3.get(
admin_code
)
if admin_level == "adminone":
country_code = self._admintwo.pcode_to_iso3.get(
admin_code
)
org_info = self._org.get_org_info(
org_name_orig, location="Country code"
org_name_orig, location=country_code
)
self._org.add_org_to_lookup(
org_name_orig, org_info.get("#org+name")
Expand Down

0 comments on commit 2d218d7

Please sign in to comment.