create a loader for a dataclass type
437832
def create_dataclass_loader(cls, registry, field_getters):
    """"""
    fields = cls.__dataclass_fields__
    item_loaders = map(registry, map(attrgetter('type'), fields.values()))
    getters = map(field_getters.__getitem__, fields)
    loaders = list(starmap(compose, zip(item_loaders, getters)))

    def dloader(obj):
        return cls(*(g(obj) for g in loaders))

    return dloader
638982
def load_class_by_name(name: str):
    """"""
    mod_path, _, cls_name = name.rpartition('.')
    mod = importlib.import_module(mod_path)
    cls = getattr(mod, cls_name)
    return cls
583200
function XMLLoader(loadItem) {
		this.AbstractLoader_constructor(loadItem, true, createjs.Types.XML);

		// public properties
		this.resultFormatter = this._formatResult;
	}
408559
def include_constructor(self, loader, node):
        
        v = self._unfold_yaml(node.value)

        return v
280842
function( loadClass, loadSpecs, name, callback ) {

		// Trigger bundle loader and return TRUE if this
		// was handled by this loader.
		return BundleLoader.load( loadClass, loadSpecs, function( data, extra ) {

			// Prepare response array
			var objects = {};
			objects[name] = data;
			if (extra) objects[name+':extra'] = extra;

			// Notify that we are compiled
			callback( null, objects );

		});


	}
935375
def _unionload(l: Loader, value, type_) -> Any:
    
    try:
        args = uniontypes(type_)
    except AttributeError:
        raise TypedloadAttributeError('The typing API for this Python version is unknown')

    # Do not convert basic types, if possible
    if type(value) in args.intersection(l.basictypes):
        return value

    exceptions = []

    # Try all types
    for t in args:
        try:
            return l.load(value, t, annotation=Annotation(AnnotationType.UNION, t))
        except Exception as e:
            exceptions.append(e)
    raise TypedloadValueError(
        'Value could not be loaded into %s' % type_,
            value=value,
            type_=type_,
            exceptions=exceptions
    )
99549
public static InjectorImpl create(ClassLoader loader)
  {
    synchronized (loader) {
      if (loader instanceof DynamicClassLoader) {
        InjectorImpl inject = _localManager.getLevel(loader);

        if (inject == null) {
          inject = (InjectorImpl) InjectorAmp.manager(loader).get();
          _localManager.set(inject, loader);
        }

        return inject;
      }
      else {
        SoftReference<InjectorImpl> injectRef = _loaderManagerMap.get(loader);

        InjectorImpl inject = null;

        if (injectRef != null) {
          inject = injectRef.get();

          if (inject != null) {
            return inject;
          }
        }

        inject = (InjectorImpl) InjectorAmp.manager(loader).get();

        _loaderManagerMap.put(loader, new SoftReference<>(inject));

        return inject;
      }
    }
  }
1188053
public static Class<?> loadClass(String classname, DataFormat<?> dataFormat) {

    // first try context classoader
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if(cl != null) {
      LOG.tryLoadingClass(classname, cl);
      try {
        return cl.loadClass(classname);
      }
      catch(Exception e) {
        // ignore
      }
    }

    // else try the classloader which loaded the dataformat
    cl = dataFormat.getClass().getClassLoader();
    try {
      LOG.tryLoadingClass(classname, cl);
      return cl.loadClass(classname);
    }
    catch (ClassNotFoundException e) {
      throw LOG.classNotFound(classname, e);
    }

  }
918763
@SuppressWarnings("unchecked")
    private Class<? extends T> loadClass(ClassLoader classLoader, String generatedName)
            throws ClassNotFoundException {
        return (Class<? extends T>) classLoader.loadClass(generatedName);
    }
980822
def _make_class(cls, **kwargs):
    """"""
    kwargs = {k: (v if v is not None else getattr(cls, k, None))
              for k, v in kwargs.items()}
    # The class name contains a hash of the custom parameters.
    name = cls.__name__ + '_' + _hash(kwargs)
    if name not in _CLASSES:
        logger.log(5, "Create class %s %s.", name, kwargs)
        cls = type(name, (cls,), kwargs)
        _CLASSES[name] = cls
    return _CLASSES[name]
542326
def _load_class(class_path):
    """"""
    parts = class_path.rsplit('.', 1)
    module = __import__(parts[0], fromlist=parts[1])
    return getattr(module, parts[1])
869160
@SuppressWarnings("rawtypes")
	public static Class loadClass(Class loadClass, String name,
								  boolean checkParents) throws ClassNotFoundException {
		ClassNotFoundException ex = null;
		Class<?> c = null;
		ClassLoader loader = Thread.currentThread().getContextClassLoader();
		while (c == null && loader != null) {
			try {
				c = loader.loadClass(name);
			} catch (ClassNotFoundException e) {
				if (ex == null) {
					ex = e;
				}
			}
			loader = (c == null && checkParents) ? loader.getParent() : null;
		}

		loader = loadClass == null ? null : loadClass.getClassLoader();
		while (c == null && loader != null) {
			try {
				c = loader.loadClass(name);
			} catch (ClassNotFoundException e) {
				if (ex == null) {
					ex = e;
				}
			}
			loader = (c == null && checkParents) ? loader.getParent() : null;
		}

		if (c == null) {
			try {
				c = Class.forName(name);
			} catch (ClassNotFoundException e) {
				if (ex == null) {
					ex = e;
				}
			}
		}

		if (c != null) {
			return c;
		}
		throw ex;
	}
1024113
def load(cls, sc, path):
        
        if not isinstance(sc, SparkContext):
            raise TypeError("sc should be a SparkContext, got type %s" % type(sc))
        if not isinstance(path, basestring):
            raise TypeError("path should be a basestring, got type %s" % type(path))
        model = callMLlibFunc("loadLDAModel", sc, path)
        return LDAModel(model)
100343
private static Class<?> loadPrimitiveType(String fullName, ClassNotFoundException ex) throws ClassNotFoundException {
        if (fullName.equals("int")) {
            return int.class;
        } else if (fullName.equals("long")) {
            return long.class;
        } else if (fullName.equals("double")) {
            return double.class;
        } else if (fullName.equals("boolean")) {
            return boolean.class;
        } else if (fullName.equals("short")) {
            return short.class;
        } else if (fullName.equals("byte")) {
            return byte.class;
        } else if (fullName.equals("char")) {
            return char.class;
        } else if (fullName.equals("float")) {
            return float.class;
        } else if (fullName.equals("void")) {
            return void.class;
        }
        throw ex;
    }
756192
public static Object instantiate(String type, ClassLoader classLoader) {
        try {
            return ClassUtils.forName(type, classLoader)
                .flatMap(InstantiationUtils::tryInstantiate)
                .orElseThrow(() -> new InstantiationException("No class found for name: " + type));
        } catch (Throwable e) {
            throw new InstantiationException("Could not instantiate type [" + type + "]: " + e.getMessage(), e);
        }
    }
216048
public static JClassLoaderWrapper create(ClassLoader loader)
  {
    JClassLoaderWrapper jLoader = _localClassLoader.getLevel(loader);
    
    if (jLoader == null) {
      jLoader = new JClassLoaderWrapper(loader);
      _localClassLoader.set(jLoader, loader);
    }

    return jLoader;
  }
991984
private Class loadClass(final String name) {

		ClassLoader loader = NodeExtender.getClassLoader();
		Class loadedClass  = null;

		if (loader == null) {
			loader = getClass().getClassLoader();
		}

		try {

			loadedClass = Class.forName(name, true, loader);

		} catch (Throwable ignore) {}

		if (loadedClass == null) {

			try {

				loadedClass = Class.forName(name);

			} catch (Throwable ignore) {}
		}

		return loadedClass;
	}