| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 os | 5 import os |
| 6 import functools | 6 import functools |
| 7 | 7 |
| 8 from slave import recipe_api | 8 from slave import recipe_api |
| 9 from slave import recipe_config_types | 9 from slave import recipe_config_types |
| 10 | 10 |
| 11 | 11 |
| 12 def PathTostring(api, test): | 12 def PathTostring(api, test): |
| 13 def PathTostring_inner(path): | 13 def PathTostring_inner(path): |
| 14 assert isinstance(path, recipe_config_types.Path) | 14 assert isinstance(path, recipe_config_types.Path) |
| 15 base_path = None | 15 base_path = None |
| 16 suffix = path.platform_ext.get(api.m.platform.name, '') | 16 suffix = path.platform_ext.get(api.m.platform.name, '') |
| 17 if path.base in api.c.dynamic_paths: | 17 if path.base in api.c.dynamic_paths: |
| 18 base_path = api.c.dynamic_paths[path.base] | 18 base_path = api.c.dynamic_paths[path.base] |
| 19 elif path.base in api.c.base_paths: | 19 elif path.base in api.c.base_paths: |
| 20 if test.enabled: | 20 if test.enabled: |
| 21 # TODO(iannucci): Remove special case in followup cl | 21 base_path = '[%s]' % path.base.upper() |
| 22 if path.base == 'root': | |
| 23 base_path = '[ROOT]' | |
| 24 else: | |
| 25 base_path = '[%s_ROOT]' % path.base.upper() | |
| 26 else: # pragma: no cover | 22 else: # pragma: no cover |
| 27 base_path = api.join(*api.c.base_paths[path.base]) | 23 base_path = api.join(*api.c.base_paths[path.base]) |
| 28 assert base_path, 'Could not get base %r for path' % path.base | 24 assert base_path, 'Could not get base %r for path' % path.base |
| 29 return api.join(base_path, *path.pieces) + suffix | 25 return api.join(base_path, *path.pieces) + suffix |
| 30 return PathTostring_inner | 26 return PathTostring_inner |
| 31 | 27 |
| 32 | 28 |
| 33 def string_filter(func): | 29 def string_filter(func): |
| 34 @functools.wraps(func) | 30 @functools.wraps(func) |
| 35 def inner(*args, **kwargs): | 31 def inner(*args, **kwargs): |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if name in self.OK_ATTRS: | 195 if name in self.OK_ATTRS: |
| 200 return getattr(self._path_mod, name) | 196 return getattr(self._path_mod, name) |
| 201 if name in self.FILTER_METHODS: | 197 if name in self.FILTER_METHODS: |
| 202 return string_filter(getattr(self._path_mod, name)) | 198 return string_filter(getattr(self._path_mod, name)) |
| 203 raise AttributeError("'%s' object has no attribute '%s'" % | 199 raise AttributeError("'%s' object has no attribute '%s'" % |
| 204 (self._path_mod, name)) # pragma: no cover | 200 (self._path_mod, name)) # pragma: no cover |
| 205 | 201 |
| 206 def __dir__(self): # pragma: no cover | 202 def __dir__(self): # pragma: no cover |
| 207 # Used for helping out show_me_the_modules.py | 203 # Used for helping out show_me_the_modules.py |
| 208 return self.__dict__.keys() + list(self.OK_METHODS) | 204 return self.__dict__.keys() + list(self.OK_METHODS) |
| OLD | NEW |