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

Side by Side Diff: tools/telemetry/telemetry/page/__init__.py

Issue 838253005: Refactor serving_dirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed import. Created 5 years, 9 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
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/page_set_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
205 file_path = os.path.realpath(self.file_path) 207 file_path = os.path.realpath(self.file_path)
206 if os.path.isdir(file_path): 208 if os.path.isdir(file_path):
207 return file_path 209 return file_path
208 else: 210 else:
209 return os.path.dirname(file_path) 211 return os.path.dirname(file_path)
210 212
211 @property 213 @property
212 def display_name(self): 214 def display_name(self):
213 if self.name: 215 if self.name:
214 return self.name 216 return self.name
215 if not self.is_file: 217 if not self.is_file:
216 return self.url 218 return self.url
217 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] 219 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file]
218 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) 220 common_prefix = os.path.dirname(os.path.commonprefix(all_urls))
219 return self.url[len(common_prefix):].strip('/') 221 return self.url[len(common_prefix):].strip('/')
OLDNEW
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/page_set_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698