1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6class OutputFormatter(object):
7  """A formatter for PageTestResults.
8
9  An OutputFormatter takes PageTestResults, formats the results
10  (telemetry.value.Value instances), and output the formatted results
11  in the given output stream.
12
13  Examples of output formatter: CsvOutputFormatter produces results in
14  CSV format."""
15
16  def __init__(self, output_stream):
17    """Constructs a new formatter that writes to the output_stream.
18
19    Args:
20      output_stream: The stream to write the formatted output to.
21    """
22    self._output_stream = output_stream
23
24  def Format(self, page_test_results):
25    """Formats the given PageTestResults into the output stream.
26
27    This will be called once at the end of a benchmark.
28
29    Args:
30      page_test_results: A PageTestResults object containing all results
31         from the current benchmark run.
32    """
33    raise NotImplementedError()
34
35  @property
36  def output_stream(self):
37    return self._output_stream
38