Coverage for heritrace/uri_generator/uri_generator.py: 100%

1 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-10-13 17:12 +0000

1from abc import ABC, abstractmethod 

2 

3 

4class URIGenerator(ABC): # pragma: no cover 

5 """ 

6 Abstract base class for URI generators. 

7 """ 

8 

9 @abstractmethod 

10 def generate_uri(self, entity_type: str | None = None, context_data: dict = None) -> str: 

11 """ 

12 Generate a new URI for an entity of the given type. 

13 

14 :param entity_type: The type of entity to generate a URI for 

15 :type entity_type: str 

16 :param context_data: Additional context data for special URI generation. 

17 Expected structure: 

18 { 

19 "entity_type": "http://purl.org/spar/cito/Citation", 

20 "properties": { 

21 "http://purl.org/spar/cito/hasCitingEntity": [ 

22 { 

23 "is_existing_entity": True, 

24 "entity_uri": "https://w3id.org/oc/meta/br/061503302037" 

25 } 

26 ], 

27 "http://purl.org/spar/cito/hasCitedEntity": [ 

28 { 

29 "is_existing_entity": True, 

30 "entity_uri": "https://w3id.org/oc/meta/br/061503302004" 

31 } 

32 ] 

33 } 

34 } 

35 :type context_data: dict 

36 :return: The generated URI 

37 :rtype: str 

38 """ 

39 pass 

40 

41 @abstractmethod 

42 def initialize_counters(self, sparql) -> None: 

43 """ 

44 Initialize counters for entity types supported by this URI generator. 

45 

46 :param sparql: SPARQLWrapper instance to execute queries on the dataset 

47 :return: None 

48 """ 

49 pass