From 7c990b148130acecbd14c708fa8179decbad510e Mon Sep 17 00:00:00 2001 From: Friedrich Lindenberg Date: Mon, 10 Jul 2023 16:05:05 +0200 Subject: [PATCH] don't match companies that have an OC ID already --- nomenklatura/enrich/opencorporates.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/nomenklatura/enrich/opencorporates.py b/nomenklatura/enrich/opencorporates.py index bc4a5553..92e130f6 100644 --- a/nomenklatura/enrich/opencorporates.py +++ b/nomenklatura/enrich/opencorporates.py @@ -68,6 +68,9 @@ def oc_get_cached(self, url: str, params: ParamsType = None) -> Optional[Any]: def match(self, entity: CE) -> Generator[CE, None, None]: if not entity.schema.matchable: return + if entity.has("opencorporatesUrl"): + # TODO: fetch entity here when we start to expand with content! + return if entity.schema.name in ["Company", "Organization", "LegalEntity"]: yield from self.search_companies(entity) @@ -81,6 +84,15 @@ def expand(self, entity: CE, match: CE) -> Generator[CE, None, None]: clone.add("opencorporatesUrl", match.get("opencorporatesUrl")) yield clone + # def expand_entity(self, entity): + # for url in entity.get("opencorporatesUrl", quiet=True): + # url = self.make_url(url) + # data = self.get_api(url).get("results", {}) + # if "company" in data: + # yield from self.expand_company(entity, data) + # if "officer" in data: + # yield from self.expand_officer(data, officer=entity) + def make_entity_id(self, url: str) -> str: parsed = urlparse(url) path = slugify(parsed.path, sep="-") @@ -213,12 +225,3 @@ def search_companies(self, entity: CE) -> Generator[CE, None, None]: # directorship.add("organization", company) # directorship.add("role", data.get("position")) # yield directorship - - # def expand_entity(self, entity): - # for url in entity.get("opencorporatesUrl", quiet=True): - # url = self.make_url(url) - # data = self.get_api(url).get("results", {}) - # if "company" in data: - # yield from self.expand_company(entity, data) - # if "officer" in data: - # yield from self.expand_officer(data, officer=entity)