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, None, 18 None) 19 self._reason = reason 20 21 def __repr__(self): 22 page_name = self.page.display_name 23 return 'SkipValue(%s, %s, description=%s)' % (page_name, self._reason, 24 self.description) 25 26 @property 27 def reason(self): 28 return self._reason 29 30 def GetBuildbotDataType(self, output_context): 31 return None 32 33 def GetBuildbotValue(self): 34 return None 35 36 def GetChartAndTraceNameForPerPageResult(self): 37 return None 38 39 def GetRepresentativeNumber(self): 40 return None 41 42 def GetRepresentativeString(self): 43 return None 44 45 @staticmethod 46 def GetJSONTypeName(): 47 return 'skip' 48 49 def AsDict(self): 50 d = super(SkipValue, self).AsDict() 51 d['reason'] = self._reason 52 return d 53 54 @staticmethod 55 def FromDict(value_dict, page_dict): 56 kwargs = value_module.Value.GetConstructorKwArgs(value_dict, page_dict) 57 del kwargs['name'] 58 del kwargs['units'] 59 if 'important' in kwargs: 60 del kwargs['important'] 61 kwargs['reason'] = value_dict['reason'] 62 if 'tir_label' in kwargs: 63 del kwargs['tir_label'] 64 if 'grouping_keys' in kwargs: 65 del kwargs['grouping_keys'] 66 67 return SkipValue(**kwargs) 68 69 @classmethod 70 def MergeLikeValuesFromSamePage(cls, values): 71 assert False, 'Should not be called.' 72 73 @classmethod 74 def MergeLikeValuesFromDifferentPages(cls, values): 75 assert False, 'Should not be called.' 76