Skip to content
Snippets Groups Projects

Helper for ListTranscriptionEntities

Merged Thibault Lavigne requested to merge helper-for-list-transcription-entities into master
All threads resolved!
2 files
+ 51
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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):
@@ -174,3 +174,35 @@ class EntityMixin(object):
f"Couldn't save created transcription entity in local cache: {e}"
)
return transcription_ent
def list_transcription_entities(
self,
transcription: Transcription,
worker_version: bool = None,
):
"""
List existing entities on a transcription
This method does not support cache
:param transcription Transcription: The transcription to list entities on.
: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.
"""
query_params = {}
assert transcription and isinstance(
transcription, Transcription
), "transcription shouldn't be null and should be a Transcription"
if worker_version is not None:
assert isinstance(
worker_version, (str, bool)
), "worker_version should be of type str or bool"
if isinstance(worker_version, bool):
assert (
worker_version is False
), "if of type bool, worker_version can only be set to False"
query_params["worker_version"] = worker_version
return self.api_client.paginate(
"ListTranscriptionEntities", id=transcription.id, **query_params
)
Loading