Skip to content

template.facts() iteration #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
solodibene opened this issue Mar 17, 2025 · 2 comments
Open

template.facts() iteration #69

solodibene opened this issue Mar 17, 2025 · 2 comments
Labels

Comments

@solodibene
Copy link

solodibene commented Mar 17, 2025

>>> env = Environment()
>>> env.build('(deftemplate kuku (slot muku))')
>>> template = env.find_template('kuku')
>>> fact = template.assert_fact(muku = 100)
>>> template
Template: (deftemplate MAIN::kuku (slot muku))
>>> fact
TemplateFact: (kuku (muku 100))
>>> for f in env.facts():
...     print(f)
... 
(kuku (muku 100))
>>> for f in template.facts():
...     print(f)
... 
Traceback (most recent call last):
  File "<python-input-10>", line 2, in <module>
    print(f)
  File "C:\Users\IMOE001\AppData\Local\Programs\Python\Python313\Lib\site-packages\clips\facts.py", line 78, in __str__
    return ' '.join(fact_pp_string(self._env, self._fact).split())
  File "C:\Users\IMOE001\AppData\Local\Programs\Python\Python313\Lib\site-packages\clips\facts.py", line 660, in fact_pp_string
    builder = environment_builder(env, 'string')
  File "C:\Users\IMOE001\AppData\Local\Programs\Python\Python313\Lib\site-packages\clips\common.py", line 190, in environment_builder   
    return getattr(ENVIRONMENT_DATA[env].builders, name)
KeyError: <cdata 'struct deftemplate *' 0x000001FD22EEE580>
@noxdafox
Copy link
Owner

Thanks for reporting this issue, it will be fixed in next release.

@solodibene
Copy link
Author

Great! Thank you for the prompt fix! Good catch with the test case too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants