aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Capitani <m.capitani@nextworks.it>2018-04-23 15:47:47 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-04-24 10:41:13 +0000
commit2b1d9a3a3a3da6f40f73704044e994c5f106bdc4 (patch)
treef2059ac74d66219245058aae90b6c14bbe333182
parent6a2c32ccf8dfb60481dd083b24624255c5de8d55 (diff)
downloadrumba-2b1d9a3a3a3da6f40f73704044e994c5f106bdc4.tar.gz
rumba-2b1d9a3a3a3da6f40f73704044e994c5f106bdc4.zip
storyboard: parse action arg as int before parsing as float
This allows argument to also be ints on top of floats
-rw-r--r--rumba/storyboard.py26
1 files 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):