def InjectPositionalArgs(self, method):
    argspec = self._modules['inspect'].getargspec(method)

    # Index in argspec.args of the first keyword argument.  This index is a
    # negative number if there are any kwargs, or 0 if there are no kwargs.
    keyword_arg_index = -1 * len(argspec.defaults or [])
    arg_names = argspec.args[:keyword_arg_index or None]
    kwarg_names = argspec.args[len(arg_names):]
    functools = self._modules['functools']

    # Create the actual method wrapper, all we do is update kwargs.  Note we
    # don't pass any *args through because there can't be any - we've filled
    # them all in with values from the configuration.  Any positional args that
    # are missing from the configuration *must* be explicitly specified as
    # kwargs.
    @functools.wraps(method)
    def method_wrapper(**kwargs):
      """Wrapper that pulls values from openhtf.conf."""
      # Check for keyword args with names that are in the config so we can warn.
      for kwarg in kwarg_names:
        if kwarg in self:
          self._logger.warning('Keyword arg %s not set from configuration, but '
                               'is a configuration key', kwarg)

      # Set positional args from configuration values.
      final_kwargs = {name: self[name] for name in arg_names if name in self}

      for overridden in set(kwargs) & set(final_kwargs):
        self._logger.warning('Overriding configuration value for kwarg %s (%s) '
                             'with provided kwarg value: %s', overridden,
                             self[overridden], kwargs[overridden])

      final_kwargs.update(kwargs)
      self._logger.debug('Invoking %s with %s', method.__name__, final_kwargs)
      return method(**final_kwargs)

    # We have to check for a 'self' parameter explicitly because Python doesn't
    # pass it as a keyword arg, it passes it as the first positional arg.
    if argspec.args[0] == 'self':
      @functools.wraps(method)
      def SelfWrapper(self, **kwargs):  # pylint: disable=invalid-name
        """Wrapper that pulls values from openhtf.conf."""
        kwargs['self'] = self
        return method_wrapper(**kwargs)
      return SelfWrapper
    return method_wrapper

# Swap out the module for a singleton instance of Configuration so we can
# provide __getattr__ and __getitem__ functionality at the module level.
Decorator for injecting positional arguments from the configuration.
dataset/ETHPy150Open google/openhtf/openhtf/conf.py/Configuration.InjectPositionalArgs