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

1# SPDX-FileCopyrightText: 2025 Arcangelo Massari <arcangelo.massari@unibo.it> 

2# 

3# SPDX-License-Identifier: ISC 

4 

5from flask import current_app 

6from rdflib import URIRef 

7 

8 

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. 

13 

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) 

17 

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)