| Index: chrome/test/mini_installer/visitor.py
|
| diff --git a/chrome/test/mini_installer/visitor.py b/chrome/test/mini_installer/visitor.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e5de04fa08885ac68a1128f7766cac7a83017d35
|
| --- /dev/null
|
| +++ b/chrome/test/mini_installer/visitor.py
|
| @@ -0,0 +1,31 @@
|
| +# Copyright 2017 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +class Visitor(object):
|
| + """Traverse one property of a state's dict"""
|
| + CONDITION = 'condition'
|
| +
|
| + def __init__(self, variable_expander):
|
| + self._variable_expander = variable_expander
|
| +
|
| + def Traverse(self, property_value):
|
| + for entry_name, entry_value in property_value.iteritems():
|
| + if Visitor.CONDITION in entry_value and not self._EvaluateCondition(
|
| + self._variable_expander.Expand(entry_value[Visitor.CONDITION])):
|
| + continue
|
| + self._VisitEntry(entry_name, entry_value)
|
| +
|
| + def _EvaluateCondition(self, condition):
|
| + """Evaluates |condition| using eval().
|
| +
|
| + Args:
|
| + condition: A condition string.
|
| +
|
| + Returns:
|
| + The result of the evaluated condition.
|
| + """
|
| + return eval(condition, {'__builtins__': {'False': False, 'True': True}})
|
| +
|
| + def _VisitEntry(self, entry_name, entry_value):
|
| + raise NotImplementedError()
|
|
|