robot.variables package

Implements storing and resolving variables.

This package is mainly for internal usage, but utilities for finding variables can be used externally as well.

Submodules

robot.variables.assigner module

class robot.variables.assigner.VariableAssignment(assignment)[source]

Bases: object

validate_assignment()[source]
assigner(context)[source]
class robot.variables.assigner.AssignmentValidator[source]

Bases: object

validate(variable)[source]
class robot.variables.assigner.VariableAssigner(assignment, context)[source]

Bases: object

assign(return_value)[source]
robot.variables.assigner.ReturnValueResolver(assignment)[source]
class robot.variables.assigner.NoReturnValueResolver[source]

Bases: object

resolve(return_value)[source]
class robot.variables.assigner.OneReturnValueResolver(assignment)[source]

Bases: object

resolve(return_value)[source]
class robot.variables.assigner.ScalarsOnlyReturnValueResolver(assignments)[source]

Bases: _MultiReturnValueResolver

class robot.variables.assigner.ScalarsAndListReturnValueResolver(assignments)[source]

Bases: _MultiReturnValueResolver

robot.variables.evaluation module

robot.variables.evaluation.evaluate_expression(expression, variables, modules=None, namespace=None, resolve_variables=False)[source]
class robot.variables.evaluation.EvaluationNamespace(variable_store, namespace)[source]

Bases: MutableMapping

robot.variables.filesetter module

class robot.variables.filesetter.VariableFileSetter(store: VariableStore)[source]

Bases: object

set(path_or_variables, args=None, overwrite=False)[source]
class robot.variables.filesetter.PythonImporter[source]

Bases: object

import_variables(path, args=None)[source]
class robot.variables.filesetter.JsonImporter[source]

Bases: object

import_variables(path, args=None)[source]
class robot.variables.filesetter.YamlImporter[source]

Bases: object

import_variables(path, args=None)[source]

robot.variables.finders module

class robot.variables.finders.VariableFinder(variables)[source]

Bases: object

find(variable)[source]
class robot.variables.finders.StoredFinder(store)[source]

Bases: object

identifiers = '$@&'
find(name)[source]
class robot.variables.finders.NumberFinder[source]

Bases: object

identifiers = '$'
find(name)[source]
class robot.variables.finders.EmptyFinder[source]

Bases: object

identifiers = '$@&'
empty = NormalizedDict({'${EMPTY}': '', '&{EMPTY}': {}, '@{EMPTY}': ()})
find(name)[source]
class robot.variables.finders.InlinePythonFinder(variables)[source]

Bases: object

identifiers = '$@&'
find(name)[source]
class robot.variables.finders.ExtendedFinder(finder)[source]

Bases: object

identifiers = '$@&'
find(name)[source]
class robot.variables.finders.EnvironmentFinder[source]

Bases: object

identifiers = '%'
find(name)[source]

robot.variables.notfound module

robot.variables.notfound.variable_not_found(name, candidates, message=None, deco_braces=True)[source]

Raise DataError for missing variable name.

Return recommendations for similar variable names if any are found.

robot.variables.replacer module

class robot.variables.replacer.VariableReplacer(variables)[source]

Bases: object

replace_list(items, replace_until=None, ignore_errors=False)[source]

Replaces variables from a list of items.

If an item in a list is a @{list} variable its value is returned. Possible variables from other items are replaced using ‘replace_scalar’. Result is always a list.

‘replace_until’ can be used to limit replacing arguments to certain index from the beginning. Used with Run Keyword variants that only want to resolve some arguments in the beginning and pass others to called keywords unmodified.

replace_scalar(item, ignore_errors=False)[source]

Replaces variables from a scalar item.

If the item is not a string it is returned as is. If it is a variable, its value is returned. Otherwise, possible variables are replaced with ‘replace_string’. Result may be any object.

replace_string(item, custom_unescaper=None, ignore_errors=False)[source]

Replaces variables from a string. Result is always a string.

Input can also be an already found VariableMatch.

robot.variables.resolvable module

class robot.variables.resolvable.Resolvable[source]

Bases: object

resolve(variables)[source]
report_error(error)[source]
class robot.variables.resolvable.GlobalVariableValue(value)[source]

Bases: Resolvable

resolve(variables)[source]

robot.variables.scopes module

class robot.variables.scopes.VariableScopes(settings)[source]

Bases: object

property current
start_suite()[source]
end_suite()[source]
start_test()[source]
end_test()[source]
start_keyword()[source]
end_keyword()[source]
replace_list(items, replace_until=None, ignore_errors=False)[source]
replace_scalar(items, ignore_errors=False)[source]
replace_string(string, custom_unescaper=None, ignore_errors=False)[source]
set_from_file(path, args, overwrite=False)[source]
set_from_variable_section(variables, overwrite=False)[source]
resolve_delayed()[source]
set_global(name, value)[source]
set_suite(name, value, top=False, children=False)[source]
set_test(name, value)[source]
set_keyword(name, value)[source]
set_local(name, value)[source]
as_dict(decoration=True)[source]
class robot.variables.scopes.GlobalVariables(settings)[source]

Bases: Variables

class robot.variables.scopes.SetVariables[source]

Bases: object

start_suite()[source]
end_suite()[source]
start_test()[source]
end_test()[source]
start_keyword()[source]
end_keyword()[source]
set_global(name, value)[source]
set_suite(name, value, children=False)[source]
set_test(name, value)[source]
set_keyword(name, value)[source]
update(variables)[source]

robot.variables.search module

robot.variables.search.search_variable(string: str, identifiers: Sequence[str] = '$@&%*', ignore_errors: bool = False) VariableMatch[source]
robot.variables.search.contains_variable(string: str, identifiers: Sequence[str] = '$@&') bool[source]
robot.variables.search.is_variable(string: str, identifiers: Sequence[str] = '$@&') bool[source]
robot.variables.search.is_scalar_variable(string: str) bool[source]
robot.variables.search.is_list_variable(string: str) bool[source]
robot.variables.search.is_dict_variable(string: str) bool[source]
robot.variables.search.is_assign(string: str, identifiers: Sequence[str] = '$@&', allow_assign_mark: bool = False, allow_nested: bool = False, allow_items: bool = False) bool[source]
robot.variables.search.is_scalar_assign(string: str, allow_assign_mark: bool = False, allow_nested: bool = False, allow_items: bool = False) bool[source]
robot.variables.search.is_list_assign(string: str, allow_assign_mark: bool = False, allow_nested: bool = False, allow_items: bool = False) bool[source]
robot.variables.search.is_dict_assign(string: str, allow_assign_mark: bool = False, allow_nested: bool = False, allow_items: bool = False) bool[source]
class robot.variables.search.VariableMatch(string: str, identifier: str | None = None, base: str | None = None, items: tuple[str, ...] = (), start: int = -1, end: int = -1)[source]

Bases: object

resolve_base(variables, ignore_errors=False)[source]
property name: str | None
property before: str
property match: str | None
property after: str
is_variable() bool[source]
is_scalar_variable() bool[source]
is_list_variable() bool[source]
is_dict_variable() bool[source]
is_assign(allow_assign_mark: bool = False, allow_nested: bool = False, allow_items: bool = False) bool[source]
is_scalar_assign(allow_assign_mark: bool = False, allow_nested: bool = False) bool[source]
is_list_assign(allow_assign_mark: bool = False, allow_nested: bool = False) bool[source]
is_dict_assign(allow_assign_mark: bool = False, allow_nested: bool = False) bool[source]
robot.variables.search.unescape_variable_syntax(item)[source]
class robot.variables.search.VariableMatches(string: str, identifiers: Sequence[str] = '$@&%', ignore_errors: bool = False)[source]

Bases: object

robot.variables.store module

class robot.variables.store.VariableStore(variables)[source]

Bases: object

resolve_delayed(item=None)[source]
get(name, default=, decorated=True)[source]
update(store)[source]
clear()[source]
add(name, value, overwrite=True, decorated=True)[source]
as_dict(decoration=True)[source]

robot.variables.tablesetter module

class robot.variables.tablesetter.VariableTableSetter(store: VariableStore)[source]

Bases: object

set(variables: Sequence[Variable], overwrite: bool = False)[source]
class robot.variables.tablesetter.VariableResolver(value: Sequence[str], error_reporter=None)[source]

Bases: Resolvable

classmethod from_name_and_value(name: str, value: str | Sequence[str], separator: str | None = None, error_reporter=None) VariableResolver[source]
classmethod from_variable(var: Var | Variable) VariableResolver[source]
resolve(variables)[source]
report_error(error)[source]
class robot.variables.tablesetter.ScalarVariableResolver(value: str | Sequence[str], separator: str | None = None, error_reporter=None)[source]

Bases: VariableResolver

class robot.variables.tablesetter.ListVariableResolver(value: Sequence[str], error_reporter=None)[source]

Bases: VariableResolver

class robot.variables.tablesetter.DictVariableResolver(value: Sequence[str], error_reporter=None)[source]

Bases: VariableResolver

robot.variables.variables module

class robot.variables.variables.Variables[source]

Bases: 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.

resolve_delayed()[source]
replace_list(items, replace_until=None, ignore_errors=False)[source]
replace_scalar(item, ignore_errors=False)[source]
replace_string(item, custom_unescaper=None, ignore_errors=False)[source]
set_from_file(path_or_variables, args=None, overwrite=False)[source]
set_from_variable_section(variables, overwrite=False)[source]
clear()[source]
copy()[source]
update(variables)[source]
as_dict(decoration=True)[source]