Skip to content

Commit

Permalink
don't match companies that have an OC ID already
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Jul 10, 2023
1 parent 01d69ad commit 7c990b1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions nomenklatura/enrich/opencorporates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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="-")
Expand Down Expand Up @@ -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)

0 comments on commit 7c990b1

Please sign in to comment.