Robot Framework
runkwregister.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 warnings
17 
18 from robot.utils import NormalizedDict
19 
20 
22 
23  def __init__(self):
24  self._libs_libs = {}
25 
26 
57  def register_run_keyword(self, libname, keyword, args_to_process,
58  deprecation_warning=True, dry_run=False):
59  if deprecation_warning:
60  warnings.warn(
61  "The API to register run keyword variants and to disable variable "
62  "resolving in keyword arguments will change in the future. "
63  "For more information see "
64  "https://github.com/robotframework/robotframework/issues/2190. "
65  "Use with `deprecation_warning=False` to avoid this warning.",
66  UserWarning
67  )
68  if libname not in self._libs_libs:
69  self._libs_libs[libname] = NormalizedDict(ignore=['_'])
70  self._libs_libs[libname][keyword] = (int(args_to_process), dry_run)
71 
72  def get_args_to_process(self, libname, kwname):
73  if libname in self._libs_libs and kwname in self._libs_libs[libname]:
74  return self._libs_libs[libname][kwname][0]
75  return -1
76 
77  def get_dry_run(self, libname, kwname):
78  if libname in self._libs_libs and kwname in self._libs_libs[libname]:
79  return self._libs_libs[libname][kwname][1]
80  return False
81 
82  def is_run_keyword(self, libname, kwname):
83  return self.get_args_to_processget_args_to_process(libname, kwname) >= 0
84 
85 
86 RUN_KW_REGISTER = _RunKeywordRegister()
def register_run_keyword(self, libname, keyword, args_to_process, deprecation_warning=True, dry_run=False)
Deprecated API for registering "run keyword variants".
def get_args_to_process(self, libname, kwname)