summaryrefslogtreecommitdiffstats
path: root/robotframework-onap/ONAPLibrary
diff options
context:
space:
mode:
authorDR695H <dr695h@att.com>2019-08-28 10:52:51 -0400
committerDR695H <dr695h@att.com>2019-08-28 11:21:56 -0400
commitf2b75da8dd38077c60cc2c852f73092980c1f906 (patch)
treef58fc4de4f54eec45e10717fabcb62d7cbe64182 /robotframework-onap/ONAPLibrary
parent566c583bbfe0b5a4e46af7ac53765a1340d11fc0 (diff)
fix linter errors and copyright
Change-Id: Idf7384307623c70a9f7714a5d276f404873c5974 Issue-ID: TEST-198 Signed-off-by: DR695H <dr695h@att.com>
Diffstat (limited to 'robotframework-onap/ONAPLibrary')
-rw-r--r--robotframework-onap/ONAPLibrary/AAI.py2
-rw-r--r--robotframework-onap/ONAPLibrary/Base64Keywords.py14
-rw-r--r--robotframework-onap/ONAPLibrary/CLAMP.py2
-rw-r--r--robotframework-onap/ONAPLibrary/DNSKeywords.py14
-rw-r--r--robotframework-onap/ONAPLibrary/HEATKeywords.py8
-rw-r--r--robotframework-onap/ONAPLibrary/JSON.py2
-rw-r--r--robotframework-onap/ONAPLibrary/JSONKeywords.py7
-rw-r--r--robotframework-onap/ONAPLibrary/JSONPathKeywords.py5
-rw-r--r--robotframework-onap/ONAPLibrary/Kafka.py2
-rw-r--r--robotframework-onap/ONAPLibrary/KafkaKeywords.py8
-rw-r--r--robotframework-onap/ONAPLibrary/MUSIC.py2
-rw-r--r--robotframework-onap/ONAPLibrary/OOF.py2
-rw-r--r--robotframework-onap/ONAPLibrary/Openstack.py2
-rw-r--r--robotframework-onap/ONAPLibrary/PreloadData.py2
-rw-r--r--robotframework-onap/ONAPLibrary/Protobuf.py2
-rw-r--r--robotframework-onap/ONAPLibrary/RequestsDecorators.py17
-rw-r--r--robotframework-onap/ONAPLibrary/SDC.py2
-rw-r--r--robotframework-onap/ONAPLibrary/SDNC.py2
-rw-r--r--robotframework-onap/ONAPLibrary/SO.py2
-rw-r--r--robotframework-onap/ONAPLibrary/ServiceMapping.py2
-rw-r--r--robotframework-onap/ONAPLibrary/SocketKeywords.py17
-rw-r--r--robotframework-onap/ONAPLibrary/Templating.py2
-rw-r--r--robotframework-onap/ONAPLibrary/Utilities.py2
-rw-r--r--robotframework-onap/ONAPLibrary/robotlibcore.py148
24 files changed, 90 insertions, 178 deletions
diff --git a/robotframework-onap/ONAPLibrary/AAI.py b/robotframework-onap/ONAPLibrary/AAI.py
index 4ad1328..49047f5 100644
--- a/robotframework-onap/ONAPLibrary/AAI.py
+++ b/robotframework-onap/ONAPLibrary/AAI.py
@@ -13,7 +13,7 @@
# limitations under the License.
from ONAPLibrary.BaseAAIKeywords import BaseAAIKeywords
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
class AAI(HybridCore):
diff --git a/robotframework-onap/ONAPLibrary/Base64Keywords.py b/robotframework-onap/ONAPLibrary/Base64Keywords.py
index 11cc69c..9fcbe3e 100644
--- a/robotframework-onap/ONAPLibrary/Base64Keywords.py
+++ b/robotframework-onap/ONAPLibrary/Base64Keywords.py
@@ -1,3 +1,17 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from robot.api.deco import keyword
import base64
diff --git a/robotframework-onap/ONAPLibrary/CLAMP.py b/robotframework-onap/ONAPLibrary/CLAMP.py
index 64361ba..96681f5 100644
--- a/robotframework-onap/ONAPLibrary/CLAMP.py
+++ b/robotframework-onap/ONAPLibrary/CLAMP.py
@@ -13,7 +13,7 @@
# limitations under the License.
from ONAPLibrary.BaseCLAMPKeywords import BaseCLAMPKeywords
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
class CLAMP(HybridCore):
diff --git a/robotframework-onap/ONAPLibrary/DNSKeywords.py b/robotframework-onap/ONAPLibrary/DNSKeywords.py
index 8f4e2f3..6eda742 100644
--- a/robotframework-onap/ONAPLibrary/DNSKeywords.py
+++ b/robotframework-onap/ONAPLibrary/DNSKeywords.py
@@ -1,3 +1,17 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
import dns.message
import dns.name
import dns.query
diff --git a/robotframework-onap/ONAPLibrary/HEATKeywords.py b/robotframework-onap/ONAPLibrary/HEATKeywords.py
index 020d24b..7f47bf9 100644
--- a/robotframework-onap/ONAPLibrary/HEATKeywords.py
+++ b/robotframework-onap/ONAPLibrary/HEATKeywords.py
@@ -21,7 +21,7 @@ import copy
from hashlib import md5
from paramiko import RSAKey
from paramiko.ssh_exception import PasswordRequiredException
-
+from six import string_types
from ONAPLibrary.Utilities import Utilities
@@ -38,7 +38,7 @@ class HEATKeywords(object):
def get_yaml(self, template_file):
"""Template Yaml To Json reads a YAML Heat template file returns a JSON string that can be used included
in an Openstack Add Stack Request"""
- if isinstance(template_file, str) or isinstance(template_file, unicode):
+ if isinstance(template_file, string_types):
fin = open(template_file, 'r')
yamlobj = yaml.load(fin)
return yamlobj
@@ -49,7 +49,7 @@ class HEATKeywords(object):
"""Template Yaml To Json reads a YAML Heat template file returns a JSON string that can be used included
in an Openstack Add Stack Request"""
contents = None
- if isinstance(template_file, str) or isinstance(template_file, unicode):
+ if isinstance(template_file, string_types):
fin = open(template_file, 'r')
yamlobj = yaml.load(fin)
fin.close()
@@ -66,7 +66,7 @@ class HEATKeywords(object):
def env_yaml_to_json(self, template_file):
"""Env Yaml To JSon reads a YAML Heat env file and returns a JSON string that can be used included
in an Openstack Add Stack Request"""
- if isinstance(template_file, str) or isinstance(template_file, unicode):
+ if isinstance(template_file, string_types):
fin = open(template_file, 'r')
yamlobj = yaml.load(fin)
fin.close()
diff --git a/robotframework-onap/ONAPLibrary/JSON.py b/robotframework-onap/ONAPLibrary/JSON.py
index b3ef653..8aec3e6 100644
--- a/robotframework-onap/ONAPLibrary/JSON.py
+++ b/robotframework-onap/ONAPLibrary/JSON.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.JSONKeywords import JSONKeywords
from ONAPLibrary.JSONPathKeywords import JSONPathKeywords
diff --git a/robotframework-onap/ONAPLibrary/JSONKeywords.py b/robotframework-onap/ONAPLibrary/JSONKeywords.py
index e007e6c..5b9e24e 100644
--- a/robotframework-onap/ONAPLibrary/JSONKeywords.py
+++ b/robotframework-onap/ONAPLibrary/JSONKeywords.py
@@ -11,10 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
+import json
from robot.api.deco import keyword
from deepdiff import DeepDiff
+from six import string_types
class JSONKeywords(object):
@@ -28,11 +29,11 @@ class JSONKeywords(object):
def json_equals(self, left, right):
"""JSON Equals takes in two strings or json objects, converts them into json if needed and then compares them,
returning if they are equal or not."""
- if isinstance(left, str) or isinstance(left, unicode):
+ if isinstance(left, string_types):
left_json = json.loads(left)
else:
left_json = left
- if isinstance(right, str) or isinstance(right, unicode):
+ if isinstance(right, string_types):
right_json = json.loads(right)
else:
right_json = right
diff --git a/robotframework-onap/ONAPLibrary/JSONPathKeywords.py b/robotframework-onap/ONAPLibrary/JSONPathKeywords.py
index 22e5e04..d5ed23a 100644
--- a/robotframework-onap/ONAPLibrary/JSONPathKeywords.py
+++ b/robotframework-onap/ONAPLibrary/JSONPathKeywords.py
@@ -11,8 +11,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-import json
+import json
+from six import string_types
from robot.api.deco import keyword
from jsonpath_rw import parse
@@ -30,7 +31,7 @@ class JSONPathKeywords(object):
which is converted into string if needed and then compares them, returning the matches."""
jsonpath_expr = parse(expression)
- if isinstance(target, str) or isinstance(target, unicode):
+ if isinstance(target, string_types):
search_json = json.dumps(target)
else:
search_json = target
diff --git a/robotframework-onap/ONAPLibrary/Kafka.py b/robotframework-onap/ONAPLibrary/Kafka.py
index e089531..d2d1847 100644
--- a/robotframework-onap/ONAPLibrary/Kafka.py
+++ b/robotframework-onap/ONAPLibrary/Kafka.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.KafkaKeywords import KafkaKeywords
diff --git a/robotframework-onap/ONAPLibrary/KafkaKeywords.py b/robotframework-onap/ONAPLibrary/KafkaKeywords.py
index 6cdf85f..44ffb49 100644
--- a/robotframework-onap/ONAPLibrary/KafkaKeywords.py
+++ b/robotframework-onap/ONAPLibrary/KafkaKeywords.py
@@ -96,14 +96,14 @@ class KafkaKeywords(object):
partitions = []
for val in partition_set:
partitions.append(TopicPartition(str(topic_name), val))
- consumer.assign(partitions)
- last = consumer.end_offsets(partitions)
- offset = max(last.values())
+ consumer.assign(partitions)
+ last = consumer.end_offsets(partitions)
+ offset = max(last.values())
if set_offset_to_earliest:
consumer.seek_to_beginning()
else:
for tp in partitions:
- consumer.seek(tp, offset - 1)
+ consumer.seek(tp, offset - 1)
return consumer
diff --git a/robotframework-onap/ONAPLibrary/MUSIC.py b/robotframework-onap/ONAPLibrary/MUSIC.py
index 88eb405..ce02bc4 100644
--- a/robotframework-onap/ONAPLibrary/MUSIC.py
+++ b/robotframework-onap/ONAPLibrary/MUSIC.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.MUSICKeywords import MUSICKeywords
diff --git a/robotframework-onap/ONAPLibrary/OOF.py b/robotframework-onap/ONAPLibrary/OOF.py
index 34b93ea..b61e260 100644
--- a/robotframework-onap/ONAPLibrary/OOF.py
+++ b/robotframework-onap/ONAPLibrary/OOF.py
@@ -13,7 +13,7 @@
# limitations under the License.
from ONAPLibrary.SNIROKeywords import SNIROKeywords
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
class OOF(HybridCore):
diff --git a/robotframework-onap/ONAPLibrary/Openstack.py b/robotframework-onap/ONAPLibrary/Openstack.py
index b8861b2..b53441e 100644
--- a/robotframework-onap/ONAPLibrary/Openstack.py
+++ b/robotframework-onap/ONAPLibrary/Openstack.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.BaseOpenstackKeywords import BaseOpenstackKeywords
from ONAPLibrary.HEATKeywords import HEATKeywords
diff --git a/robotframework-onap/ONAPLibrary/PreloadData.py b/robotframework-onap/ONAPLibrary/PreloadData.py
index 4d24078..0ffd134 100644
--- a/robotframework-onap/ONAPLibrary/PreloadData.py
+++ b/robotframework-onap/ONAPLibrary/PreloadData.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.PreloadDataKeywords import PreloadDataKeywords
diff --git a/robotframework-onap/ONAPLibrary/Protobuf.py b/robotframework-onap/ONAPLibrary/Protobuf.py
index 0dfb1c4..8a06aa0 100644
--- a/robotframework-onap/ONAPLibrary/Protobuf.py
+++ b/robotframework-onap/ONAPLibrary/Protobuf.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.ProtobufKeywords import ProtobufKeywords
diff --git a/robotframework-onap/ONAPLibrary/RequestsDecorators.py b/robotframework-onap/ONAPLibrary/RequestsDecorators.py
index 1bb8b3b..0ad0fb7 100644
--- a/robotframework-onap/ONAPLibrary/RequestsDecorators.py
+++ b/robotframework-onap/ONAPLibrary/RequestsDecorators.py
@@ -1,5 +1,20 @@
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
from robot.api import logger
+
def log_wrapped(func):
def _log_wrapped(*args, **kwargs):
if 'endpoint' in kwargs:
@@ -13,6 +28,7 @@ def log_wrapped(func):
return _log_wrapped
+
def default_keywords(func):
def _default_keywords(*args, **kwargs):
dicts = _keyword_defaults(**kwargs)
@@ -42,4 +58,3 @@ def default_keywords(func):
return kwargs
return _default_keywords
-
diff --git a/robotframework-onap/ONAPLibrary/SDC.py b/robotframework-onap/ONAPLibrary/SDC.py
index f95468a..7e605c7 100644
--- a/robotframework-onap/ONAPLibrary/SDC.py
+++ b/robotframework-onap/ONAPLibrary/SDC.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.BaseSDCKeywords import BaseSDCKeywords
diff --git a/robotframework-onap/ONAPLibrary/SDNC.py b/robotframework-onap/ONAPLibrary/SDNC.py
index a96ef5f..a4f9bf1 100644
--- a/robotframework-onap/ONAPLibrary/SDNC.py
+++ b/robotframework-onap/ONAPLibrary/SDNC.py
@@ -13,7 +13,7 @@
# limitations under the License.
from ONAPLibrary.PreloadSDNCKeywords import PreloadSDNCKeywords
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.BaseSDNCKeywords import BaseSDNCKeywords
diff --git a/robotframework-onap/ONAPLibrary/SO.py b/robotframework-onap/ONAPLibrary/SO.py
index 3d2cbc3..858937c 100644
--- a/robotframework-onap/ONAPLibrary/SO.py
+++ b/robotframework-onap/ONAPLibrary/SO.py
@@ -13,7 +13,7 @@
# limitations under the License.
from ONAPLibrary.RequestSOKeywords import RequestSOKeywords
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.BaseSOKeywords import BaseSOKeywords
from ONAPLibrary.CloudConfigSOKeywords import CloudConfigSOKeywords
diff --git a/robotframework-onap/ONAPLibrary/ServiceMapping.py b/robotframework-onap/ONAPLibrary/ServiceMapping.py
index 8eeb3c9..0948d22 100644
--- a/robotframework-onap/ONAPLibrary/ServiceMapping.py
+++ b/robotframework-onap/ONAPLibrary/ServiceMapping.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.ServiceMappingKeywords import ServiceMappingKeywords
diff --git a/robotframework-onap/ONAPLibrary/SocketKeywords.py b/robotframework-onap/ONAPLibrary/SocketKeywords.py
index 2999880..6ca8956 100644
--- a/robotframework-onap/ONAPLibrary/SocketKeywords.py
+++ b/robotframework-onap/ONAPLibrary/SocketKeywords.py
@@ -1,4 +1,19 @@
-import socket, ssl
+# Copyright 2019 AT&T Intellectual Property. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import socket
+import ssl
from robot.api.deco import keyword
diff --git a/robotframework-onap/ONAPLibrary/Templating.py b/robotframework-onap/ONAPLibrary/Templating.py
index fc26829..7de1fef 100644
--- a/robotframework-onap/ONAPLibrary/Templating.py
+++ b/robotframework-onap/ONAPLibrary/Templating.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.TemplatingKeywords import TemplatingKeywords
diff --git a/robotframework-onap/ONAPLibrary/Utilities.py b/robotframework-onap/ONAPLibrary/Utilities.py
index 4773432..374885f 100644
--- a/robotframework-onap/ONAPLibrary/Utilities.py
+++ b/robotframework-onap/ONAPLibrary/Utilities.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ONAPLibrary.robotlibcore import HybridCore
+from robotlibcore import HybridCore
from ONAPLibrary.DNSKeywords import DNSKeywords
from ONAPLibrary.SocketKeywords import SocketKeywords
from ONAPLibrary.UUIDKeywords import UUIDKeywords
diff --git a/robotframework-onap/ONAPLibrary/robotlibcore.py b/robotframework-onap/ONAPLibrary/robotlibcore.py
deleted file mode 100644
index 9719e52..0000000
--- a/robotframework-onap/ONAPLibrary/robotlibcore.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# Copyright 2017- Robot Framework Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Generic test library core for Robot Framework.
-
-Main usage is easing creating larger test libraries. For more information and
-examples see the project pages at
-https://github.com/robotframework/PythonLibCore
-"""
-
-import inspect
-import sys
-
-try:
- from robot.api.deco import keyword
-except ImportError: # Support RF < 2.9
- def keyword(name=None, tags=()):
- if callable(name):
- return keyword()(name)
- def decorator(func):
- func.robot_name = name
- func.robot_tags = tags
- return func
- return decorator
-
-
-PY2 = sys.version_info < (3,)
-
-__version__ = '1.0.1.dev1'
-
-
-class HybridCore(object):
-
- def __init__(self, library_components):
- self.keywords = {}
- self.attributes = {}
- self.add_library_components(library_components)
- self.add_library_components([self])
-
- def add_library_components(self, library_components):
- for component in library_components:
- for name, func in self._get_members(component):
- if callable(func) and hasattr(func, 'robot_name'):
- kw = getattr(component, name)
- kw_name = func.robot_name or name
- self.keywords[kw_name] = kw
- # Expose keywords as attributes both using original
- # method names as well as possible custom names.
- self.attributes[name] = self.attributes[kw_name] = kw
-
- def _get_members(self, component):
- if inspect.ismodule(component):
- return inspect.getmembers(component)
- if inspect.isclass(component):
- raise TypeError('Libraries must be modules or instances, got '
- 'class {!r} instead.'.format(component.__name__))
- if type(component) != component.__class__:
- raise TypeError('Libraries must be modules or new-style class '
- 'instances, got old-style class {!r} instead.'
- .format(component.__class__.__name__))
- return self._get_members_from_instance(component)
-
- def _get_members_from_instance(self, instance):
- # Avoid calling properties by getting members from class, not instance.
- cls = type(instance)
- for name in dir(instance):
- owner = cls if hasattr(cls, name) else instance
- yield name, getattr(owner, name)
-
- def __getattr__(self, name):
- if name in self.attributes:
- return self.attributes[name]
- raise AttributeError('{!r} object has no attribute {!r}'
- .format(type(self).__name__, name))
-
- def __dir__(self):
- if PY2:
- my_attrs = dir(type(self)) + list(self.__dict__)
- else:
- my_attrs = super().__dir__()
- return sorted(set(my_attrs) | set(self.attributes))
-
- def get_keyword_names(self):
- return sorted(self.keywords)
-
-
-class DynamicCore(HybridCore):
- _get_keyword_tags_supported = False # get_keyword_tags is new in RF 3.0.2
-
- def run_keyword(self, name, args, kwargs):
- return self.keywords[name](*args, **kwargs)
-
- def get_keyword_arguments(self, name):
- kw = self.keywords[name] if name != '__init__' else self.__init__
- args, defaults, varargs, kwargs = self._get_arg_spec(kw)
- args += ['{}={}'.format(name, value) for name, value in defaults]
- if varargs:
- args.append('*{}'.format(varargs))
- if kwargs:
- args.append('**{}'.format(kwargs))
- return args
-
- def _get_arg_spec(self, kw):
- if PY2:
- spec = inspect.getargspec(kw)
- keywords = spec.keywords
- else:
- spec = inspect.getfullargspec(kw)
- keywords = spec.varkw
- args = spec.args[1:] if inspect.ismethod(kw) else spec.args # drop self
- defaults = spec.defaults or ()
- nargs = len(args) - len(defaults)
- mandatory = args[:nargs]
- defaults = zip(args[nargs:], defaults)
- return mandatory, defaults, spec.varargs, keywords
-
- def get_keyword_tags(self, name):
- self._get_keyword_tags_supported = True
- return self.keywords[name].robot_tags
-
- def get_keyword_documentation(self, name):
- if name == '__intro__':
- return inspect.getdoc(self) or ''
- if name == '__init__':
- return inspect.getdoc(self.__init__) or ''
- kw = self.keywords[name]
- doc = inspect.getdoc(kw) or ''
- if kw.robot_tags and not self._get_keyword_tags_supported:
- tags = 'Tags: {}'.format(', '.join(kw.robot_tags))
- doc = '{}\n\n{}'.format(doc, tags) if doc else tags
- return doc
-
-
-class StaticCore(HybridCore):
-
- def __init__(self):
- HybridCore.__init__(self, [])