OLD | NEW |
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 import user_story as user_story_module | 8 from telemetry import user_story as user_story_module |
9 from telemetry.util import cloud_storage | 9 from telemetry.util import cloud_storage |
10 from telemetry.wpr import archive_info | 10 from telemetry.wpr import archive_info |
(...skipping 14 matching lines...) Expand all Loading... |
25 base_dir=None, serving_dirs=None): | 25 base_dir=None, serving_dirs=None): |
26 """Creates a new UserStorySet. | 26 """Creates a new UserStorySet. |
27 | 27 |
28 Args: | 28 Args: |
29 archive_data_file: The path to Web Page Replay's archive data, relative | 29 archive_data_file: The path to Web Page Replay's archive data, relative |
30 to self.base_dir. | 30 to self.base_dir. |
31 cloud_storage_bucket: The cloud storage bucket used to download | 31 cloud_storage_bucket: The cloud storage bucket used to download |
32 Web Page Replay's archive data. Valid values are: None, | 32 Web Page Replay's archive data. Valid values are: None, |
33 PUBLIC_BUCKET, PARTNER_BUCKET, or INTERNAL_BUCKET (defined | 33 PUBLIC_BUCKET, PARTNER_BUCKET, or INTERNAL_BUCKET (defined |
34 in telemetry.util.cloud_storage). | 34 in telemetry.util.cloud_storage). |
35 serving_dirs: A set of paths, relative to self.base_dir, to directories | |
36 containing hash files for non-wpr archive data stored in cloud | |
37 storage. | |
38 """ | 35 """ |
39 self.user_stories = [] | 36 self.user_stories = [] |
40 self._archive_data_file = archive_data_file | 37 self._archive_data_file = archive_data_file |
41 self._wpr_archive_info = None | 38 self._wpr_archive_info = None |
42 archive_info.AssertValidCloudStorageBucket(cloud_storage_bucket) | 39 archive_info.AssertValidCloudStorageBucket(cloud_storage_bucket) |
43 self._cloud_storage_bucket = cloud_storage_bucket | 40 self._cloud_storage_bucket = cloud_storage_bucket |
44 if base_dir: | 41 if base_dir: |
45 if not os.path.isdir(base_dir): | 42 if not os.path.isdir(base_dir): |
46 raise ValueError('Must provide valid directory path for base_dir.') | 43 raise ValueError('Must provide valid directory path for base_dir.') |
47 self._base_dir = base_dir | 44 self._base_dir = base_dir |
(...skipping 24 matching lines...) Expand all Loading... |
72 @property | 69 @property |
73 def base_dir(self): | 70 def base_dir(self): |
74 """The base directory to resolve archive_data_file. | 71 """The base directory to resolve archive_data_file. |
75 | 72 |
76 This defaults to the directory containing the UserStorySet instance's class. | 73 This defaults to the directory containing the UserStorySet instance's class. |
77 """ | 74 """ |
78 return self._base_dir | 75 return self._base_dir |
79 | 76 |
80 @property | 77 @property |
81 def serving_dirs(self): | 78 def serving_dirs(self): |
82 all_serving_dirs = self._serving_dirs.copy() | 79 return self._serving_dirs |
83 for user_story in self.user_stories: | |
84 if user_story.serving_dir: | |
85 all_serving_dirs.add(user_story.serving_dir) | |
86 return all_serving_dirs | |
87 | 80 |
88 @property | 81 @property |
89 def archive_data_file(self): | 82 def archive_data_file(self): |
90 return self._archive_data_file | 83 return self._archive_data_file |
91 | 84 |
92 @property | 85 @property |
93 def bucket(self): | 86 def bucket(self): |
94 return self._cloud_storage_bucket | 87 return self._cloud_storage_bucket |
95 | 88 |
96 @property | 89 @property |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return self.user_stories.__iter__() | 144 return self.user_stories.__iter__() |
152 | 145 |
153 def __len__(self): | 146 def __len__(self): |
154 return len(self.user_stories) | 147 return len(self.user_stories) |
155 | 148 |
156 def __getitem__(self, key): | 149 def __getitem__(self, key): |
157 return self.user_stories[key] | 150 return self.user_stories[key] |
158 | 151 |
159 def __setitem__(self, key, value): | 152 def __setitem__(self, key, value): |
160 self.user_stories[key] = value | 153 self.user_stories[key] = value |
OLD | NEW |