Revert "Expand variables in gclient flattened output."

This reverts commit a32f98e652d5e151f70d571cf046c3d83ae2f486.

Reason for revert:
Doesn't work when there are variables which definition includes other variables, e.g.:

'cros_download_vm': '"{cros_board}" == "amd64_generic"',

Original change's description:
> Expand variables in gclient flattened output.
> 
> Bug: 848990
> Change-Id: I0ad7e4f965973edbc5a335bd30f9cbd7b04abff2
> Reviewed-on: https://chromium-review.googlesource.com/1085996
> Reviewed-by: Michael Moss <mmoss@chromium.org>
> Reviewed-by: Aaron Gable <agable@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=agable@chromium.org,mmoss@chromium.org,ehmaldonado@chromium.org

Change-Id: I7e81000e92aa352e45b420845bb1dcc8572f1962
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 848990
Reviewed-on: https://chromium-review.googlesource.com/1085974
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/gclient_eval.py b/gclient_eval.py
index ae50ee0..5e2fd33 100644
--- a/gclient_eval.py
+++ b/gclient_eval.py
@@ -206,9 +206,9 @@
 }))
 
 
-def _gclient_eval(node_or_string, filename='<unknown>', vars_dict=None):
+def _gclient_eval(node_or_string, vars_dict=None, expand_vars=False,
+                  filename='<unknown>'):
   """Safely evaluates a single expression. Returns the result."""
-  vars_dict = vars_dict or {}
   _allowed_names = {'None': None, 'True': True, 'False': False}
   if isinstance(node_or_string, basestring):
     node_or_string = ast.parse(node_or_string, filename=filename, mode='eval')
@@ -216,6 +216,8 @@
     node_or_string = node_or_string.body
   def _convert(node):
     if isinstance(node, ast.Str):
+      if not expand_vars:
+        return node.s
       try:
         return node.s.format(**vars_dict)
       except KeyError as e:
@@ -252,6 +254,8 @@
         raise ValueError(
             'Var\'s argument must be a variable name (file %r, line %s)' % (
                 filename, getattr(node, 'lineno', '<unknown>')))
+      if not expand_vars:
+        return '{%s}' % arg
       if vars_dict is None:
         raise ValueError(
             'vars must be declared before Var can be used (file %r, line %s)'
@@ -274,7 +278,7 @@
   return _convert(node_or_string)
 
 
-def Exec(content, filename='<unknown>', vars_override=None):
+def Exec(content, expand_vars=True, filename='<unknown>', vars_override=None):
   """Safely execs a set of assignments."""
   def _validate_statement(node, local_scope):
     if not isinstance(node, ast.Assign):
@@ -326,7 +330,7 @@
   vars_dict = {}
   if 'vars' in statements:
     vars_statement = statements['vars']
-    value = _gclient_eval(vars_statement, filename)
+    value = _gclient_eval(vars_statement, None, False, filename)
     local_scope.SetNode('vars', value, vars_statement)
     # Update the parsed vars with the overrides, but only if they are already
     # present (overrides do not introduce new variables).
@@ -338,13 +342,14 @@
         if k in vars_dict})
 
   for name, node in statements.iteritems():
-    value = _gclient_eval(node, filename, vars_dict)
+    value = _gclient_eval(node, vars_dict, expand_vars, filename)
     local_scope.SetNode(name, value, node)
 
   return _GCLIENT_SCHEMA.validate(local_scope)
 
 
-def ExecLegacy(content, filename='<unknown>', vars_override=None):
+def ExecLegacy(content, expand_vars=True, filename='<unknown>',
+               vars_override=None):
   """Executes a DEPS file |content| using exec."""
   local_scope = {}
   global_scope = {'Var': lambda var_name: '{%s}' % var_name}
@@ -355,7 +360,7 @@
   # as "exec a in b, c" (See https://bugs.python.org/issue21591).
   eval(compile(content, filename, 'exec'), global_scope, local_scope)
 
-  if 'vars' not in local_scope:
+  if 'vars' not in local_scope or not expand_vars:
     return local_scope
 
   vars_dict = {}
@@ -450,7 +455,7 @@
     del info_dict['condition']
 
 
-def Parse(content, validate_syntax, filename, vars_override=None):
+def Parse(content, expand_vars, validate_syntax, filename, vars_override=None):
   """Parses DEPS strings.
 
   Executes the Python-like string stored in content, resulting in a Python
@@ -459,6 +464,7 @@
 
   Args:
     content: str. DEPS file stored as a string.
+    expand_vars: bool. Whether variables should be expanded to their values.
     validate_syntax: bool. Whether syntax should be validated using the schema
       defined above.
     filename: str. The name of the DEPS file, or a string describing the source
@@ -471,9 +477,9 @@
     schema above.
   """
   if validate_syntax:
-    result = Exec(content, filename, vars_override)
+    result = Exec(content, expand_vars, filename, vars_override)
   else:
-    result = ExecLegacy(content, filename, vars_override)
+    result = ExecLegacy(content, expand_vars, filename, vars_override)
 
   vars_dict = result.get('vars', {})
   if 'deps' in result: