Source code for robot.variables.variables

#  Copyright 2008-2015 Nokia Networks
#  Copyright 2016-     Robot Framework Foundation
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  See the License for the specific language governing permissions and
#  limitations under the License.

from robot.utils import is_list_like, type_name

from .filesetter import VariableFileSetter
from .finders import VariableFinder
from .replacer import VariableReplacer
from .store import VariableStore
from .tablesetter import VariableTableSetter

[docs]class Variables(object): """Represents a set of variables. Contains methods for replacing variables from list, scalars, and strings. On top of ${scalar}, @{list} and &{dict} variables, these methods handle also %{environment} variables. """ def __init__(self): = VariableStore(self) self._replacer = VariableReplacer(self) self._finder = VariableFinder( def __setitem__(self, name, value):, value) def __getitem__(self, item): return self._finder.find(item) def __contains__(self, name): return name in
[docs] def resolve_delayed(self):
[docs] def replace_list(self, items, replace_until=None, ignore_errors=False): if not is_list_like(items): raise ValueError("'replace_list' requires list-like input, " "got %s." % type_name(items)) return self._replacer.replace_list(items, replace_until, ignore_errors)
[docs] def replace_scalar(self, item, ignore_errors=False): return self._replacer.replace_scalar(item, ignore_errors)
[docs] def replace_string(self, item, custom_unescaper=None, ignore_errors=False): return self._replacer.replace_string(item, custom_unescaper, ignore_errors)
[docs] def set_from_file(self, path_or_variables, args=None, overwrite=False): setter = VariableFileSetter( return setter.set(path_or_variables, args, overwrite)
[docs] def set_from_variable_table(self, variables, overwrite=False): setter = VariableTableSetter( setter.set(variables, overwrite)
[docs] def clear(self):
[docs] def copy(self): variables = Variables() = return variables
[docs] def update(self, variables):
[docs] def as_dict(self, decoration=True): return