| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 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 import inspect | 4 import inspect |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 import urlparse | 7 import urlparse |
| 8 | 8 |
| 9 from telemetry import user_story | 9 from telemetry import user_story |
| 10 from telemetry.page import shared_page_state | 10 from telemetry.page import shared_page_state |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if self.url.endswith('/'): | 195 if self.url.endswith('/'): |
| 196 file_path_url += os.sep | 196 file_path_url += os.sep |
| 197 return file_path_url | 197 return file_path_url |
| 198 | 198 |
| 199 @property | 199 @property |
| 200 def file_path_url_with_scheme(self): | 200 def file_path_url_with_scheme(self): |
| 201 return 'file://' + self.file_path_url | 201 return 'file://' + self.file_path_url |
| 202 | 202 |
| 203 @property | 203 @property |
| 204 def serving_dir(self): | 204 def serving_dir(self): |
| 205 if not self.is_file: | |
| 206 return None | |
| 207 file_path = os.path.realpath(self.file_path) | 205 file_path = os.path.realpath(self.file_path) |
| 208 if os.path.isdir(file_path): | 206 if os.path.isdir(file_path): |
| 209 return file_path | 207 return file_path |
| 210 else: | 208 else: |
| 211 return os.path.dirname(file_path) | 209 return os.path.dirname(file_path) |
| 212 | 210 |
| 213 @property | 211 @property |
| 214 def display_name(self): | 212 def display_name(self): |
| 215 if self.name: | 213 if self.name: |
| 216 return self.name | 214 return self.name |
| 217 if not self.is_file: | 215 if not self.is_file: |
| 218 return self.url | 216 return self.url |
| 219 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] | 217 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] |
| 220 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) | 218 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) |
| 221 return self.url[len(common_prefix):].strip('/') | 219 return self.url[len(common_prefix):].strip('/') |
| OLD | NEW |