Robot Framework Integrated Development Environment (RIDE)
variablefetcher.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from .. import robotapi
17 
18 # NOTE! This is in own module to reduce the number of dependencies as this is executed in another process
19 
20 
21 def import_varfile(varfile_path, args):
22  temp = robotapi.RobotVariables()
23  try:
24  temp.set_from_file(varfile_path, args)
25  except SystemExit:
26  raise robotapi.DataError('Variable file import failed')
27  return [(name, _format_value(value), varfile_path)
28  for (name, value) in temp.store.data.items()]
29 
30 
31 # Must be picklable
32 def _format_value(value):
33  if isinstance(value, str):
34  return value
35  if isinstance(value, list):
36  return u'[ %s ]' % u' | '.join(str(v) for v in value)
37  return str(value)
Used when variable does not exist.
Definition: errors.py:67
def import_varfile(varfile_path, args)