def _raise_replacing_vars_failed(self, import_setting, err): raise DataError("Replacing variables from setting '%s' failed: %s" % (import_setting.type, unicode(err)))
def _process_tag_stat_link(self, value): tokens = value.split(':') if len(tokens) >= 3: return tokens[0], ':'.join(tokens[1:-1]), tokens[-1] raise DataError("Invalid format for option '--tagstatlink'. " "Expected 'tag:link:title' but got '%s'." % value)
def _validate_remove_keywords(self, values): for value in values: try: KeywordRemover(value) except DataError as err: raise DataError("Invalid value for option '--removekeywords'. %s" % err)
def _raise_wrong_variable_count(self, variables, values): raise DataError( 'Number of FOR IN ENUMERATE loop values should be multiple of ' 'its variables (excluding the index). Got %d variables but %d ' 'value%s.' % (variables, values, s(values)))
def _format_arg(self, arg): if not is_scalar_var(arg): raise DataError("Invalid argument '%s'." % arg) return arg[2:-1]
def _replace_variables(self, values, variables): try: return DotDict( self._yield_replaced(values, variables.replace_scalar)) except TypeError as err: raise DataError('Creating dictionary failed: %s' % err)
def _raise_wrong_variable_count(self, variables, values): raise DataError( 'Number of FOR loop values should be multiple of its variables. ' 'Got %d variables but %d value%s.' % (variables, values, s(values)))
def _compile_regexp(self, pattern): try: return re.compile(''.join(pattern), re.IGNORECASE) except: raise DataError("Compiling embedded arguments regexp failed: %s" % utils.get_error_message())
def _recursive_and_inplace_together(self, args): raise DataError('--recursive and --inplace can not be used together.')
def _verify_keyword_is_valid(self): if not (self.keywords or self.return_value): raise DataError("User keyword '%s' contains no keywords." % self.name)
def _regexp_extensions_are_not_allowed(self, pattern): if not self._regexp_extension.search(pattern): return pattern raise DataError('Regexp extensions are not allowed in embedded ' 'arguments.')
def _validate_not_importing_init_file(self, path): name = os.path.splitext(os.path.basename(path))[0] if name.lower() == '__init__': raise DataError("Initialization file '%s' cannot be imported as " "a resource file." % path)
def _raise_multiple_keywords_found(self, name, found, implicit=True): error = "Multiple keywords with name '%s' found" % name if implicit: error += ". Give the full name of the keyword you want to use" names = sorted(handler.longname for handler in found) raise DataError('\n '.join([error + ':'] + names))
def get_library(self, name): try: return self.libraries[name.replace(' ', '')] except KeyError: raise DataError("No library with name '%s' found." % name)
def _values_per_iteration(self, variables): if len(variables) < 2: raise DataError('FOR IN ENUMERATE expected 2 or more loop ' 'variables, got %d.' % len(variables)) return len(variables) - 1
def _recursive_mode_arguments(self, args): if len(args) != 1: raise DataError('--recursive requires exactly one argument.') if not os.path.isdir(args[0]): raise DataError('--recursive requires input to be a directory.')
def _run(self, data, *args, **kwargs): raise DataError("Invalid FOR loop type '%s'. Expected 'IN', " "'IN RANGE', 'IN ZIP', or 'IN ENUMERATE'." % self.flavor)
def _inplace_mode_arguments(self, args): if not all(os.path.isfile(path) for path in args): raise DataError('--inplace requires inputs to be files.')
def _map_dict_values_to_rounds(self, values, per_round): if per_round > 2: raise DataError( 'Number of FOR loop variables must be 1 or 2 when iterating ' 'over dictionaries, got %d.' % per_round) return values
def _default_mode_arguments(self, args): if len(args) not in (1, 2): raise DataError('Default mode requires 1 or 2 arguments.') if not os.path.isfile(args[0]): raise DataError('Default mode requires input to be a file.')
def _resolve_dict_values(self, values): raise DataError( 'FOR IN ZIP loops do not support iterating over dictionaries.')
def line_sep(self, lineseparator, **others): values = {'native': os.linesep, 'windows': '\r\n', 'unix': '\n'} try: return values[(lineseparator or 'native').lower()] except KeyError: raise DataError("Invalid line separator '%s'." % lineseparator)
def start_keyword(self, keyword): self._started_keywords += 1 if self._started_keywords > self._started_keywords_threshold: raise DataError('Maximum limit of started keywords exceeded.') self.output.start_keyword(keyword)
def _validate_assign_mark(self, variable): if self._seen_assign_mark: raise DataError("Assign mark '=' can be used only with the last " "variable.") self._seen_assign_mark = variable.endswith('=') return variable.rstrip('= ')
def _raise_invalid_option_value(self, option_name, given_value): raise DataError("Option '%s' does not support value '%s'." % (option_name, given_value))
def _raise_invalid_spec(self, error): raise DataError('Invalid argument specification: %s' % error)
def _convert_to_integer(self, name, value): try: return int(value) except ValueError: raise DataError("Option '--%s' expected integer value but got '%s'." % (name.lower(), value))
def JavaDocBuilder(): raise DataError('Documenting Java test libraries requires Jython.')
def _validate_flatten_keywords(self, values): try: validate_flatten_keyword(values) except DataError as err: raise DataError("Invalid value for option '--flattenkeywords'. %s" % err)
def _verify_type(self, imported): if inspect.isclass(imported) or inspect.ismodule(imported): return imported raise DataError('Expected class or module, got %s.' % type_name(imported))