Robot Framework Integrated Development Environment (RIDE)
logreportwriters.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from os.path import basename, splitext
17 
18 from robotide.lib.robot.htmldata import HtmlFileWriter, ModelWriter, LOG, REPORT
19 from robotide.lib.robot.utils import file_writer, is_string
20 
21 from .jswriter import JsResultWriter, SplitLogWriter
22 
23 
25 
26  def __init__(self, js_model):
27  self._js_model_js_model = js_model
28 
29  def _write_file(self, path, config, template):
30  outfile = file_writer(path) \
31  if is_string(path) else path # unit test hook
32  with outfile:
33  model_writer = RobotModelWriter(outfile, self._js_model_js_model, config)
34  writer = HtmlFileWriter(outfile, model_writer)
35  writer.write(template)
36 
37 
39 
40  def write(self, path, config):
41  self._write_file_write_file(path, config, LOG)
42  if self._js_model_js_model.split_results:
43  self._write_split_logs_write_split_logs(splitext(path)[0])
44 
45  def _write_split_logs(self, base):
46  for index, (keywords, strings) in enumerate(self._js_model_js_model.split_results,
47  start=1):
48  self._write_split_log_write_split_log(index, keywords, strings, '%s-%d.js' % (base, index))
49 
50  def _write_split_log(self, index, keywords, strings, path):
51  with file_writer(path) as outfile:
52  writer = SplitLogWriter(outfile)
53  writer.write(keywords, strings, index, basename(path))
54 
55 
57 
58  def write(self, path, config):
59  self._write_file_write_file(path, config, REPORT)
60 
61 
63 
64  def __init__(self, output, model, config):
65  self._output_output = output
66  self._model_model = model
67  self._config_config = config
68 
69  def write(self, line):
70  JsResultWriter(self._output_output).write(self._model_model, self._config_config)
def _write_split_log(self, index, keywords, strings, path)
def file_writer(path=None, encoding='UTF-8', newline=None)
Definition: robotio.py:21