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

Side by Side Diff: scripts/slave/recipe_api.py

Issue 187203005: Minor cleanup of some recipe framework code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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 from .recipe_test_api import DisabledTestData, ModuleTestData 5 from .recipe_test_api import DisabledTestData, ModuleTestData
6 6
7 from .recipe_util import ModuleInjectionSite 7 from .recipe_util import ModuleInjectionSite
8 8
9 9
10 class RecipeApi(ModuleInjectionSite): 10 class RecipeApi(ModuleInjectionSite):
11 """ 11 """
12 Framework class for handling recipe_modules. 12 Framework class for handling recipe_modules.
13 13
14 Inherit from this in your recipe_modules/<name>/api.py . This class provides 14 Inherit from this in your recipe_modules/<name>/api.py . This class provides
15 wiring for your config context (in self.c and methods, and for dependency 15 wiring for your config context (in self.c and methods, and for dependency
16 injection (in self.m). 16 injection (in self.m).
17 17
18 Dependency injection takes place in load_recipe_modules() below. 18 Dependency injection takes place in load_recipe_modules() in recipe_loader.py.
19 """ 19 """
20 def __init__(self, module=None, test_data=DisabledTestData(), **_kwargs): 20 def __init__(self, module=None, test_data=DisabledTestData(), **_kwargs):
21 """Note: Injected dependencies are NOT available in __init__().""" 21 """Note: Injected dependencies are NOT available in __init__()."""
22 super(RecipeApi, self).__init__() 22 super(RecipeApi, self).__init__()
23 23
24 self.c = None 24 self.c = None
25 self._module = module 25 self._module = module
26 26
27 assert isinstance(test_data, (ModuleTestData, DisabledTestData)) 27 assert isinstance(test_data, (ModuleTestData, DisabledTestData))
28 self._test_data = test_data 28 self._test_data = test_data
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 for dep in self._module.DEPS: 100 for dep in self._module.DEPS:
101 getattr(self.m, dep).set_config(config_name, optional=True, **params) 101 getattr(self.m, dep).set_config(config_name, optional=True, **params)
102 102
103 def apply_config(self, config_name, config_object=None): 103 def apply_config(self, config_name, config_object=None):
104 """Apply a named configuration to the provided config object or self.""" 104 """Apply a named configuration to the provided config object or self."""
105 self._module.CONFIG_CTX.CONFIG_ITEMS[config_name](config_object or self.c) 105 self._module.CONFIG_CTX.CONFIG_ITEMS[config_name](config_object or self.c)
106 106
107 @property 107 @property
108 def name(self): 108 def name(self):
109 return self._module.NAME 109 return self._module.NAME
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698