Skip to content

Commit

Permalink
Fix bug in entity.clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Jul 3, 2023
1 parent 1d16af6 commit 6255167
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions nomenklatura/enrich/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,23 @@ def http_post_json_cached(
self.cache.set_json(cache_key, resp_data)
return resp_data

def _make_data_entity(self, entity: CE, data, cleaned: bool = True) -> CE:
return type(entity).from_dict(
model,
data,
default_dataset=self.dataset.name,
cleaned=cleaned,
)

def load_entity(self, entity: CE, data: Dict[str, Any]) -> CE:
proxy = type(entity).from_dict(model, data, cleaned=False)
proxy = self._make_data_entity(entity, data, cleaned=False)
for prop in proxy.iterprops():
if prop.stub:
proxy.pop(prop)
return proxy

def make_entity(self, entity: CE, schema: str) -> CE:
data = {"schema": schema}
return type(entity).from_dict(model, data)
return self._make_data_entity(entity, {"schema": schema})

def match_wrapped(self, entity: CE) -> Generator[CE, None, None]:
if len(self.schemata) and entity.schema.name not in self.schemata:
Expand Down
6 changes: 5 additions & 1 deletion nomenklatura/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,11 @@ def iterprops(self) -> List[Property]:

def clone(self: CE) -> CE:
data = {"schema": self.schema.name, "id": self.id}
cloned = type(self).from_dict(self.schema.model, data)
cloned = type(self).from_dict(
self.schema.model,
data,
default_dataset=self.default_dataset,
)
for stmt in self._iter_stmt():
cloned.add_statement(stmt)
return cloned
Expand Down

0 comments on commit 6255167

Please sign in to comment.