Skip to content
Snippets Groups Projects

Helper for ListCorpusEntities

Merged Thibault Lavigne requested to merge helper-for-list-corpus-entities into master
All threads resolved!
3 files
+ 32
109
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -8,7 +8,7 @@ from peewee import IntegrityError
from arkindex_worker import logger
from arkindex_worker.cache import CachedElement, CachedEntity, CachedTranscriptionEntity
from arkindex_worker.models import Corpus, Element, Transcription
from arkindex_worker.models import Element, Transcription
class EntityType(Enum):
@@ -196,39 +196,25 @@ class EntityMixin(object):
def list_corpus_entities(
self,
corpus: Corpus,
name: str = None,
parent: str or Element = None,
parent: Element = None,
):
"""
List all entities in a corpus
This method does not support cache
:param corpus Corpus: The corpus that contains the entities to list.
:param name str: For filter entities by part of their name (case-insensitive)
:param parent str: uuid for restrict entities to those linked to all transcriptions of an element and all its descendants. Note that links to metadata are ignored.
"""
query_params = {}
assert corpus and isinstance(
corpus, Corpus
), "corpus shouldn't be null and should be a Corpus"
if name is not None:
assert name and isinstance(name, str), "name should be of type str"
query_params["name"] = name
if parent is not None:
assert (
parent
and isinstance(parent, str)
or parent
and isinstance(parent, Element)
), "parent should be of type str or Element"
query_params["parent"] = parent
if type(parent) == Element:
query_params["parent"] = parent.id
assert isinstance(parent, Element), "parent should be of type Element"
query_params["parent"] = parent.id
return self.api_client.paginate(
"ListCorpusEntities", id=corpus.id, **query_params
"ListCorpusEntities", id=self.corpus_id, **query_params
)
Loading