Action links for OAI-PMH Harvester.
Normally contains a "harvest" link, but can be extended by other links.
Modelled after invenio links.
Source code in oarepo_oaipmh_harvester/links.py
| class ActionLinks:
"""Action links for OAI-PMH Harvester.
Normally contains a "harvest" link, but can be extended by other links.
Modelled after invenio links.
"""
def __init__(self, actions_links: dict[str, Any]):
"""Initialize the ActionLinks."""
self._actions_links = actions_links
def should_render(self, obj: Any, ctx: Any) -> bool: # noqa ARG002 params kept for overriding
"""Determine if the link should be rendered."""
return True
@staticmethod
def vars(obj: Any, _vars: Any) -> None:
"""Overwrite this method in subclasses."""
def expand(self, obj: Any, context: Any) -> dict[str, Any]:
"""Expand the URI Template."""
ret = {}
for action, link in self._actions_links.items():
if link.should_render(obj, context):
ret[action] = link.expand(obj, context)
return ret
|
__init__(actions_links: dict[str, Any])
Initialize the ActionLinks.
Source code in oarepo_oaipmh_harvester/links.py
| def __init__(self, actions_links: dict[str, Any]):
"""Initialize the ActionLinks."""
self._actions_links = actions_links
|
should_render(obj: Any, ctx: Any) -> bool
Determine if the link should be rendered.
Source code in oarepo_oaipmh_harvester/links.py
| def should_render(self, obj: Any, ctx: Any) -> bool: # noqa ARG002 params kept for overriding
"""Determine if the link should be rendered."""
return True
|
vars(obj: Any, _vars: Any) -> None
staticmethod
Overwrite this method in subclasses.
Source code in oarepo_oaipmh_harvester/links.py
| @staticmethod
def vars(obj: Any, _vars: Any) -> None:
"""Overwrite this method in subclasses."""
|
expand(obj: Any, context: Any) -> dict[str, Any]
Expand the URI Template.
Source code in oarepo_oaipmh_harvester/links.py
| def expand(self, obj: Any, context: Any) -> dict[str, Any]:
"""Expand the URI Template."""
ret = {}
for action, link in self._actions_links.items():
if link.should_render(obj, context):
ret[action] = link.expand(obj, context)
return ret
|