ironman5366 / W.I.L.L

A python written personal assistant
https://willbeddow.com
MIT License
377 stars 58 forks source link

plugin.json format #28

Closed brenttaylor closed 7 years ago

brenttaylor commented 8 years ago

I'm working on a proposal for a change in how we handle python plugins. In the meantime I'm doing a general refactoring of the plugin code for cleanup purposes. There's a lot of unnecessary code and practically no error or validation checking.

One thing I notice is the actual format for plugin.json files. Is there a reason the plugin.json format is a list of dicts with single key value pairs? This only makes parsing more complicated and much harder to validate.

Here's an example from the search plugin.json:

[
  {"name": "search"},
  {"type": "python"},
  {"require": ["command"]},
  {"pos": "verb"},
  {"file": "search.py"},
  {"function": "main"},
  {"returns": "answer"},
  {"synonyms": ["google"]},
  {"questiontriggers": "any"},
  {"firstword":"yes"}
]

I think this is likely a better approach:

{
  "name": "search",
  "type": "python",
  "require": ["command"],
  "pos": "verb",
  "file": "search.py",
  "function": "main",
  "returns": "answer",
  "synonyms": ["google"],
  "questiontriggers": "any",
  "firstword": "yes"
}

Any complaints with making this change?

ironman5366 commented 8 years ago

Sounds great, thanks! It should remove the need for some of my ugliest code too.

brenttaylor commented 8 years ago

Just giving an update on this. I have been working on this (and a rewrite of the plugin system), I've just been delayed by work and family in the hospital. I should be done in the next few days however as things are calming down.

ironman5366 commented 8 years ago

@brenttaylor I really appreciate the work, thanks! Honestly I'm really happily shocked at all the improvements that you've been doing, thanks again.