Coverage for lode / models / property.py: 96%

46 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-10-05 16:02 +0000

1from .resource import Resource 

2 

3class Property(Resource): 

4 """Represents an RDF Property""" 

5 

6 def __init__(self, **kwargs): 

7 

8 super().__init__(**kwargs) 

9 

10 # Attributes 

11 self.is_functional = False # bool [1] 

12 

13 # Relations with Properties (0..*) 

14 self.is_sub_property_of = [] 

15 self.is_super_property_of = [] 

16 self.is_disjoint_with = [] 

17 self.is_equivalent_to = [] 

18 

19 # Relation with Resource (1..*)  

20 self.has_range = [] 

21 

22 # Relations with Concept (1..*) 

23 self.has_domain = [] 

24 

25 # Metodi per is_functional 

26 def set_is_functional(self, bool): 

27 """Imposta is_functional""" 

28 self.is_functional = bool 

29 

30 def get_is_functional(self): 

31 """Restituisce is_functional""" 

32 return self.is_functional 

33 

34 # Metodi per is_sub_property_of / is_super_property_of 

35 def set_is_sub_property_of(self, property_obj): 

36 if property_obj not in self.is_sub_property_of: 

37 self.is_sub_property_of.append(property_obj) 

38 inv = getattr(property_obj, 'is_super_property_of', None) 

39 if inv is not None and self not in inv: 

40 inv.append(self) 

41 

42 def get_is_sub_property_of(self): 

43 return list(self.is_sub_property_of) 

44 

45 def set_is_super_property_of(self, property_obj): 

46 if property_obj not in self.is_super_property_of: 

47 self.is_super_property_of.append(property_obj) 

48 

49 def get_is_super_property_of(self): 

50 return list(self.is_super_property_of) 

51 

52 # Metodi per is_disjoint_with 

53 def set_is_disjoint_with(self, property_obj): 

54 """Aggiunge una property a is_disjoint_with""" 

55 self.is_disjoint_with.append(property_obj) 

56 

57 def get_is_disjoint_with(self): 

58 """Restituisce una copia della lista is_disjoint_with""" 

59 return list(set(self.is_disjoint_with)) 

60 

61 def set_is_equivalent_to(self, property_obj): 

62 """Aggiunge una property a is_equivalent_to""" 

63 self.is_equivalent_to.append(property_obj) 

64 

65 def get_is_equivalent_to(self): 

66 """Restituisce una copia della lista is_equivalent_to""" 

67 return list(set(self.is_equivalent_to)) 

68 

69 # Metodi per has_range 

70 def set_has_range(self, resource): 

71 if resource not in self.has_range: 

72 self.has_range.append(resource) 

73 

74 def get_has_range(self): 

75 """Restituisce una copia della lista has_range""" 

76 return list(self.has_range) 

77 

78 def set_has_domain(self, concept): 

79 if concept not in self.has_domain: 

80 self.has_domain.append(concept) 

81 

82 def get_has_domain(self): 

83 """Restituisce una copia della lista has_domain""" 

84 return list(self.has_domain) 

85