Skip to content

Commit

Permalink
refactor: make oap_set.py easier (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Oct 23, 2023
1 parent 871821f commit 7ec450a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions dsp_permissions_scripts/oap/oap_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
logger = get_logger(__name__)


def _get_value_iris(resource: dict[str, Any]) -> list[ValueUpdate]:
def _get_values_to_update(resource: dict[str, Any]) -> list[ValueUpdate]:
"""Returns a list of values that have permissions and hence should be updated."""
res: list[ValueUpdate] = []
for k, v in resource.items():
Expand Down Expand Up @@ -142,15 +142,12 @@ def _update_permissions_for_resource_and_values(
) -> None:
"""Updates the permissions for the given resource and its values on a DSP server"""
resource = _get_resource(resource_iri, host, token)
lmd: str | None = resource.get("knora-api:lastModificationDate")
resource_type: str = resource["@type"]
context: dict[str, str] = resource["@context"]
values = _get_value_iris(resource)
values = _get_values_to_update(resource)
_update_permissions_for_resource(
resource_iri=resource_iri,
lmd=lmd,
resource_type=resource_type,
context=context,
lmd=resource.get("knora-api:lastModificationDate"),
resource_type=resource["@type"],
context=resource["@context"],
scope=scope,
host=host,
token=token,
Expand All @@ -159,8 +156,8 @@ def _update_permissions_for_resource_and_values(
_update_permissions_for_value(
resource_iri=resource_iri,
value=v,
resource_type=resource_type,
context=context,
resource_type=resource["@type"],
context=resource["@context"],
scope=scope,
host=host,
token=token,
Expand Down

0 comments on commit 7ec450a

Please sign in to comment.