glaserL / viasp

A visualization tool for clingo
MIT License
3 stars 3 forks source link

Make quickstart application and not what ever you have #66

Closed glaserL closed 2 years ago

glaserL commented 2 years ago

c+p How to build your own ASP system?


import sys
from clingo.application import clingo_main, Application
from clingo.script import enable_python

enable_python()
class App(Application):
  def main(self, ctl, files):
    for path in files:
      ctl.load(path)
      if not files:
        ctl.load("-")
    ctl.ground([("base", [])])
    ctl.solve()

if __name__ == "__main__":
  clingo_main(App(), sys.argv[1:])
glaserL commented 2 years ago

viasp extends the ctl object. the argument of def main(self, ctl, files): is constructed somewhere in cython and in private functions, so there is no nice way to do this.

This can be revisted if the application exposes the ctl object to configuration.