Robot Framework
deco.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 import inspect
17 
18 
19 
36 def not_keyword(func):
37  func.robot_not_keyword = True
38  return func
39 
40 
41 not_keyword.robot_not_keyword = True
42 
43 
44 @not_keyword
45 
86 def keyword(name=None, tags=(), types=()):
87  if inspect.isroutine(name):
88  return keyword()(name)
89 
90  def decorator(func):
91  func.robot_name = name
92  func.robot_tags = tags
93  func.robot_types = types
94  return func
95 
96  return decorator
97 
98 
99 @not_keyword
100 
136 def library(scope=None, version=None, converters=None, doc_format=None, listener=None,
137  auto_keywords=False):
138  if inspect.isclass(scope):
139  return library()(scope)
140 
141  def decorator(cls):
142  if scope is not None:
143  cls.ROBOT_LIBRARY_SCOPE = scope
144  if version is not None:
145  cls.ROBOT_LIBRARY_VERSION = version
146  if converters is not None:
147  cls.ROBOT_LIBRARY_CONVERTERS = converters
148  if doc_format is not None:
149  cls.ROBOT_LIBRARY_DOC_FORMAT = doc_format
150  if listener is not None:
151  cls.ROBOT_LIBRARY_LISTENER = listener
152  cls.ROBOT_AUTO_KEYWORDS = auto_keywords
153  return cls
154 
155  return decorator
def library(scope=None, version=None, converters=None, doc_format=None, listener=None, auto_keywords=False)
Class decorator to control keyword discovery and other library settings.
Definition: deco.py:137
def keyword(name=None, tags=(), types=())
Decorator to set custom name, tags and argument types to keywords.
Definition: deco.py:86
def not_keyword(func)
Decorator to disable exposing functions or methods as keywords.
Definition: deco.py:36