def create_jsdata(outxml, target): settings = RebotSettings({ 'name': '<Suite.Name>', 'critical': ['i?'], 'noncritical': ['*kek*kone*'], 'tagstatlink': ['force:http://google.com:<kuukkeli>', 'i*:http://%1/?foo=bar&zap=%1:Title of i%1', '?1:http://%1/<&>:Title', '</script>:<url>:<title>'], 'tagdoc': ['test:this_is_*my_bold*_test', 'IX:*Combined* and escaped << tag doc', 'i*:Me, myself, and I.', '</script>:<doc>'], 'tagstatcombine': ['fooANDi*:No Match', 'long1ORcollections', 'i?:IX', '<*>:<any>'] }) result = Results(settings, outxml).js_result config = {'logURL': 'log.html', 'title': 'This is a long long title. A very long title indeed. ' 'And it even contains some stuff to <esc&ape>. ' 'Yet it should still look good.', 'minLevel': 'DEBUG', 'defaultLevel': 'DEBUG', 'reportURL': 'report.html', 'background': {'fail': 'DeepPink'}} with file_writer(target) as output: writer = JsResultWriter(output, start_block='', end_block='') writer.write(result, config) print 'Log: ', normpath(join(BASEDIR, '..', 'rebot', 'log.html')) print 'Report: ', normpath(join(BASEDIR, '..', 'rebot', 'report.html'))
def _write_file(self, path, config, template): outfile = file_writer(path) \ if is_string(path) else path # unit test hook with outfile: model_writer = RobotModelWriter(outfile, self._js_model, config) writer = HtmlFileWriter(outfile, model_writer) writer.write(template)
def __init__(self, output): if is_string(output) or is_pathlike(output): self.writer = file_writer(output) self.close_writer = True else: self.writer = output self.close_writer = False
def __enter__(self): if not self.output: path = self._output_path() if PY2 and self.format == self.tsv_format: self.output = binary_file_writer(path) else: self.output = file_writer(path, newline=self.line_separator) return self
def DebugFile(path): if not path: LOGGER.info('No debug file') return None try: outfile = file_writer(path) except EnvironmentError as err: LOGGER.error("Opening debug file '%s' failed: %s" % (path, err.strerror)) return None else: LOGGER.info('Debug file: %s' % path) return _DebugFileWriter(outfile)
def DebugFile(path): if not path: LOGGER.info('No debug file') return None try: outfile = file_writer(path, usage='debug') except DataError as err: LOGGER.error(err.message) return None else: LOGGER.info('Debug file: %s' % path) return _DebugFileWriter(outfile)
def save(self, output=None): output = output or self.source if output is None: raise TypeError('Saving model requires explicit output ' 'when original source is not path.') if is_string(output) or is_pathlike(output): output = file_writer(output) close = True else: close = False try: ModelWriter(output).visit(self) finally: if close: output.close()
def create_jsdata(outxml, target): settings = RebotSettings({ 'name': '<Suite.Name>', 'critical': ['i?'], 'noncritical': ['*kek*kone*'], 'tagstatlink': [ 'force:http://google.com:<kuukkeli>', 'i*:http://%1/?foo=bar&zap=%1:Title of i%1', '?1:http://%1/<&>:Title', '</script>:<url>:<title>' ], 'tagdoc': [ 'test:this_is_*my_bold*_test', 'IX:*Combined* and escaped << tag doc', 'i*:Me, myself, and I.', '</script>:<doc>' ], 'tagstatcombine': ['fooANDi*:No Match', 'long1ORcollections', 'i?:IX', '<*>:<any>'] }) result = Results(settings, outxml).js_result config = { 'logURL': 'log.html', 'title': 'This is a long long title. A very long title indeed. ' 'And it even contains some stuff to <esc&ape>. ' 'Yet it should still look good.', 'minLevel': 'DEBUG', 'defaultLevel': 'DEBUG', 'reportURL': 'report.html', 'background': { 'fail': 'DeepPink' } } with file_writer(target) as output: writer = JsResultWriter(output, start_block='', end_block='') writer.write(result, config) print('Log: ', normpath(join(BASEDIR, '..', 'rebot', 'log.html'))) print('Report: ', normpath(join(BASEDIR, '..', 'rebot', 'report.html')))
def _get_writer(self, inpath, outpath): if PY2 and self._is_tsv(inpath): return binary_file_writer(outpath) return file_writer(outpath, newline=self._options['line_separator'])
def _get_output(self, path): return file_writer(path, newline='', usage='Tidy output')
def _write_test_doc(self, suite, outfile, title): with file_writer(outfile) as output: model_writer = TestdocModelWriter(output, suite, title) HtmlFileWriter(output, model_writer).write(TESTDOC)
def _get_writer(self, path): return file_writer(path, usage='syslog')
def _get_writer(self, outpath): return file_writer(outpath, newline=self._options['line_separator'], usage='Tidy output')
def __enter__(self): if self._format == 'HTML': self._output_file = file_writer(self._output_path) return self._output_file return self._output_path
def _write_split_log(self, index, keywords, strings, path): with file_writer(path) as outfile: writer = SplitLogWriter(outfile) writer.write(keywords, strings, index, basename(path))
def __enter__(self): if not self.output: self.output = file_writer(self._path, newline=self.line_separator) return self
def __enter__(self): if self._format == 'HTML': self._output_file = file_writer(self._output_path, usage='Libdoc output') return self._output_file return self._output_path
def write(self, libdoc, outfile): with file_writer(outfile) as f: json.dump(libdoc.to_dictionary(), f, indent=2)
def _write_test_doc(self, suite, outfile, title): with file_writer(outfile, usage='Testdoc output') as output: model_writer = TestdocModelWriter(output, suite, title) HtmlFileWriter(output, model_writer).write(TESTDOC)
def _get_writer(self, path): try: return file_writer(path) except EnvironmentError as err: raise DataError(err.strerror)
def write(self, libdoc, outfile): with file_writer(outfile) as writer: writer.write(libdoc.to_json(indent=2))