def _getattr(self, attribute): """ responds to instance.method by asking datalog engine """ if not attribute == "__iter__" and not attribute.startswith("_sa_"): predicate_name = "%s.%s[1]==" % (self.__class__.__name__, attribute) literal = Literal.make(predicate_name, (self, Symbol("X"))) result = literal.lua.ask(False) return result[0][-1] if result else None raise AttributeError
def _getattr(self, attribute): """ responds to instance.method by asking datalog engine """ if not attribute == '__iter__' and not attribute.startswith( '_sa_'): predicate_name = "%s.%s[1]==" % (self.__class__.__name__, attribute) literal = Literal.make(predicate_name, (self, Symbol("X"))) result = literal.lua.ask(False) return result[0][-1] if result else None raise AttributeError
def assert_fact(predicate_name, *args): """ assert predicate_name(args) """ literal = Literal.make(predicate_name, [pyParser.Expression._for(arg) for arg in args]) _assert_fact(literal)
def retract_fact(predicate_name, *args): """ retracts predicate_name(args) """ literal = Literal.make(predicate_name, [pyParser.Expression._for(arg) for arg in args]) _retract_fact(literal)