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

Unified Diff: deps_utils.py

Issue 619133002: deps2git: Add support for overriding DEPS vars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/deps2git/
Patch Set: Changed to var_overrides Created 6 years, 2 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 | « deps2git.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: deps_utils.py
===================================================================
--- deps_utils.py (revision 292133)
+++ deps_utils.py (working copy)
@@ -16,22 +16,26 @@
class VarImpl(object):
"""Implement the Var function used within the DEPS file."""
- def __init__(self, local_scope):
+ def __init__(self, local_scope, var_overrides=None):
self._local_scope = local_scope
+ self._var_overrides = var_overrides or {}
def Lookup(self, var_name):
"""Implements the Var syntax."""
+ if var_name in self._var_overrides:
+ return self._var_overrides[var_name]
if var_name in self._local_scope.get('vars', {}):
return self._local_scope['vars'][var_name]
raise Exception('Var is not defined: %s' % var_name)
-def GetDepsContent(deps_path):
+def GetDepsContent(deps_path, var_overrides=None):
"""Read a DEPS file and return all the sections."""
deps_file = open(deps_path, 'rU')
+ var_overrides = var_overrides or {}
content = deps_file.read()
local_scope = {}
- var = VarImpl(local_scope)
+ var = VarImpl(local_scope, var_overrides)
global_scope = {
'Var': var.Lookup,
'deps': {},
@@ -48,6 +52,7 @@
local_scope.setdefault('skip_child_includes', [])
local_scope.setdefault('hooks', [])
local_scope.setdefault('vars', {})
+ local_scope['vars'].update(var_overrides)
return (local_scope['deps'], local_scope['deps_os'],
local_scope['include_rules'], local_scope['skip_child_includes'],
« no previous file with comments | « deps2git.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698