Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge lawson/label_predicates into maintenance-v3 #273

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions prez/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from os import environ
from pathlib import Path
from typing import Optional, Union, Any, Dict
from typing import Any, Dict, Optional, Union

import toml
from pydantic import BaseSettings, root_validator
from rdflib import URIRef, DCTERMS, RDFS, SDO
from rdflib import DCTERMS, RDFS, SDO, URIRef
from rdflib.namespace import SKOS

from prez.reference_data.prez_ns import REG
Expand Down Expand Up @@ -43,7 +43,12 @@ class Settings(BaseSettings):
order_lists_by_label: bool = True
base_classes: Optional[dict]
prez_flavours: Optional[list] = ["SpacePrez", "VocPrez", "CatPrez", "ProfilesPrez"]
label_predicates = [SKOS.prefLabel, DCTERMS.title, RDFS.label, SDO.name]
label_predicates: list[URIRef] = [
SKOS.prefLabel,
DCTERMS.title,
RDFS.label,
SDO.name,
]
description_predicates = [SKOS.definition, DCTERMS.description, SDO.description]
provenance_predicates = [DCTERMS.provenance]
other_predicates = [SDO.color, REG.status]
Expand Down Expand Up @@ -97,5 +102,20 @@ def set_system_uri(cls, values):
)
return values

@root_validator()
def get_label_predicates(cls, values):
try:
label_predicates = [
URIRef(label_predicate)
for label_predicate in values["label_predicates"]
]
except ValueError as e:
raise ValueError(
"Could not parse label_predicates. label predicates must be valid URIs no prefixes allowed "
f"original message: {e}"
)
values["label_predicates"] = label_predicates
return values


settings = Settings()
Loading