OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 os | 4 import os |
| 5 import urlparse |
5 | 6 |
6 # NOTE: This assumes the page_set file uses 'file:///' instead of 'file://', | 7 # NOTE: This assumes the page_set file uses 'file:///' instead of 'file://', |
7 # otherwise the '/' will be missing between page_set.base_dir and | 8 # otherwise the '/' will be missing between page_set.base_dir and |
8 # parsed_url.path. | 9 # parsed_url.path. |
9 def GetUrlBaseDirAndFile(page_set_base_dir, parsed_url): | 10 def GetUrlBaseDirAndFile(page, page_set_base_dir, parsed_url): |
10 # Don't use os.path.join otherwise netloc and path can't point to relative | 11 # Don't use os.path.join otherwise netloc and path can't point to relative |
11 # directories. | 12 # directories. |
12 assert parsed_url.path[0] == '/' | 13 assert parsed_url.path[0] == '/' |
13 | 14 |
14 path = (page_set_base_dir + | 15 path = (page_set_base_dir + |
15 parsed_url.netloc + | 16 parsed_url.netloc + |
16 parsed_url.path) # pylint: disable=E1101 | 17 parsed_url.path) # pylint: disable=E1101 |
17 | 18 |
| 19 if hasattr(page, 'url_base_dir'): |
| 20 parsed_url = urlparse.urlparse(page.url_base_dir) |
| 21 base_path = (page_set_base_dir + parsed_url.netloc + parsed_url.path) |
| 22 return (base_path, path.replace(base_path, '')) |
| 23 |
18 return os.path.split(path) | 24 return os.path.split(path) |
OLD | NEW |