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. |
35 """ | 38 """ |
36 self.user_stories = [] | 39 self.user_stories = [] |
37 self._archive_data_file = archive_data_file | 40 self._archive_data_file = archive_data_file |
38 self._wpr_archive_info = None | 41 self._wpr_archive_info = None |
39 archive_info.AssertValidCloudStorageBucket(cloud_storage_bucket) | 42 archive_info.AssertValidCloudStorageBucket(cloud_storage_bucket) |
40 self._cloud_storage_bucket = cloud_storage_bucket | 43 self._cloud_storage_bucket = cloud_storage_bucket |
41 if base_dir: | 44 if base_dir: |
42 if not os.path.isdir(base_dir): | 45 if not os.path.isdir(base_dir): |
43 raise ValueError('Must provide valid directory path for base_dir.') | 46 raise ValueError('Must provide valid directory path for base_dir.') |
44 self._base_dir = base_dir | 47 self._base_dir = base_dir |
(...skipping 24 matching lines...) Expand all Loading... |
69 @property | 72 @property |
70 def base_dir(self): | 73 def base_dir(self): |
71 """The base directory to resolve archive_data_file. | 74 """The base directory to resolve archive_data_file. |
72 | 75 |
73 This defaults to the directory containing the UserStorySet instance's class. | 76 This defaults to the directory containing the UserStorySet instance's class. |
74 """ | 77 """ |
75 return self._base_dir | 78 return self._base_dir |
76 | 79 |
77 @property | 80 @property |
78 def serving_dirs(self): | 81 def serving_dirs(self): |
79 return self._serving_dirs | 82 all_serving_dirs = self._serving_dirs.copy() |
| 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 |
80 | 87 |
81 @property | 88 @property |
82 def archive_data_file(self): | 89 def archive_data_file(self): |
83 return self._archive_data_file | 90 return self._archive_data_file |
84 | 91 |
85 @property | 92 @property |
86 def bucket(self): | 93 def bucket(self): |
87 return self._cloud_storage_bucket | 94 return self._cloud_storage_bucket |
88 | 95 |
89 @property | 96 @property |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 return self.user_stories.__iter__() | 151 return self.user_stories.__iter__() |
145 | 152 |
146 def __len__(self): | 153 def __len__(self): |
147 return len(self.user_stories) | 154 return len(self.user_stories) |
148 | 155 |
149 def __getitem__(self, key): | 156 def __getitem__(self, key): |
150 return self.user_stories[key] | 157 return self.user_stories[key] |
151 | 158 |
152 def __setitem__(self, key, value): | 159 def __setitem__(self, key, value): |
153 self.user_stories[key] = value | 160 self.user_stories[key] = value |
OLD | NEW |