Skip to content

Commit

Permalink
fynamic supplier_prefix bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
arcangelo7 committed Mar 18, 2024
1 parent 8c229bf commit d29baf3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion oc_ocdm/counter_handler/filesystem_counter_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ def increment_counter(self, entity_short_name: str, prov_short_name: str = "", i
return self._add_number(file_path, identifier)

def _get_info_path(self, short_name: str, supplier_prefix: str) -> str:
supplier_prefix = "" if supplier_prefix is None else supplier_prefix
directory = self.info_dir if supplier_prefix == self.supplier_prefix else self.info_dir.replace(self.supplier_prefix, supplier_prefix, 1)
return directory + self.info_files[short_name]

def _get_prov_path(self, short_name: str, supplier_prefix: str) -> str:
supplier_prefix = "" if supplier_prefix is None else supplier_prefix
directory = self.info_dir if supplier_prefix == self.supplier_prefix else self.info_dir.replace(self.supplier_prefix, supplier_prefix, 1)
return directory + self.prov_files[short_name]

Expand Down Expand Up @@ -346,4 +348,4 @@ def increment_metadata_counter(self, entity_short_name: str, dataset_name: str)
raise ValueError("entity_short_name is not a known metadata short name!")

file_path: str = self._get_metadata_path(entity_short_name, dataset_name)
return self._add_number(file_path, 1)
return self._add_number(file_path, 1)
9 changes: 5 additions & 4 deletions oc_ocdm/prov/prov_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,17 @@ def _add_prov(self, graph_url: str, short_name: str, prov_subject: GraphEntity,
except ValueError:
res_count: int = -1
if isinstance(self.counter_handlers[prov_subject.short_name], SqliteCounterHandler):
cur_count: str = self.counter_handlers[prov_subject.short_name].read_counter(prov_subject, supplier_prefix=supplier_prefix)
cur_count: str = self.counter_handlers[prov_subject.short_name].read_counter(prov_subject)
else:
cur_count: str = self.counter_handlers[prov_subject.short_name].read_counter(prov_subject.short_name, "se", int(get_count(prov_subject.res)), supplier_prefix=supplier_prefix)
if res_count > cur_count:
if isinstance(self.counter_handlers[prov_subject.short_name], SqliteCounterHandler):
self.counter_handlers[prov_subject.short_name].set_counter(int(get_count(prov_subject.res)), prov_subject, supplier_prefix=supplier_prefix)
self.counter_handlers[prov_subject.short_name].set_counter(int(get_count(prov_subject.res)), prov_subject)
else:
self.counter_handlers[prov_subject.short_name].set_counter(res_count, prov_subject.short_name, "se", int(get_count(prov_subject.res)), supplier_prefix=supplier_prefix)
return cur_g, count, label
if isinstance(self.counter_handlers[prov_subject.short_name], SqliteCounterHandler):
count = str(self.counter_handlers[prov_subject.short_name].increment_counter(prov_subject, supplier_prefix=supplier_prefix))
count = str(self.counter_handlers[prov_subject.short_name].increment_counter(prov_subject))
else:
count = str(self.counter_handlers[prov_subject.short_name].increment_counter(prov_subject.short_name, "se", int(get_count(prov_subject.res)), supplier_prefix=supplier_prefix))
if self.wanted_label:
Expand Down Expand Up @@ -289,7 +289,8 @@ def _retrieve_last_snapshot(self, prov_subject: URIRef) -> Optional[URIRef]:
if isinstance(self.counter_handlers[subj_short_name], SqliteCounterHandler):
last_snapshot_count: str = str(self.counter_handlers[subj_short_name].read_counter(prov_subject))
else:
last_snapshot_count: str = str(self.counter_handlers[subj_short_name].read_counter(subj_short_name, "se", int(subj_count)))
supplier_prefix = get_prefix(str(prov_subject))
last_snapshot_count: str = str(self.counter_handlers[subj_short_name].read_counter(subj_short_name, "se", int(subj_count), supplier_prefix=supplier_prefix))
if int(last_snapshot_count) <= 0:
return None
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "oc_ocdm"
version = "7.3.2"
version = "7.3.4"
description = "Object mapping library for manipulating RDF graphs that are compliant with the OpenCitations datamodel."
authors = [
"Silvio Peroni <essepuntato@gmail.com>",
Expand Down

0 comments on commit d29baf3

Please sign in to comment.