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

Side by Side Diff: recipe_engine/loader.py

Issue 1923363003: recipe engine: add a hook for initializing recipe module with injected deps (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: presubmit Created 4 years, 7 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 | recipe_engine/recipe_api.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 2013-2015 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 collections 5 import collections
6 import contextlib 6 import contextlib
7 import imp 7 import imp
8 import inspect 8 import inspect
9 import os 9 import os
10 import sys 10 import sys
11 11
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 'test_data': test_data.get_module_test_data(mod.NAME) 521 'test_data': test_data.get_module_test_data(mod.NAME)
522 } 522 }
523 prop_defs = mod.PROPERTIES 523 prop_defs = mod.PROPERTIES
524 mod_api = invoke_with_properties( 524 mod_api = invoke_with_properties(
525 mod.API, engine.properties, prop_defs, **kwargs) 525 mod.API, engine.properties, prop_defs, **kwargs)
526 mod_api.test_api = (getattr(mod, 'TEST_API', None) 526 mod_api.test_api = (getattr(mod, 'TEST_API', None)
527 or RecipeTestApi)(module=mod) 527 or RecipeTestApi)(module=mod)
528 for k, v in deps.iteritems(): 528 for k, v in deps.iteritems():
529 setattr(mod_api.m, k, v) 529 setattr(mod_api.m, k, v)
530 setattr(mod_api.test_api.m, k, v.test_api) 530 setattr(mod_api.test_api.m, k, v.test_api)
531 mod_api.initialize()
531 return mod_api 532 return mod_api
532 533
533 mapper = DependencyMapper(instantiator) 534 mapper = DependencyMapper(instantiator)
534 api = RecipeScriptApi(module=None, engine=engine, 535 api = RecipeScriptApi(module=None, engine=engine,
535 test_data=test_data.get_module_test_data(None)) 536 test_data=test_data.get_module_test_data(None))
536 for k, v in toplevel_deps.iteritems(): 537 for k, v in toplevel_deps.iteritems():
537 setattr(api, k, mapper.instantiate(v)) 538 setattr(api, k, mapper.instantiate(v))
538 return api 539 return api
539 540
540 541
541 def create_test_api(toplevel_deps, universe): 542 def create_test_api(toplevel_deps, universe):
542 def instantiator(mod, deps): 543 def instantiator(mod, deps):
543 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod) 544 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod)
544 for k,v in deps.iteritems(): 545 for k,v in deps.iteritems():
545 setattr(modapi.m, k, v) 546 setattr(modapi.m, k, v)
546 return modapi 547 return modapi
547 548
548 mapper = DependencyMapper(instantiator) 549 mapper = DependencyMapper(instantiator)
549 api = RecipeTestApi(module=None) 550 api = RecipeTestApi(module=None)
550 for k,v in toplevel_deps.iteritems(): 551 for k,v in toplevel_deps.iteritems():
551 setattr(api, k, mapper.instantiate(v)) 552 setattr(api, k, mapper.instantiate(v))
552 return api 553 return api
OLDNEW
« no previous file with comments | « no previous file | recipe_engine/recipe_api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698