From fd4b0b4b8ad927362f8ac37e2437ac412686fce2 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 21 Feb 2015 15:35:31 +0100 Subject: fix bug when having multiple inputs of the same type --- blockext/generate.py | 5 +++-- example.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/blockext/generate.py b/blockext/generate.py index 207163b..c384fa8 100644 --- a/blockext/generate.py +++ b/blockext/generate.py @@ -113,6 +113,7 @@ def generate_snap(descriptor, language): inputs = SubElement(defn, "inputs") snap_spec = "" + inputCounter = 0 for part in block.parts: if isinstance(part, Input): input_el = SubElement(inputs, "input", { @@ -126,8 +127,8 @@ def generate_snap(descriptor, language): # TODO menus # XXX ^ why is there a todo comment here? - index = block.inputs.index(part) - part = "%'arg-{}'".format(index) + part = "%'arg-{}'".format(inputCounter) + inputCounter += 1 else: assert isinstance(part, str) # Snap! doesn't allow %-signs in block text yet. diff --git a/example.py b/example.py index 3b3690b..163908d 100644 --- a/example.py +++ b/example.py @@ -32,6 +32,11 @@ class Example: print(text) time.sleep(duration) + @command("multiple %s inputs are %s allowed") + def argstest(self, arg1, arg2): + print(arg1) + print(arg2) + @command("play note %n") def play_note(self, note): print("DING {note}".format(note=note)) -- cgit v1.3.1