예제 #1
0
 def _raise_replacing_vars_failed(self, import_setting, err):
     raise DataError("Replacing variables from setting '%s' failed: %s" %
                     (import_setting.type, unicode(err)))
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)))
예제 #5
0
 def _format_arg(self, arg):
     if not is_scalar_var(arg):
         raise DataError("Invalid argument '%s'." % arg)
     return arg[2:-1]
예제 #6
0
 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)
예제 #7
0
 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)))
예제 #8
0
 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())
예제 #9
0
 def _recursive_and_inplace_together(self, args):
     raise DataError('--recursive and --inplace can not be used together.')
예제 #10
0
 def _verify_keyword_is_valid(self):
     if not (self.keywords or self.return_value):
         raise DataError("User keyword '%s' contains no keywords." %
                         self.name)
예제 #11
0
 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.')
예제 #12
0
 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)
예제 #13
0
 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))
예제 #14
0
 def get_library(self, name):
     try:
         return self.libraries[name.replace(' ', '')]
     except KeyError:
         raise DataError("No library with name '%s' found." % name)
예제 #15
0
 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
예제 #16
0
 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.')
예제 #17
0
 def _run(self, data, *args, **kwargs):
     raise DataError("Invalid FOR loop type '%s'. Expected 'IN', "
                     "'IN RANGE', 'IN ZIP', or 'IN ENUMERATE'." %
                     self.flavor)
예제 #18
0
 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.')
예제 #19
0
 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
예제 #20
0
 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.')
예제 #21
0
 def _resolve_dict_values(self, values):
     raise DataError(
         'FOR IN ZIP loops do not support iterating over dictionaries.')
예제 #22
0
 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)
예제 #24
0
 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('= ')
예제 #25
0
 def _raise_invalid_option_value(self, option_name, given_value):
     raise DataError("Option '%s' does not support value '%s'."
                     % (option_name, given_value))
예제 #26
0
 def _raise_invalid_spec(self, error):
     raise DataError('Invalid argument specification: %s' % error)
예제 #27
0
 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))
예제 #28
0
 def JavaDocBuilder():
     raise DataError('Documenting Java test libraries requires Jython.')
예제 #29
0
 def _validate_flatten_keywords(self, values):
     try:
         validate_flatten_keyword(values)
     except DataError as err:
         raise DataError("Invalid value for option '--flattenkeywords'. %s" % err)
예제 #30
0
 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))