grilo: Port from JavaScript to Python