예제 #1
0
파일: pyDatalog.py 프로젝트: jean/pydatalog
 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
예제 #2
0
 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
예제 #3
0
파일: pyDatalog.py 프로젝트: jean/pydatalog
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)
예제 #4
0
파일: pyDatalog.py 프로젝트: jean/pydatalog
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)
예제 #5
0
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)
예제 #6
0
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)