Skip to content

Actions

build_iiif_resource(identifier) ΒΆ

Given a IIIF resource identifier, build the resource from the first matching builder in the BUILDERS list and then return the result. If no builder can be matched then None is returned.

Parameters:

Name Type Description Default
identifier str

the IIIF resource identifier

required

Returns:

Type Description
Optional[dict]

a dict or None

Source code in ckanext/iiif/logic/actions.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@action(build_iiif_resource_schema, build_iiif_resource_help, toolkit.side_effect_free)
def build_iiif_resource(identifier: str) -> Optional[dict]:
    """
    Given a IIIF resource identifier, build the resource from the first matching builder
    in the BUILDERS list and then return the result. If no builder can be matched then
    None is returned.

    :param identifier: the IIIF resource identifier
    :returns: a dict or None
    """
    for builder in BUILDERS.values():
        try:
            result = builder.match_and_build(identifier)
            if result is not None:
                return result
        except IIIFBuildError as e:
            log.error(str(e), exc_info=e)
            break
    return None