Source code for edri.api.extensions.url_prefix
from abc import ABC, abstractmethod
__all__ = ["PrefixBase"]
[docs]
class PrefixBase(ABC):
[docs]
@staticmethod
@abstractmethod
def url_prefix() -> str:
"""Common prefix URL."""
pass
[docs]
@classmethod
def resource_prefix(cls) -> str:
"""Common prefix for resource."""
url_prefix = cls.url_prefix()
if url_prefix.startswith('/'):
return url_prefix[1:] + "-"
else:
raise NotImplementedError("Resource prefix cannot be taken from url_prefix")