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

Side by Side Diff: chrome/test/mini_installer/visitor.py

Issue 2747023002: Cleanup machine based on the state in configuration file for mini installer test.
Patch Set: fix gni file Created 3 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
OLDNEW
(Empty)
1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 class Visitor(object):
6 """Traverse one property of a state's dict"""
7 CONDITION = 'condition'
8
9 def __init__(self, variable_expander):
10 self._variable_expander = variable_expander
11
12 def Traverse(self, property_value):
13 for entry_name, entry_value in property_value.iteritems():
14 if Visitor.CONDITION in entry_value and not self._EvaluateCondition(
15 self._variable_expander.Expand(entry_value[Visitor.CONDITION])):
16 continue
17 self._VisitEntry(entry_name, entry_value)
18
19 def _EvaluateCondition(self, condition):
20 """Evaluates |condition| using eval().
21
22 Args:
23 condition: A condition string.
24
25 Returns:
26 The result of the evaluated condition.
27 """
28 return eval(condition, {'__builtins__': {'False': False, 'True': True}})
29
30 def _VisitEntry(self, entry_name, entry_value):
31 raise NotImplementedError()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698