Robot Framework Integrated Development Environment (RIDE)
restsupport.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 robotide.lib.robot.errors import DataError
17 
18 try:
19  from docutils.core import publish_doctree, publish_from_doctree
20  from docutils.parsers.rst.directives import register_directive
21  from docutils.parsers.rst.directives.body import CodeBlock
22 except ImportError:
23  raise DataError("Using reStructuredText test data requires having "
24  "'docutils' module version 0.9 or newer installed.")
25 
26 
27 class CaptureRobotData(CodeBlock):
28 
29  def run(self):
30  if 'robotframework' in self.arguments:
31  store = RobotDataStorage(self.state_machine.document)
32  store.add_data(self.content)
33  return []
34 
35 
36 register_directive('code', CaptureRobotData)
37 register_directive('code-block', CaptureRobotData)
38 register_directive('sourcecode', CaptureRobotData)
39 
40 
42 
43  def __init__(self, doctree):
44  if not hasattr(doctree, '_robot_data'):
45  doctree._robot_data = []
46  self._robot_data_robot_data = doctree._robot_data
47 
48  def add_data(self, rows):
49  self._robot_data_robot_data.extend(rows)
50 
51  def get_data(self):
52  return '\n'.join(self._robot_data_robot_data)
53 
54  def has_data(self):
55  return bool(self._robot_data_robot_data)
Used when variable does not exist.
Definition: errors.py:67