Skip to content

Instantly share code, notes, and snippets.

@mtholder
Created June 18, 2014 16:35
Show Gist options
  • Save mtholder/c6b1c44a2332d44efee0 to your computer and use it in GitHub Desktop.
Save mtholder/c6b1c44a2332d44efee0 to your computer and use it in GitHub Desktop.
query taxomachine using autocompleteBoxQuery. if a name is preceded by an arg that starts with -cblah, then blah will be the contextName
#!/usr/bin/env python
import sys
from peyotl.api.taxomachine import Taxomachine
taxomachine = Taxomachine()
from peyotl.nexson_syntax import write_as_json
context_name = 'All life'
for n in sys.argv[1:]:
if n.startswith('-c'):
context_name = n[2:]
else:
r = taxomachine.autocomplete(n, context_name=context_name)
write_as_json(r, sys.stdout, indent=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment