drepr.utils.misc#

Functions

assert_isinstance(x, cls)

assert_not_null(x)

assert_true(x, msg)

get_abs_iri(prefixes, rel_iri)

get_varname_for_attr(attr_id)

Get variable name for the given attribute id

Classes

assert_not_null(x: Optional[V]) V[source]#
Parameters:

x (Optional[V]) –

Return type:

V

assert_true(x: bool, msg: str) bool[source]#
Parameters:
Return type:

bool

assert_isinstance(x: Any, cls: type[V]) V[source]#
Parameters:
Return type:

V

class CacheMethod[source]#

Bases: object

static single_literal_arg(args, _kwargs)[source]#
static as_is_posargs(args, _kwargs)[source]#
static as_is(args, kwargs)[source]#
static as_json(args, kwargs)[source]#
static selected_args(selection: Sequence[Union[int, str]])[source]#
Parameters:

selection (Sequence[Union[int, str]]) –

static cache(key: Callable[[tuple, dict], Union[tuple, str, bytes, int]], cache_attr: str = '_cache') Callable[[F], F][source]#

Cache instance’s method during its life-time. Note: Order of the arguments is important. Different order of the arguments will result in different cache key.

Parameters:
Return type:

Callable[[F], F]

get_abs_iri(prefixes: dict[str, str], rel_iri: str) str[source]#
Parameters:
Return type:

str

get_varname_for_attr(attr_id: str | int)[source]#

Get variable name for the given attribute id

Parameters:

attr_id (str | int) –