From 2b1d9a3a3a3da6f40f73704044e994c5f106bdc4 Mon Sep 17 00:00:00 2001 From: Marco Capitani Date: Mon, 23 Apr 2018 15:47:47 +0200 Subject: storyboard: parse action arg as int before parsing as float This allows argument to also be ints on top of floats --- rumba/storyboard.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/rumba/storyboard.py b/rumba/storyboard.py index 799c78e..8570690 100644 --- a/rumba/storyboard.py +++ b/rumba/storyboard.py @@ -1251,6 +1251,8 @@ class Event(object): pass def _start(self): + logger.debug("Running event %s, action %s", + self.id, self._action_repr()) self.pre_exec() if self.done: raise ValueError('Event %s has already ran' % self.id) @@ -1385,7 +1387,6 @@ class _Script(object): """ while len(self._events_ready): event = self._events_ready.pop() - logger.debug("Running event %s.", event.id) event.run() def _nested_iterator(self, d): @@ -1433,17 +1434,22 @@ class _Script(object): args.append(arg_s) else: quotes_part = arg_s - else: + else: # Not a string if arg_s.startswith('$'): args.append(self._resolve_entity(arg_s[1:])) - else: - try: - args.append(float(arg_s)) - except ValueError: - raise ValueError('Syntax error: %s is not a float. ' - 'If it is supposed to be a string, ' - 'enclose it in single quotes.' - % (arg_s,)) + continue + try: # No string, no entity, it must be a number + args.append(int(arg_s)) + continue + except ValueError: + pass # Try to parse it as float + try: + args.append(float(arg_s)) + except ValueError: + raise ValueError('Syntax error: %s is not a valid value. ' + 'If it is supposed to be a string, ' + 'enclose it in single quotes.' + % (arg_s,)) return args def _parse_prefix(self, prefix): -- cgit v1.2.3