| 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 contextlib | 5 import contextlib |
| 6 import types | 6 import types |
| 7 | 7 |
| 8 from functools import wraps | 8 from functools import wraps |
| 9 | 9 |
| 10 from .recipe_test_api import DisabledTestData, ModuleTestData | 10 from .recipe_test_api import DisabledTestData, ModuleTestData |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 """Sets the modules and its dependencies to the named configuration.""" | 364 """Sets the modules and its dependencies to the named configuration.""" |
| 365 assert self._module | 365 assert self._module |
| 366 config, params = self.make_config_params(config_name, optional, | 366 config, params = self.make_config_params(config_name, optional, |
| 367 **CONFIG_VARS) | 367 **CONFIG_VARS) |
| 368 if config: | 368 if config: |
| 369 self.c = config | 369 self.c = config |
| 370 | 370 |
| 371 if include_deps: | 371 if include_deps: |
| 372 # TODO(iannucci): This is 'inefficient', since if a dep comes up multiple | 372 # TODO(iannucci): This is 'inefficient', since if a dep comes up multiple |
| 373 # times in this recursion, it will get set_config()'d multiple times | 373 # times in this recursion, it will get set_config()'d multiple times |
| 374 for dep in self._module.DEPS: | 374 for dep in self._module.LOADED_DEPS: |
| 375 getattr(self.m, dep).set_config(config_name, optional=True, **params) | 375 getattr(self.m, dep).set_config(config_name, optional=True, **params) |
| 376 | 376 |
| 377 def apply_config(self, config_name, config_object=None): | 377 def apply_config(self, config_name, config_object=None): |
| 378 """Apply a named configuration to the provided config object or self.""" | 378 """Apply a named configuration to the provided config object or self.""" |
| 379 self._module.CONFIG_CTX.CONFIG_ITEMS[config_name](config_object or self.c) | 379 self._module.CONFIG_CTX.CONFIG_ITEMS[config_name](config_object or self.c) |
| 380 | 380 |
| 381 def resource(self, *path): | 381 def resource(self, *path): |
| 382 """Returns path to a file under <recipe module>/resources/ directory. | 382 """Returns path to a file under <recipe module>/resources/ directory. |
| 383 | 383 |
| 384 Args: | 384 Args: |
| 385 path: path relative to module's resources/ directory. | 385 path: path relative to module's resources/ directory. |
| 386 """ | 386 """ |
| 387 # TODO(vadimsh): Verify that file exists. Including a case like: | 387 # TODO(vadimsh): Verify that file exists. Including a case like: |
| 388 # module.resource('dir').join('subdir', 'file.py') | 388 # module.resource('dir').join('subdir', 'file.py') |
| 389 return self._module.MODULE_DIRECTORY.join('resources', *path) | 389 return self._module.MODULE_DIRECTORY.join('resources', *path) |
| 390 | 390 |
| 391 @property | 391 @property |
| 392 def name(self): | 392 def name(self): |
| 393 return self._module.NAME | 393 return self._module.NAME |
| 394 | 394 |
| 395 | 395 |
| 396 class RecipeApi(RecipeApiPlain): | 396 class RecipeApi(RecipeApiPlain): |
| 397 __metaclass__ = RecipeApiMeta | 397 __metaclass__ = RecipeApiMeta |
| OLD | NEW |