21 is_number, is_string, prepr, type_name)
29 self.
assignmentassignment = [validator.validate(var)
for var
in assignment]
31 except DataError
as err:
61 is_dict=variable[0] ==
'&')
66 raise DataError(
"Assign mark '=' can be used only with the last "
68 if variable.endswith(
'='):
70 return variable[:-1].rstrip()
75 raise DataError(
'Assignment can contain only one list variable.')
77 raise DataError(
'Dictionary variable cannot be assigned with '
88 _valid_extended_attr = re.compile(
'^[_a-zA-Z]\w*$')
100 failure = self.
_get_failure_get_failure(exc_type, exc_val, exc_tb)
101 if failure.can_continue(self.
_context_context.in_teardown):
102 self.
assignassign(failure.return_value)
105 if isinstance(exc_val, ExecutionStatus):
107 exc_info = (exc_type, exc_val, exc_tb)
112 context.trace(
lambda:
'Return: %s' %
prepr(return_value))
114 for name, value
in resolver.resolve(return_value):
115 if not self.
_extended_assign_extended_assign(name, value, context.variables):
116 value = self.
_normal_assign_normal_assign(name, value, context.variables)
120 if name[0] !=
'$' or '.' not in name
or name
in variables:
124 var = variables[base]
131 setattr(var, attr, value)
133 raise VariableError(
"Setting attribute '%s' to variable '%s' "
138 base, attr = name.rsplit(
'.', 1)
139 return base.strip() +
'}', attr[:-1].strip()
148 variables[name] = value
150 return value
if name[0] ==
'$' else variables[name]
156 if len(assignment) == 1:
158 if any(a[0] ==
'@' for a
in assignment):
175 if return_value
is None:
177 return_value = {
'$':
None,
'@': [],
'&': {}}[identifier]
178 return [(self.
_variable_variable, return_value)]
189 self.
_validate_validate(len(return_value))
190 return self.
_resolve_resolve(return_value)
193 if return_value
is None:
198 return list(return_value)
203 self.
_raise_raise(
'Expected list-like value, got %s.' %
type_name(ret))
209 raise NotImplementedError
212 raise NotImplementedError
219 self.
_raise_raise(
'Expected %d return values, got %d.'
223 return list(zip(self.
_variables_variables, return_value))
229 _MultiReturnValueResolver.__init__(self, variables)
234 self.
_raise_raise(
'Expected %d or more return values, got %d.'
238 before_vars, list_var, after_vars \
240 before_items, list_items, after_items \
241 = self.
_split_return_split_return(return_value, before_vars, after_vars)
242 before = list(zip(before_vars, before_items))
243 after = list(zip(after_vars, after_items))
244 return before + [(list_var, list_items)] + after
247 list_index = [v[0]
for v
in variables].index(
'@')
248 return (variables[:list_index],
249 variables[list_index],
250 variables[list_index+1:])
253 list_start = len(before_vars)
254 list_end = len(return_value) - len(after_vars)
255 return (return_value[:list_start],
256 return_value[list_start:list_end],
257 return_value[list_end:])
Used when variable does not exist.
Used when no keyword is found or there is more than one match.
def _validate_state(self, is_list, is_dict)
def _validate_assign_mark(self, variable)
def validate(self, variable)
def resolve(self, return_value)
def resolve(self, return_value)
def __init__(self, variable)
def __init__(self, variables)
def _validate(self, return_count)
def _split_return(self, return_value, before_vars, after_vars)
def _resolve(self, return_value)
def _split_variables(self, variables)
def _resolve(self, return_value)
def _validate(self, return_count)
def _split_extended_assign(self, name)
def _get_failure(self, exc_type, exc_val, exc_tb)
def __exit__(self, exc_type, exc_val, exc_tb)
def _normal_assign(self, name, value, variables)
def _is_valid_extended_attribute(self, attr)
def assign(self, return_value)
def _variable_supports_extended_assign(self, var)
def _extended_assign(self, name, value, variables)
def __init__(self, assignment, context)
def validate_assignment(self)
def assigner(self, context)
def __init__(self, assignment)
def _resolve(self, return_value)
def __init__(self, variables)
def _raise_expected_list(self, ret)
def resolve(self, return_value)
def _validate(self, return_count)
def _convert_to_list(self, return_value)
def ErrorDetails(exc_info=None, exclude_robot_traces=EXCLUDE_ROBOT_TRACES)
This factory returns an object that wraps the last occurred exception.
def get_error_message()
Returns error message of the last occurred exception.
def format_assign_message(variable, value, cut_long=True)
def prepr(item, width=80)
def ReturnValueResolver(assignment)