예제 #1
0
파일: datalog.py 프로젝트: utdb/judged
def query(clause, args):
    """Executes a query and presents the answers."""
    if args.verbose:
        print(formatting.comment("% query ") + "{}".format(clause))

    # determine debugger
    debugger = None
    if args.debug:
        debugger = ReportingDebugger()

    # determine cache mechanism
    cache = {'none': caching.NoCache,
             'dict': caching.DictCache}[args.cache]()

    # set up prover and execute query
    prover = logic.Prover(kb, debugger=debugger, cache=cache)
    for a in prover.ask(clause):
        print("{}.".format(a))
예제 #2
0
파일: datalog.py 프로젝트: utdb/judged
def retract_clause(clause, args):
    if args.verbose:
        print(formatting.comment("% retract ") + "{}".format(clause))
    kb.retract_clause(clause)
예제 #3
0
파일: datalog.py 프로젝트: utdb/judged
def assert_clause(clause, args):
    if args.verbose:
        print(formatting.comment("% assert ") + "{}".format(clause))
    kb.assert_clause(clause)