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

Unified Diff: recipe_engine/loader.py

Issue 2628523004: Allow module self-reference in loader (Closed)
Patch Set: typo Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | recipes/example/module_self_ref.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/loader.py
diff --git a/recipe_engine/loader.py b/recipe_engine/loader.py
index e9a2e7b5129683475935b880a7ae4179b1878b54..f3d87f2941fa82a46a031a4b3eb81327f4fb107d 100644
--- a/recipe_engine/loader.py
+++ b/recipe_engine/loader.py
@@ -573,6 +573,11 @@ def create_recipe_api(toplevel_package, toplevel_deps, recipe_script_path,
setattr(mod_api.m, k, v)
setattr(mod_api.test_api.m, k, v.test_api)
+ # It is useful to have module's self-reference under .m . This allows
+ # passing module's API to other objects within that module, still having
+ # access to the module itself, along with all its dependencies.
+ setattr(mod_api.m, mod.NAME, mod_api)
+
# Replace class-level Requirements placeholders in the recipe API with
# their instance-level real values.
map(lambda (k, v): setattr(mod_api, k, _resolve_requirement(v, engine)),
« no previous file with comments | « no previous file | recipes/example/module_self_ref.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698