Example #1
0
def slot_value(env, fact, slot):
    data = clips.data.DataObject(env)
    slot = slot if slot is not None else ffi.NULL
    implied = lib.implied_deftemplate(lib.EnvFactDeftemplate(env, fact))

    if not implied and slot == ffi.NULL:
        raise ValueError()

    if bool(lib.EnvGetFactSlot(env, fact, slot, data.byref)):
        return data.value
Example #2
0
def new_fact(env, fact):
    if lib.implied_deftemplate(lib.EnvFactDeftemplate(env, fact)):
        return ImpliedFact(env, fact)
    else:
        return TemplateFact(env, fact)
Example #3
0
 def implied(self):
     """True if the Template is implied."""
     return bool(lib.implied_deftemplate(self._tpl))