Merge remote-tracking branch 'origin/master' into development

# Conflicts:
#	api/od.py
This commit is contained in:
Inte Vleminckx 2025-06-03 16:25:24 +02:00
commit 9475b1fdc5
38 changed files with 1028 additions and 15 deletions

View file

@ -53,7 +53,7 @@ class CDAPI:
return self.bottom.read_outgoing_elements(self.m, type_name)[0]
def is_direct_subtype(self, super_type_name: str, sub_type_name: str):
return sub_type_name in self.direct_sub_types[super_type]
return sub_type_name in self.direct_sub_types[super_type_name]
def is_direct_supertype(self, sub_type_name: str, super_type_name: str):
return super_type_name in self.direct_super_types[sub_type_name]
@ -83,3 +83,6 @@ class CDAPI:
result = self.find_attribute_type(supertype, attr_name)
if result != None:
return result
def get_type(self, type_name: str):
return next(k for k, v in self.type_model_names.items() if v == type_name)

View file

@ -146,7 +146,7 @@ class ODAPI:
typ = self.cdapi.get_type(type_name)
types = set(typ) if not include_subtypes else self.cdapi.transitive_sub_types[type_name]
for type_of_obj in self.bottom.read_outgoing_elements(obj, "Morphism"):
if type_of_obj in types:
if self.get_name(type_of_obj) in types:
return True
return False
@ -154,10 +154,9 @@ class ODAPI:
self.bottom.delete_element(obj)
self.__recompute_mappings()
# Does the class of the object have the given attribute?
# Does the the object have the given attribute?
def has_slot(self, obj: UUID, attr_name: str):
class_name = self.get_name(self.get_type(obj))
return self.od.get_attr_link_name(class_name, attr_name) != None
return self.od.get_slot_link(obj, attr_name) != None
def get_slots(self, obj: UUID) -> list[str]:
return [attr_name for attr_name, _ in self.od.get_slots(obj)]
@ -285,6 +284,7 @@ def bind_api_readonly(odapi):
'get_target': odapi.get_target,
'get_source': odapi.get_source,
'get_slot': odapi.get_slot,
'get_slots': odapi.get_slots,
'get_slot_value': odapi.get_slot_value,
'get_slot_value_default': odapi.get_slot_value_default,
'get_all_instances': odapi.get_all_instances,
@ -292,7 +292,8 @@ def bind_api_readonly(odapi):
'get_type_name': odapi.get_type_name,
'get_outgoing': odapi.get_outgoing,
'get_incoming': odapi.get_incoming,
'has_slot': odapi.has_slot
'has_slot': odapi.has_slot,
'is_instance': odapi.is_instance,
}
return funcs