diff --git a/entity.py b/entity.py index 713c248..fccce1b 100644 --- a/entity.py +++ b/entity.py @@ -493,10 +493,11 @@ def direct_instances(Class, world = None): def get_class_properties(Class): l = set() for r in _property_value_restrictions(Class, None): - if r.property._class_property_some and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)): - l.add(r.property) - elif r.property._class_property_only and (r.type == ONLY): - l.add(r.property) + prop = r.property + if getattr(prop, "_class_property_some", False) and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)): + l.add(prop) + elif getattr(prop, "_class_property_only", False) and (r.type == ONLY): + l.add(prop) for storid in Class.namespace.world._get_triples_s_p(Class.storid): Prop = Class.namespace.world._get_by_storid(storid) @@ -507,10 +508,11 @@ def get_class_properties(Class): def INDIRECT_get_class_properties(Class): l = set() for r in _inherited_properties_value_restrictions(Class, None, set()): - if r.property._class_property_some and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)): - l.add(r.property) - elif r.property._class_property_only and (r.type == ONLY): - l.add(r.property) + prop = r.property + if getattr(prop, "_class_property_some", False) and ((r.type == VALUE) or (r.type == SOME) or ((r.type == EXACTLY) and r.cardinality >= 1) or ((r.type == MIN) and r.cardinality >= 1)): + l.add(prop) + elif getattr(prop, "_class_property_only", False) and (r.type == ONLY): + l.add(prop) for storid in Class.namespace.world._get_triples_s_p(Class.storid): Prop = Class.namespace.world._get_by_storid(storid) diff --git a/test/regtest.py b/test/regtest.py index 74c0301..8c038ae 100644 --- a/test/regtest.py +++ b/test/regtest.py @@ -5955,6 +5955,21 @@ class D(Thing): assert isinstance(r.property, Inverse) self.assert_triple(r.property.storid, owl_inverse_property, P.storid, None, world) + def test_inverse_2_get_class_properties(self): + world = self.new_world() + n = world.get_ontology("http://www.test.org/test.owl") + + with n: + class P(ObjectProperty): pass + class C(Thing): pass + class D(Thing): + is_a = [Inverse(P).some(C)] + class E(D): pass + + assert set(D.get_class_properties()) == set() + assert set(D.INDIRECT_get_class_properties()) == set() + assert set(E.INDIRECT_get_class_properties()) == set() + def test_inverse_3(self): world = self.new_world() n = world.get_ontology("http://www.test.org/test.owl")