def _deprecate_escaped_cells_before_continuation(self, data): index = data.index(self._row_continuation_marker) if any(cell == '\\' for cell in data[:index]): LOGGER.warn("Error in file '%s': Escaping empty cells with " "'\\' before line continuation marker '...' is " "deprecated. Remove escaping before Robot " "Framework 3.2." % self.source)
def _deprecate_quoting(self, cell, path, line_number): if len(cell) > 1 and cell[0] == cell[-1] == '"': LOGGER.warn("TSV file '%s' has quotes around cells which is " "deprecated and must be fixed. Remove quotes " "from '%s' on line %d." % (path, cell, line_number)) return cell[1:-1].replace('""', '"').strip() return cell
def _process_cell(self, cell, path): if len(cell) > 1 and cell[0] == cell[-1] == '"': cell = cell[1:-1].replace('""', '"') if path not in self._warned_escaping: LOGGER.warn("Un-escaping quotes in TSV files is deprecated. " "Change cells in '%s' to not contain surrounding " "quotes." % path) self._warned_escaping.add(path) return cell
def _log_imported_library(self, name, args, lib): type = lib.__class__.__name__.replace("Library", "").lower()[1:] listener = ", with listener" if lib.has_listener else "" LOGGER.info( "Imported library '%s' with arguments %s " "(version %s, %s type, %s scope, %d keywords%s)" % (name, seq2str2(args), lib.version or "<unknown>", type, lib.scope.lower(), len(lib), listener) ) if not lib and not lib.has_listener: LOGGER.warn("Imported library '%s' contains no keywords" % name)
def _check_deprecations(self, cells, path, line_number): for original in cells: normalized = self._normalize_whitespace(original) if normalized != original: if len(normalized) != len(original): msg = 'Collapsing consecutive whitespace' else: msg = 'Converting whitespace characters to ASCII spaces' LOGGER.warn("%s during parsing is deprecated. Fix %s in file " "'%s' on line %d." % (msg, prepr(original), path, line_number)) yield normalized
def _check_deprecated_extensions(self, source): if os.path.isdir(source): return ext = os.path.splitext(source)[1][1:].lower() if self.extensions and ext in self.extensions: return # HTML files cause deprecation warning that cannot be avoided with # --extension at parsing time. No need for double warning. if ext not in ('robot', 'html', 'htm', 'xhtml'): LOGGER.warn("Automatically parsing other than '*.robot' files is " "deprecated. Convert '%s' to '*.robot' format or use " "'--extension' to explicitly configure which files to " "parse." % source)
def _unescape_opts_and_args(self, opts, args): from robotide.lib.robot.output import LOGGER with LOGGER.cache_only: LOGGER.warn("Option '--escape' is deprecated. Use console escape " "mechanism instead.") try: escape_strings = opts['escape'] except KeyError: raise FrameworkError("No 'escape' in options") escapes = self._get_escapes(escape_strings) for name, value in opts.items(): if name != 'escape': opts[name] = self._unescape(value, escapes) return opts, [self._unescape(arg, escapes) for arg in args]
def read(self, htmlfile, populator, path=None): self.populator = populator self.state = self.IGNORE self.current_row = None self.current_cell = None for line in htmlfile.readlines(): self.feed(self._decode(line)) # Calling close is required by the HTMLParser but may cause problems # if the same instance of our HtmlParser is reused. Currently it's # used only once so there's no problem. self.close() if self.populator.eof(): LOGGER.warn("Using test data in HTML format is deprecated. " "Convert '%s' to plain text format." % (path or htmlfile.name))
def _process_value(self, name, value): if name == 'ReRunFailed': return gather_failed_tests(value) if name == 'ReRunFailedSuites': return gather_failed_suites(value) if name == 'LogLevel': return self._process_log_level(value) if value == self._get_default_value(name): return value if name == 'Doc': return self._escape_as_data(value) if name in ['Metadata', 'TagDoc']: if name == 'Metadata': value = [self._escape_as_data(v) for v in value] return [self._process_metadata_or_tagdoc(v) for v in value] if name in ['Include', 'Exclude']: return [self._format_tag_patterns(v) for v in value] if name in self._output_opts and (not value or value.upper() == 'NONE'): return None if name == 'OutputDir': return abspath(value) if name in ['SuiteStatLevel', 'ConsoleWidth']: return self._convert_to_positive_integer_or_default(name, value) if name == 'VariableFiles': return [split_args_from_name_or_path(item) for item in value] if name == 'ReportBackground': return self._process_report_background(value) if name == 'TagStatCombine': return [self._process_tag_stat_combine(v) for v in value] if name == 'TagStatLink': return [ v for v in [self._process_tag_stat_link(v) for v in value] if v ] if name == 'Randomize': return self._process_randomize_value(value) if name == 'MaxErrorLines': return self._process_max_error_lines(value) if name == 'RemoveKeywords': self._validate_remove_keywords(value) if name == 'FlattenKeywords': self._validate_flatten_keywords(value) if name == 'WarnOnSkipped': with LOGGER.cache_only: LOGGER.warn("Option '--warnonskippedfiles' is deprecated and " "has no effect. Nowadays all skipped files are " "reported.") return value
def _process_value(self, name, value): if name == 'ReRunFailed': return gather_failed_tests(value) if name == 'ReRunFailedSuites': return gather_failed_suites(value) if name == 'LogLevel': return self._process_log_level(value) if value == self._get_default_value(name): return value if name == 'Doc': return self._escape_as_data(value) if name in ['Metadata', 'TagDoc']: if name == 'Metadata': value = [self._escape_as_data(v) for v in value] return [self._process_metadata_or_tagdoc(v) for v in value] if name in ['Include', 'Exclude']: return [self._format_tag_patterns(v) for v in value] if name in self._output_opts and (not value or value.upper() == 'NONE'): return None if name == 'OutputDir': return abspath(value) if name in ['SuiteStatLevel', 'ConsoleWidth']: return self._convert_to_positive_integer_or_default(name, value) if name == 'VariableFiles': return [split_args_from_name_or_path(item) for item in value] if name == 'ReportBackground': return self._process_report_background(value) if name == 'TagStatCombine': return [self._process_tag_stat_combine(v) for v in value] if name == 'TagStatLink': return [v for v in [self._process_tag_stat_link(v) for v in value] if v] if name == 'Randomize': return self._process_randomize_value(value) if name == 'MaxErrorLines': return self._process_max_error_lines(value) if name == 'RemoveKeywords': self._validate_remove_keywords(value) if name == 'FlattenKeywords': self._validate_flatten_keywords(value) if name == 'WarnOnSkipped': with LOGGER.cache_only: LOGGER.warn("Option '--warnonskippedfiles' is deprecated and " "has no effect. Nowadays all skipped files are " "reported.") return value
def _process_value(self, name, value): if name == 'ReRunFailed': return gather_failed_tests(value) if name == 'DeprecatedRunFailed': if value.upper() != 'NONE': LOGGER.warn('Option --runfailed is deprecated and will be ' 'removed in the future. Use --rerunfailed instead.') return gather_failed_tests(value) if name == 'DeprecatedMerge' and value is True: LOGGER.warn('Option --rerunmerge is deprecated and will be ' 'removed in the future. Use --merge instead.') if name == 'LogLevel': return self._process_log_level(value) if value == self._get_default_value(name): return value if name in ['Name', 'Doc', 'LogTitle', 'ReportTitle']: if name == 'Doc': value = self._escape_as_data(value) return value.replace('_', ' ') if name in ['Metadata', 'TagDoc']: if name == 'Metadata': value = [self._escape_as_data(v) for v in value] return [self._process_metadata_or_tagdoc(v) for v in value] if name in ['Include', 'Exclude']: return [self._format_tag_patterns(v) for v in value] if name in self._output_opts and (not value or value.upper() == 'NONE'): return None if name == 'OutputDir': return abspath(value) if name in ['MonitorWidth', 'MonitorColors', 'MonitorMarkers']: option = '--' + name.lower() LOGGER.warn("Option '%s' is deprecated. Use '%s' instead." % (option, option.replace('monitor', 'console'))) if name in ['SuiteStatLevel', 'MonitorWidth', 'ConsoleWidth']: return self._convert_to_positive_integer_or_default(name, value) if name == 'VariableFiles': return [split_args_from_name_or_path(item) for item in value] if name == 'ReportBackground': return self._process_report_background(value) if name == 'TagStatCombine': return [self._process_tag_stat_combine(v) for v in value] if name == 'TagStatLink': return [v for v in [self._process_tag_stat_link(v) for v in value] if v] if name == 'Randomize': return self._process_randomize_value(value) if name == 'RemoveKeywords': self._validate_remove_keywords(value) if name == 'FlattenKeywords': self._validate_flatten_keywords(value) return value
def _log_failed_parsing(self, message, warn): if warn: LOGGER.warn(message) else: LOGGER.info(message)
def _warn_about_registeration_error(self, signum, err): name, ctrlc = {signal.SIGINT: ('INT', 'or with Ctrl-C '), signal.SIGTERM: ('TERM', '')}[signum] LOGGER.warn('Registering signal %s failed. Stopping execution ' 'gracefully with this signal %sis not possible. ' 'Original error was: %s' % (name, ctrlc, err))
def _deprecate_empty_data_cells_in_tsv_format(self, cells, path): data_cells = dropwhile(lambda c: not c, cells) if not all(data_cells) and path not in self._warned_empty: LOGGER.warn("Empty cells in TSV files are deprecated. " "Escape them with '${EMPTY}' in '%s'." % path) self._warned_empty.add(path)
def _convert_to_new_style_metadata(self): # TODO: Remove support for olde style metadata in RF 2.10. LOGGER.warn("Setting suite metadata using '%s' syntax is deprecated. " "Use 'Metadata' setting with name and value in separate " "cells instead." % self.head) return ['Metadata'] + [self.head.split(':', 1)[1].strip()] + self.tail
def _deprecate_empty_data_cells(self, cells, path, line_number): data_cells = dropwhile(lambda c: not c, cells) if not all(data_cells): LOGGER.warn("TSV file '%s' has empty data cells which is " "deprecated and must be fixed. Escape empty cells " "on line %d with '${EMPTY}'." % (path, line_number))
def _get_reserved_variable(self, splitter): value = splitter.get_replaced_variable(self) LOGGER.warn("Syntax '%s' is reserved for future use. Please " "escape it like '\\%s'." % (value, value)) return value
def _report_status(self): if self.setting_table or self.variable_table or self.keyword_table: LOGGER.info("Imported resource file '%s' (%d keywords)." % (self.source, len(self.keyword_table.keywords))) else: LOGGER.warn("Imported resource file '%s' is empty." % self.source)