A compatibility wrapper for setting object's name.

  See documentation for `GetName` for more information.

  Args:
    obj: A type or function object to set the name for.
    name: A name to set.
966579
def SetName(obj, name):
  
  # Not doing type assertion on obj, since it may be a mock object used
  # in tests.
  precondition.AssertType(name, str)

  if PY2:
    obj.__name__ = name.encode("ascii")
  else:
    obj.__name__ = name
880491
def callable_name(callable_obj):
    
    try:
        if (isinstance(callable_obj, type)
            and issubclass(callable_obj, param.ParameterizedFunction)):
            return callable_obj.__name__
        elif (isinstance(callable_obj, param.Parameterized)
              and 'operation' in callable_obj.params()):
            return callable_obj.operation.__name__
        elif isinstance(callable_obj, partial):
            return str(callable_obj)
        elif inspect.isfunction(callable_obj):  # functions and staticmethods
            return callable_obj.__name__
        elif inspect.ismethod(callable_obj):    # instance and class methods
            meth = callable_obj
            if sys.version_info < (3,0):
                owner =  meth.im_class if meth.im_self is None else meth.im_self
            else:
                owner =  meth.__self__
            if meth.__name__ == '__call__':
                return type(owner).__name__
            return '.'.join([owner.__name__, meth.__name__])
        elif isinstance(callable_obj, types.GeneratorType):
            return callable_obj.__name__
        else:
            return type(callable_obj).__name__
    except:
        return str(callable_obj)
351952
def _name(iris_obj, default='unknown'):
    
    return (iris_obj.var_name or iris_obj.standard_name or
            iris_obj.long_name or default)
536044
def type_named(obj, name):
    
    # if obj is a member of the named class, return True
    name = str(name)
    if obj.__class__.__name__ == name:
        return obj.__class__
    for base in type_bases(obj):
        if base.__name__ == name:
            return base
    raise ValueError('Unable to extract class of name ' + name)
1072325
def qualified_name(obj) -> str:
    
    if not isclass(obj):
        obj = type(obj)

    if obj.__module__ == 'builtins':
        return obj.__name__
    else:
        return '{}.{}'.format(obj.__module__, obj.__qualname__)
1078647
def make_string(obj):
    
    if inspect.isclass(obj):
        if issubclass(obj, Object):
            return obj._ROOT.__name__
        if issubclass(obj, string_types):
            return 'string'
        return obj.__name__
    if not isinstance(obj, string_types):
        raise TypeError("expected string or class")
    return obj
346996
private static ObjectName getObjectName(String name) {

		ObjectName mBeanName = null;
		try {
			mBeanName = new ObjectName(name);
		} catch (MalformedObjectNameException | NullPointerException e) {
			throw new JmxConfigException(e);
		}

		return mBeanName;
	}
1134567
public void set(String name, Object obj) throws IOException {
        if (!(obj instanceof Integer)) {
            throw new IOException("Attribute must be of type Integer.");
        }
        if (name.equalsIgnoreCase(REASON)) {
            reasonCode = ((Integer)obj).intValue();
        } else {
            throw new IOException
                ("Name not supported by CRLReasonCodeExtension");
        }
        encodeThis();
    }
233094
def bind_key_name(self, function, object_name):
        """"""
        for funcname, name in self.name_map.items():
            if funcname == function:
                self.name_map[
                    funcname] = object_name
438046
def get_name(name_or_obj):
    
    if isinstance(name_or_obj, six.string_types):
        # It's a name
        return name_or_obj
    try:
        return name_or_obj.name
    except AttributeError:
        raise exc.MissingName(name_or_obj)
1306225
def get_object_by_name(self, name):
        
        for obj in self.objects:
            if obj.name == name:
                return obj
        raise ValueError
1174290
def _assign_name(self, obj, name, shaders):
        
        if self._is_global(obj):
            assert name not in self._global_ns
            self._global_ns[name] = obj
        else:
            for shader in shaders:
                ns = self._shader_ns[shader]
                assert name not in ns
                ns[name] = obj
        self._object_names[obj] = name
328144
public static X509Name getInstance(
                                       ASN1TaggedObject obj,
                                       boolean explicit)
    {
        return getInstance(ASN1Sequence.getInstance(obj, explicit));
    }
410630
def setObjectName( self, objectName ):
        
        super(XLineEdit, self).setObjectName(objectName)
        self.adjustStyleSheet()
512690
def _handle_object(self, name, obj):
        
        if type(obj) in twitter_object_handlers_lookup:
            return twitter_object_handlers_lookup[type(obj)](name, obj)
        else:
            return {name: obj}
1044717
def name(self, name):
        
        if name is None:
            raise ValueError("Invalid value for `name`, must not be `None`")
        if name is not None and len(name) > 200:
            raise ValueError("Invalid value for `name`, length must be less than or equal to `200`")

        self._name = name
364547
def instantiate_by_name_with_default(self, object_name, default_value=None):
        
        if object_name not in self.instances:
            if object_name not in self.environment:
                return default_value
            else:
                instance = self.instantiate_from_data(self.environment[object_name])

                self.instances[object_name] = instance
                return instance
        else:
            return self.instances[object_name]