Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: telemetry/telemetry/story/story_set.py

Issue 2163583002: Revert of [Telemetry] Ensure that story display names are unique (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import inspect 5 import inspect
6 import os 6 import os
7 7
8 from telemetry.story import story as story_module 8 from telemetry.story import story as story_module
9 from telemetry.wpr import archive_info 9 from telemetry.wpr import archive_info
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 @property 91 @property
92 def wpr_archive_info(self): 92 def wpr_archive_info(self):
93 """Lazily constructs wpr_archive_info if it's not set and returns it.""" 93 """Lazily constructs wpr_archive_info if it's not set and returns it."""
94 if self.archive_data_file and not self._wpr_archive_info: 94 if self.archive_data_file and not self._wpr_archive_info:
95 self._wpr_archive_info = archive_info.WprArchiveInfo.FromFile( 95 self._wpr_archive_info = archive_info.WprArchiveInfo.FromFile(
96 os.path.join(self.base_dir, self.archive_data_file), self.bucket) 96 os.path.join(self.base_dir, self.archive_data_file), self.bucket)
97 return self._wpr_archive_info 97 return self._wpr_archive_info
98 98
99 def AddStory(self, story): 99 def AddStory(self, story):
100 assert isinstance(story, story_module.Story) 100 assert isinstance(story, story_module.Story)
101 assert self._IsUnique(story), ('Tried to add story with duplicate display '
102 'name %s. Story display names should be '
103 'unique.' % story.display_name)
104 self.stories.append(story) 101 self.stories.append(story)
105 102
106 def _IsUnique(self, story):
107 return not any((story.display_name == other.display_name) and
108 sorted(story.grouping_keys.iteritems()) ==
109 sorted(other.grouping_keys.iteritems())
110 for other in self.stories)
111
112 def RemoveStory(self, story): 103 def RemoveStory(self, story):
113 """Removes a Story. 104 """Removes a Story.
114 105
115 Allows the stories to be filtered. 106 Allows the stories to be filtered.
116 """ 107 """
117 self.stories.remove(story) 108 self.stories.remove(story)
118 109
119 @classmethod 110 @classmethod
120 def Name(cls): 111 def Name(cls):
121 """Returns the string name of this StorySet. 112 """Returns the string name of this StorySet.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return self.stories.__iter__() 146 return self.stories.__iter__()
156 147
157 def __len__(self): 148 def __len__(self):
158 return len(self.stories) 149 return len(self.stories)
159 150
160 def __getitem__(self, key): 151 def __getitem__(self, key):
161 return self.stories[key] 152 return self.stories[key]
162 153
163 def __setitem__(self, key, value): 154 def __setitem__(self, key, value):
164 self.stories[key] = value 155 self.stories[key] = value
OLDNEW
« no previous file with comments | « telemetry/telemetry/page/page_run_end_to_end_unittest.py ('k') | telemetry/telemetry/story/story_set_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698