Coverage for heritrace / utils / uri_utils.py: 100%
6 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-21 12:56 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-21 12:56 +0000
1# SPDX-FileCopyrightText: 2025 Arcangelo Massari <arcangelo.massari@unibo.it>
2#
3# SPDX-License-Identifier: ISC
5from flask import current_app
6from rdflib import URIRef
9def generate_unique_uri(entity_type: URIRef | str = None, context_data: dict = None) -> URIRef:
10 """
11 Generate a unique URI for a given entity type using the application's URI generator.
12 The counter increment is handled internally by the URI generator.
14 Args:
15 entity_type: The type of entity to generate a URI for
16 context_data: Additional context data for special URI generation (e.g., Citation entities)
18 Returns:
19 URIRef: The generated unique URI
20 """
21 entity_type = str(entity_type)
22 uri = current_app.config["URI_GENERATOR"].generate_uri(entity_type, context_data)
23 return URIRef(uri)