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
5from telemetry import value as value_module
6
7
8class SkipValue(value_module.Value):
9
10  def __init__(self, page, reason, description=None):
11    """A value representing a skipped page.
12
13    Args:
14      page: The skipped page object.
15      reason: The string reason the page was skipped.
16    """
17    super(SkipValue, self).__init__(page, 'skip', '', True, description)
18    self._reason = reason
19
20  def __repr__(self):
21    page_name = self.page.url
22    return 'SkipValue(%s, %s)' % (page_name, self._reason)
23
24  @property
25  def reason(self):
26    return self._reason
27
28  def GetBuildbotDataType(self, output_context):
29    return None
30
31  def GetBuildbotValue(self):
32    return None
33
34  def GetChartAndTraceNameForPerPageResult(self):
35    return None
36
37  def GetRepresentativeNumber(self):
38    return None
39
40  def GetRepresentativeString(self):
41    return None
42
43  @staticmethod
44  def GetJSONTypeName():
45    return 'skip'
46
47  def AsDict(self):
48    d = super(SkipValue, self).AsDict()
49    d['reason'] = self._reason
50    return d
51
52  @staticmethod
53  def FromDict(value_dict, page_dict):
54    kwargs = value_module.Value.GetConstructorKwArgs(value_dict, page_dict)
55    del kwargs['name']
56    del kwargs['units']
57    important = kwargs.get('important', None)
58    if important != None:
59      del kwargs['important']
60    kwargs['reason'] = value_dict['reason']
61
62    return SkipValue(**kwargs)
63
64  @classmethod
65  def MergeLikeValuesFromSamePage(cls, values):
66    assert False, 'Should not be called.'
67
68  @classmethod
69  def MergeLikeValuesFromDifferentPages(cls, values,
70                                        group_by_name_suffix=False):
71    assert False, 'Should not be called.'
72