Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasprobst committed Jun 23, 2024
1 parent b1cc9e6 commit 9b0142f
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 39 deletions.
17 changes: 0 additions & 17 deletions docs/userguide/extensions/index.html

This file was deleted.

324 changes: 305 additions & 19 deletions docs/userguide/misc/Extensions.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions h5rdmtoolbox/convention/standard_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class StandardAttribute:
validator: Union[pydantic.BaseModel, typing_extensions._AnnotatedAlias]
The validator for the attribute. If the validator takes a parameter, pass it as dict.
Examples for no-parameter validator: "$pintunits", "$standard_name", "$orcid", "$url"
Examples for validator with parameter: {"$regex": "^[a-z0-9_]*$"}, {"$in": ["a", "b", "c"]}
Examples for validator with parameter: {"$regex": r"^[a-z0-9_]*$"}, {"$in": ["a", "b", "c"]}
description: str
The description of the attribute
target_method: str
Expand Down Expand Up @@ -352,6 +352,6 @@ def validate(self, value, parent=None, attrs=None) -> bool:
try:
_validated_value = self.validator.model_validate({key0: value},
context={'parent': parent, 'attrs': attrs})
except pydantic.ValidationError as err:
except pydantic.ValidationError as _:
return False
return True
5 changes: 4 additions & 1 deletion h5rdmtoolbox/wrapper/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def object(self):

@property
def subject(self) -> Optional[str]:
"""Return the RDF subject, which is the @ID in JSON-LD syntax"""
"""Return the RDF subject (a URL), which is equivalent to the @ID in JSON-LD syntax"""
if RDF_SUBJECT_ATTR_NAME not in self._attr:
return
return self._attr[RDF_SUBJECT_ATTR_NAME]
Expand All @@ -487,11 +487,14 @@ def subject(self):
@subject.setter
def subject(self, jsonld_id: Union[str, HttpUrl]):
"""Set the RDF subject, which is the @ID in JSON-LD syntax.
Hence a valdi URL is required. This is validated by pydantic!
Raises
------
TypeError
If the subject is not a string or URL
RDFError
If the URL is invalid
"""
if not isinstance(jsonld_id, str):
raise TypeError(f'Expecting a string or URL. Got {type(jsonld_id)}. Note, that a subject '
Expand Down

0 comments on commit 9b0142f

Please sign in to comment.