From b28e50ac4cf013eb68f6d3a10b07f8683bd60122 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 16 Jun 2019 14:57:14 +0300 Subject: Fix: encode args as JSON, to get around difficult chars in captures --- ftt-codegen | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ftt-codegen b/ftt-codegen index f8a57b4..c54a383 100755 --- a/ftt-codegen +++ b/ftt-codegen @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import copy +import json import re import sys @@ -9,7 +10,7 @@ import yaml hardcoded = ''' -import fable +import fable, json run = fable.Run() ''' @@ -112,13 +113,12 @@ def find_binding(bindings, keyword, rest): def codegen(f, step, bindings): words = step.split() + if not words: + return keyword = words[0] rest = ' '.join(words[1:]) function, args = find_binding(bindings, keyword, rest) - f.write('args = {\n') - for arg in args: - f.write('"{}": "{}"\n'.format(arg, args[arg])) - f.write('}\n') + f.write('args = {}\n'.format(json.dumps(args))) f.write('{}(run.get_context(), **args)\n'.format(function)) def debug(msg): -- cgit v1.2.1