Coverage for heritrace/utils/uri_utils.py: 100%
6 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-10-13 17:12 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-10-13 17:12 +0000
1from flask import current_app
2from rdflib import URIRef
5def generate_unique_uri(entity_type: URIRef | str = None, context_data: dict = None) -> URIRef:
6 """
7 Generate a unique URI for a given entity type using the application's URI generator.
8 The counter increment is handled internally by the URI generator.
10 Args:
11 entity_type: The type of entity to generate a URI for
12 context_data: Additional context data for special URI generation (e.g., Citation entities)
14 Returns:
15 URIRef: The generated unique URI
16 """
17 entity_type = str(entity_type)
18 uri = current_app.config["URI_GENERATOR"].generate_uri(entity_type, context_data)
19 return URIRef(uri)