Skip to content

Commit

Permalink
Merge branch 'main' into wip/scenario-tanner
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Oct 3, 2023
2 parents 62706cb + 432257d commit 24b7096
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dsp_permissions_scripts/models/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Doap(BaseModel):

target: DoapTarget
scope: PermissionScope
iri: str
doap_iri: str


class DoapTargetType(Enum):
Expand Down
4 changes: 2 additions & 2 deletions dsp_permissions_scripts/utils/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def set_doaps_of_groups(
print("Old DOAP:\n=========")
print(d.model_dump_json(indent=2))
new_doap = update_doap_scope(
doap_iri=d.iri,
doap_iri=d.doap_iri,
scope=scope,
host=host,
token=token,
Expand All @@ -101,7 +101,7 @@ def __get_doap(permission: dict[str, Any]) -> Doap:
property=permission["forProperty"],
),
scope=scope,
iri=permission["iri"],
doap_iri=permission["iri"],
)
return doap

Expand Down
14 changes: 7 additions & 7 deletions dsp_permissions_scripts/utils/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def get_all_resource_iris_of_project(
token: str,
) -> list[str]:
all_resource_iris = []
resclasses = __get_all_resource_class_iris_of_project(
resclass_iris = __get_all_resource_class_iris_of_project(
project_iri=project_iri,
host=host,
token=token,
)
for resclass in resclasses:
for resclass_iri in resclass_iris:
resource_iris = __get_all_resource_iris_of_resclass(
host=host,
resclass=resclass,
resclass_iri=resclass_iri,
project_iri=project_iri,
token=token,
)
Expand Down Expand Up @@ -99,7 +99,7 @@ def __dereference_prefix(identifier: str, context: dict[str, str]) -> str:

def __get_all_resource_iris_of_resclass(
host: str,
resclass: str,
resclass_iri: str,
project_iri: str,
token: str,
) -> list[str]:
Expand All @@ -112,7 +112,7 @@ def __get_all_resource_iris_of_resclass(
more, iris = __get_next_page(
protocol=protocol,
host=host,
resclass=resclass,
resclass_iri=resclass_iri,
page=page,
headers=headers,
)
Expand All @@ -124,7 +124,7 @@ def __get_all_resource_iris_of_resclass(
def __get_next_page(
protocol: str,
host: str,
resclass: str,
resclass_iri: str,
page: int,
headers: dict[str, str],
) -> tuple[bool, list[str]]:
Expand All @@ -137,7 +137,7 @@ def __get_next_page(
and an empty response content with status code 200 if there are no resources remaining.
This means that the page must be incremented until the response contains 0 or 1 resource.
"""
url = f"{protocol}://{host}/v2/resources?resourceClass={quote_plus(resclass)}&page={page}"
url = f"{protocol}://{host}/v2/resources?resourceClass={quote_plus(resclass_iri)}&page={page}"
response = requests.get(url, headers=headers, timeout=5)
assert response.status_code == 200
result = response.json()
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tests/test_scope_serialization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Any
import unittest
from typing import Any

from dsp_permissions_scripts.models.groups import BuiltinGroup
from dsp_permissions_scripts.models.scope import PermissionScope
Expand Down Expand Up @@ -101,9 +101,10 @@ def _resolve_prefixes_of_admin_route_object(self, admin_route_object: list[dict[
"knora-admin:", "http://www.knora.org/ontology/knora-admin#"
)
return admin_route_object

def _resolve_prefixes_of_perm_string(self, perm_string: str) -> str:
return perm_string.replace("knora-admin:", "http://www.knora.org/ontology/knora-admin#")


if __name__ == "__main__":
unittest.main()

0 comments on commit 24b7096

Please sign in to comment.