Exemple #1
0
def get_manifest_label(label_uuid, manifest):
    """ Retrieves the manifest label on the manifest with the given UUID or None if none. """
    try:
        return (Label.select(
            Label, LabelSourceType).join(LabelSourceType).where(
                Label.uuid == label_uuid).switch(Label).join(ManifestLabel).
                where(ManifestLabel.manifest == manifest).get())
    except Label.DoesNotExist:
        return None
Exemple #2
0
def get_manifest_label(label_uuid, tag_manifest):
    """ Retrieves the manifest label on the tag manifest with the given ID. """
    try:
        return (Label.select(
            Label, LabelSourceType).join(LabelSourceType).where(
                Label.uuid == label_uuid).switch(Label).join(TagManifestLabel).
                where(TagManifestLabel.annotated == tag_manifest).get())
    except Label.DoesNotExist:
        return None
Exemple #3
0
def list_manifest_labels(manifest_id, prefix_filter=None):
    """ Lists all labels found on the given manifest, with an optional filter by key prefix. """
    query = (Label.select(Label, MediaType).join(MediaType).switch(Label).join(
        LabelSourceType).switch(Label).join(ManifestLabel).where(
            ManifestLabel.manifest == manifest_id))

    if prefix_filter is not None:
        query = query.where(prefix_search(Label.key, prefix_filter))

    return query
Exemple #4
0
def list_manifest_labels(tag_manifest, prefix_filter=None):
    """ Lists all labels found on the given tag manifest. """
    query = (Label.select(Label, MediaType).join(MediaType).switch(Label).join(
        LabelSourceType).switch(Label).join(TagManifestLabel).where(
            TagManifestLabel.annotated == tag_manifest))

    if prefix_filter is not None:
        query = query.where(prefix_search(Label.key, prefix_filter))

    return query
Exemple #5
0
def _get_dangling_labels():
    label_ids = set([current.id for current in Label.select()])
    referenced_by_manifest = set(
        [mlabel.label_id for mlabel in ManifestLabel.select()])
    return label_ids - referenced_by_manifest