animedex.agg._type_routes

Entity type routing for aggregate search/show.

ENTITY_TYPES

animedex.agg._type_routes.ENTITY_TYPES = ('anime', 'manga', 'character', 'person', 'studio', 'publisher')

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

SearchRoute

class animedex.agg._type_routes.SearchRoute(backend: str, function_name: str, query_arg: str = 'q', limit_arg: str | None = None, all_items: bool = False)[source]

Bases: object

One backend search route for an entity type.

backend: str
function_name: str
query_arg: str = 'q'
limit_arg: str | None = None
all_items: bool = False

ShowRoute

class animedex.agg._type_routes.ShowRoute(backend: str, function_name: str, id_arg: str)[source]

Bases: object

One backend show route for an entity type.

backend: str
function_name: str
id_arg: str

validate_entity_type

animedex.agg._type_routes.validate_entity_type(entity_type: str) str[source]

Validate and normalise an entity type.

Parameters:

entity_type (str) – User-supplied entity type.

Returns:

Normalised type.

Return type:

str

Raises:

ApiError – When the type is unknown.

search_routes_for

animedex.agg._type_routes.search_routes_for(entity_type: str) tuple[SearchRoute, ...][source]

Return search routes for entity_type.

Parameters:

entity_type (str) – Normalised entity type.

Returns:

Search routes.

Return type:

tuple[SearchRoute, …]

show_route_for

animedex.agg._type_routes.show_route_for(entity_type: str, backend: str) ShowRoute[source]

Return show route for an entity type/backend pair.

Parameters:
  • entity_type (str) – Entity type.

  • backend (str) – Backend name.

Returns:

Show route.

Return type:

ShowRoute

Raises:

ApiError – When the pair is unsupported.

backends_for_type

animedex.agg._type_routes.backends_for_type(entity_type: str) Iterable[str][source]

Return default fan-out backends for entity_type.

Parameters:

entity_type (str) – Entity type.

Returns:

Backend names in fan-out order.

Return type:

iterable[str]

import_backend

animedex.agg._type_routes.import_backend(backend: str)[source]

Import a backend module by short name.

Parameters:

backend (str) – Backend name.

Returns:

Imported module.

Return type:

module

call_search_route

animedex.agg._type_routes.call_search_route(route: SearchRoute, query: str, limit: int, *, config: Config | None = None, **kw)[source]

Call a search route.

Parameters:
  • route (SearchRoute) – Search route.

  • query (str) – Search query.

  • limit (int) – Per-source limit.

  • config (Config or None) – Optional config.

Returns:

Backend result list.

Return type:

list

call_show_route

animedex.agg._type_routes.call_show_route(route: ShowRoute, raw_id: str, *, config: Config | None = None, **kw)[source]

Call a show route.

Parameters:
  • route (ShowRoute) – Show route.

  • raw_id (str) – Backend-native ID string.

  • config (Config or None) – Optional config.

Returns:

Backend result.

Return type:

object

selftest

animedex.agg._type_routes.selftest() bool[source]

Smoke-test entity type routing.

Returns:

True on success.

Return type:

bool