def _set(self, variable): if is_scalar_var(variable): self.scalar_vars.append(variable) elif is_list_var(variable): self.list_var = variable else: raise DataError('Invalid variable to assign: %s' % variable)
def _get_arg_spec(self, origargs): """Returns argument spec in a tuple (args, defaults, varargs). args - tuple of all accepted arguments defaults - tuple of default values varargs - name of the argument accepting varargs or None Examples: ['${arg1}', '${arg2}'] => ('${arg1}', '${arg2}'), (), None ['${arg1}', '${arg2}=default', '@{varargs}'] => ('${arg1}', '${arg2}'), ('default',), '@{varargs}' """ args = [] defaults = [] varargs = None for arg in origargs: if varargs: raise DataError('Only last argument can be a list') if is_list_var(arg): varargs = arg continue # should be last round (otherwise DataError in next) arg, default = self._split_default(arg) if defaults and default is None: raise DataError('Non default argument after default arguments') if not is_scalar_var(arg): raise DataError("Invalid argument '%s'" % arg) args.append(arg) if default is not None: defaults.append(default) return args, defaults, varargs
def _validate(self): if not self.vars: raise DataError('FOR loop has no loop variables.') for var in self.vars: if not is_scalar_var(var): raise DataError("Invalid FOR loop variable '%s'." % var) if not self.items: raise DataError('FOR loop has no loop values.') if not self.keywords: raise DataError('FOR loop contains no keywords.')
def method(self, *args, **kwargs): try: variables = BuiltIn()._variables except RobotNotRunningError: pass else: for key, value in list(dictitems(kwargs)): if is_scalar_var(key): kwargs[variables[key]] = kwargs.pop(key) return func(self, *args, **kwargs)
def _is_old_x_times_syntax(self, name): if not name.lower().endswith('x'): return False times = name[:-1].strip() if is_scalar_var(times): return True try: int(times) except ValueError: return False else: return True
def test_is_scalar_var(self): for ok in SCALARS: assert is_scalar_var(ok) for nok in LISTS + NOKS: assert not is_scalar_var(nok)
def _format_arg(self, arg): if not is_scalar_var(arg): raise DataError("Invalid argument '%s'." % arg) return arg[2:-1]
def _format_arg(self, arg): if not is_scalar_var(arg): self._raise_invalid_spec("Invalid argument syntax '%s'." % arg) return arg[2:-1]