# Path: robottools/utils/normdict.py
# def normdictdata(nd):
#     """Get the internal data dict with normalized keys
#        of :class:`robot.utils.NormalizedDict` instance `nd`
#     """
#     if not isinstance(nd, base):
#         raise TypeError(
#           "normdictdata() arg must be a robot.utils.NormalizedDict instance")
#     return nd.data if _has_UserDict_base else nd._data
# 
# Path: robottools/library/keywords/utils.py
# class KeywordName(str):
#     """:class:`str` wrapper to work with Keyword names in a Robot way.
# 
#     * Converts the given raw Keyword name (usually a function name)
#       to Capitalized Robot Style.
#     * Uses :func:`robot.utils.normalize`d conversions
#       (plain lowercase without spaces and underscores)
#       for comparing and hashing.
#     """
#     def __new__(cls, name='', convert=True):
#         if convert and type(name) is not KeywordName:
#             name = camelize(name, joiner=' ')
#         return str.__new__(cls, name)
# 
#     @property
#     def normalized(self):
#         return normalize(str(self), ignore='_')
# 
#     def __eq__(self, name):
#         return self.normalized == normalize(name, ignore='_')
# 
#     def __hash__(self):
#         return hash(self.normalized)
# 
# Path: robottools/library/keywords/errors.py
# class InvalidKeywordOption(LookupError):
#     pass
# 
# class KeywordNotDefined(LookupError):
#     pass


from six import PY3
from itertools import chain
from moretools import isstring, dictitems
from robot.utils import NormalizedDict
from robot.variables import is_scalar_var
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
from robottools.utils import normdictdata
from .utils import KeywordName
from .errors import InvalidKeywordOption, KeywordNotDefined
import inspect
                else:
                    varargs.append(arg)
            return func(self, *chain(args[:nposargs], varargs), **kwargs)

        method.__name__ = func.__name__
        return method

    @staticmethod
    def option_keys_from_vars(func):
        def method(self, *args, **kwargs):
            try:
                variables = BuiltIn()._variables
            except RobotNotRunningError:
                pass
            else:
                for key, value in list(dictitems(kwargs)):
                    if is_scalar_var(key):
                        kwargs[variables[key]] = kwargs.pop(key)
            return func(self, *args, **kwargs)

        method.__name__ = func.__name__
        return method

    @staticmethod
    def option_normalized_kwargs(func):
        """Normalize the keys of **kwargs using robot.utils.NormalizedDict
           (convert to lowercase and remove spaces).
        """
        def method(self, *args, **kwargs):
            kwargs = NormalizedDict(kwargs)

# Path: robottools/utils/normdict.py
# def normdictdata(nd):
#     """Get the internal data dict with normalized keys
#        of :class:`robot.utils.NormalizedDict` instance `nd`
#     """
#     if not isinstance(nd, base):
#         raise TypeError(
#           "normdictdata() arg must be a robot.utils.NormalizedDict instance")
#     return nd.data if _has_UserDict_base else nd._data
# 
# Path: robottools/library/keywords/utils.py
# class KeywordName(str):
#     """:class:`str` wrapper to work with Keyword names in a Robot way.
# 
#     * Converts the given raw Keyword name (usually a function name)
#       to Capitalized Robot Style.
#     * Uses :func:`robot.utils.normalize`d conversions
#       (plain lowercase without spaces and underscores)
#       for comparing and hashing.
#     """
#     def __new__(cls, name='', convert=True):
#         if convert and type(name) is not KeywordName:
#             name = camelize(name, joiner=' ')
#         return str.__new__(cls, name)
# 
#     @property
#     def normalized(self):
#         return normalize(str(self), ignore='_')
# 
#     def __eq__(self, name):
#         return self.normalized == normalize(name, ignore='_')
# 
#     def __hash__(self):
#         return hash(self.normalized)
# 
# Path: robottools/library/keywords/errors.py
# class InvalidKeywordOption(LookupError):
#     pass
# 
# class KeywordNotDefined(LookupError):
#     pass


# Path: robottools/library/keywords/deco.py
from six import PY3
from itertools import chain
from moretools import isstring, dictitems
from robot.utils import NormalizedDict
from robot.variables import is_scalar_var
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
from robottools.utils import normdictdata
from .utils import KeywordName
from .errors import InvalidKeywordOption, KeywordNotDefined
import inspect

                else:
                    varargs.append(arg)
            return func(self, *chain(args[:nposargs], varargs), **kwargs)

        method.__name__ = func.__name__
        return method

    @staticmethod
    def option_keys_from_vars(func):
        def method(self, *args, **kwargs):
            try:
                variables = BuiltIn()._variables
            except RobotNotRunningError:
                pass
            else:
                for key, value in list(dictitems(kwargs)):
                    if is_scalar_var(key):
                        kwargs[variables[key]] = kwargs.pop(key)
            return func(self, *args, **kwargs)

        method.__name__ = func.__name__
        return method

    @staticmethod
    def option_normalized_kwargs(func):
        """Normalize the keys of **kwargs using robot.utils.NormalizedDict
           (convert to lowercase and remove spaces).
        """
        def method(self, *args, **kwargs):
            kwargs = NormalizedDict(kwargs)

            return func(self, *args, **normdictdata(kwargs))