code: def for_method(cls, server, namespace, classname, methodname):
          # pylint: disable=line-too-long
            # noqa: E501
  
          conn = server
          try:
              get_class = conn.GetClass
          except AttributeError:
              conn = server.conn
              get_class = conn.GetClass
  
          class_obj = get_class(ClassName=classname,
                                namespace=namespace,
                                LocalOnly=False,
                                IncludeQualifiers=True)
          try:
              method_obj = class_obj.methods[methodname]
          except KeyError:
              raise KeyError(
                  _format("Class {0!A} (in {1!A}) does not have a method {2!A}",
                          classname, namespace, methodname))
  
          new_vm = cls._create_for_element(method_obj, conn, namespace,
                                           classname, methodname=methodname)
  
          return new_vm
docs: Factory method that returns a new :class:`~pywbem.ValueMapping`
          instance that maps CIM method return values to the `Values` qualifier
          of that method.
  
          If a `Values` qualifier is defined but no `ValueMap` qualifier, a
          default of 0-based consecutive numbers is applied (that is the default
          defined in :term:`DSP0004`).
  
          Parameters:
  
            server (:class:`~pywbem.WBEMConnection` or :class:`~pywbem.WBEMServer`):
              The connection to the WBEM server containing the namespace.
  
            namespace (:term:`string`):
              Name of the CIM namespace containing the class.
  
            classname (:term:`string`):
              Name of the CIM class exposing the method. The method can be
              defined in that class or inherited into that class.
  
            methodname (:term:`string`):
              Name of the CIM method that defines the `Values` / `ValueMap`
              qualifiers.
  
          Returns:
  
              The new :class:`~pywbem.ValueMapping` instance.
  
          Raises:
  
              Exceptions raised by :class:`~pywbem.WBEMConnection`.
              KeyError: The CIM method does not exist in the CIM class.
              TypeError: The CIM method is not integer-typed.
              ValueError: No `Values` qualifier defined on the CIM method.
              ValueError: Invalid integer representation in `ValueMap` qualifier
                defined on the CIM method.