Skip to content
Snippets Groups Projects

Helper for ListTranscriptionEntities

Merged Thibault Lavigne requested to merge helper-for-list-transcription-entities into master
1 file
+ 12
29
Compare changes
  • Side-by-side
  • Inline
@@ -10,7 +10,7 @@ from peewee import IntegrityError
from arkindex_worker import logger
from arkindex_worker.cache import CachedElement, CachedEntity, CachedTranscriptionEntity
from arkindex_worker.models import Element
from arkindex_worker.models import Element, Transcription
class EntityType(Enum):
@@ -177,36 +177,20 @@ class EntityMixin(object):
def list_transcription_entities(
self,
transcription: str,
page: int = None,
page_size: int = None,
worker_version=None,
transcription: Transcription,
worker_version: bool = None,
):
"""
List transcriptions on entities
This method not work with the cache
List existing entities on a transcription
This method does not support cache
:param transcription str: UUID of the existing transcription.
:param page int: A page number within the paginated result set.
:param page_size int: Number of results to return per page.
:param transcription Transcription: UUID of the existing transcription.
:param worker_version str or bool: Restrict to entities created by a worker version with this UUID. Set to False to look for manually created transcriptions.
"""
params = {}
query_params = {}
assert transcription and isinstance(
transcription, str
), "transcription shouldn't be null and should be of type str"
if page is not None:
assert page and isinstance(
page, int
), "page shouldn't be null and should be of type integer"
params[page] = page
if page_size is not None:
assert page_size and isinstance(
page_size, int
), "page_size shouldn't be null and should be of type integer"
params[page_size] = page_size
transcription, Transcription
), "transcription shouldn't be null and should be an instance of class Transcription"
if worker_version is not None:
assert isinstance(
@@ -217,9 +201,8 @@ class EntityMixin(object):
assert (
worker_version is False
), "if of type bool, worker_version can only be set to False"
params["worker_version"] = self.worker_version_id
query_params["worker_version"] = self.worker_version_id
transcription_ent = self.api_client.paginate(
"ListTranscriptionEntities", id=transcription, **params
return self.api_client.paginate(
"ListTranscriptionEntities", id=transcription, **query_params
)
return transcription_ent
Loading