Returns a ChosenView class that extends specified chooser class.

    :param chooser_cls: the class to extend.
    :rtype: class.
509742
def chosen_view_factory(chooser_cls):
    
    class ChosenView(chooser_cls):
        #noinspection PyUnusedLocal
        def get(self, request, *args, **kwargs):
            """
            Returns GET response.

            :param request: the request instance.
            :rtype: django.http.HttpResponse.
            """
            #noinspection PyAttributeOutsideInit
            self.object = self.get_object()

            return render_modal_workflow(
                self.request,
                None,
                '{0}/chosen.js'.format(self.template_dir),
                {'obj': self.get_json(self.object)}
            )

        def get_object(self, queryset=None):
            """
            Returns chosen object instance.

            :param queryset: the queryset instance.
            :rtype: django.db.models.Model.
            """
            if queryset is None:
                queryset = self.get_queryset()

            pk = self.kwargs.get('pk', None)

            try:
                return queryset.get(pk=pk)
            except self.models.DoesNotExist:
                raise Http404()

        def post(self, request, *args, **kwargs):
            """
            Returns POST response.

            :param request: the request instance.
            :rtype: django.http.HttpResponse.
            """
            return self.get(request, *args, **kwargs)

    return ChosenView
121473
def _register(self, cls):
        
        if not inspect.isclass(cls):
            raise ValueError('Only classes may be registered.')
        elif not issubclass(cls, self._registerable_class):
            raise ValueError('Only %s classes or subclasses may be registered.'
                             % self._registerable_class.__name__)

        if cls not in self._registry:
            cls._registered_with = self
            self._registry[cls] = cls()

        return self._registry[cls]
1286814
def abstract(cls):
    ''' 

    '''
    if not issubclass(cls, HasProps):
        raise TypeError("%s is not a subclass of HasProps" % cls.__name__)

    # running python with -OO will discard docstrings -> __doc__ is None
    if cls.__doc__ is not None:
        cls.__doc__ += _ABSTRACT_ADMONITION

    return cls
140819
private static Constructor<? extends OptionHandler> getConstructor(Class<? extends OptionHandler> handlerClass) {
        try {
            return handlerClass.getConstructor(CmdLineParser.class, OptionDef.class, Setter.class);
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException(Messages.NO_CONSTRUCTOR_ON_HANDLER.format(handlerClass));
        }
    }
1170903
private static Class<?> getRestrictionClass(OptionID oid, final Parameter<?> firstopt, Map<OptionID, List<Pair<Parameter<?>, Class<?>>>> byopt) {
    Class<?> superclass = getRestrictionClass(firstopt);
    // Also look for more general restrictions:
    for(Pair<Parameter<?>, Class<?>> clinst : byopt.get(oid)) {
      if(clinst.getFirst() instanceof ClassParameter) {
        ClassParameter<?> cls = (ClassParameter<?>) clinst.getFirst();
        if(!cls.getRestrictionClass().equals(superclass) && cls.getRestrictionClass().isAssignableFrom(superclass)) {
          superclass = cls.getRestrictionClass();
        }
      }
      if(clinst.getFirst() instanceof ClassListParameter) {
        ClassListParameter<?> cls = (ClassListParameter<?>) clinst.getFirst();
        if(!cls.getRestrictionClass().equals(superclass) && cls.getRestrictionClass().isAssignableFrom(superclass)) {
          superclass = cls.getRestrictionClass();
        }
      }
    }
    return superclass;
  }
323702
public static Selection forClass(Class cl) {
        java.lang.reflect.Constructor[] constrs;
        int i;
        List<Function> lst;
        Function fn;

        lst = new ArrayList<Function>();
        constrs = cl.getConstructors();
        for (i = 0; i < constrs.length; i++) {
            fn = create(constrs[i]);
            if (fn != null) {
                lst.add(fn);
            }
        }
        return new Selection(lst);
    }
504355
def select(self, selection_specs=None, **kwargs):
        
        return super(Element2D, self).select(selection_specs, **kwargs)
347591
def DefaultSelector():
    
    global _DEFAULT_SELECTOR
    if _DEFAULT_SELECTOR is None:
        if _can_allocate('kqueue'):
            _DEFAULT_SELECTOR = KqueueSelector
        elif _can_allocate('epoll'):
            _DEFAULT_SELECTOR = EpollSelector
        elif _can_allocate('poll'):
            _DEFAULT_SELECTOR = PollSelector
        elif hasattr(select, 'select'):
            _DEFAULT_SELECTOR = SelectSelector
        else:  # Platform-specific: AppEngine
            raise ValueError('Platform does not have a selector')
    return _DEFAULT_SELECTOR()
594168
def _option(self):
        
        class Options(object):
            def __getitem__(_self, name):
                return self.getOption(name)

            def __setitem__(_self, name, value):
                self.setOption(name, value)

        return Options()
1372272
def _find_controller(self, class_):
        
        for controller, classes in self.request_controllers.items():
            if class_ in classes:
                return controller
        else:
            raise ValueError('Unknown request class {!r}'.format(class_))
426580
def get_subclasses(klass):
    
    stack = [klass]
    seen = set()
    while stack:
        klass = stack.pop()
        seen.add(klass)
        stack.extend(klass.__subclasses__())
    return seen
1143511
def inherited_meths(opts = {})
      inheritance_tree[1..-1].inject([]) do |list, superclass|
        if superclass.is_a?(Proxy)
          list
        else
          list += superclass.meths(opts).reject do |o|
            next(false) if opts[:all]
            child(:name => o.name, :scope => o.scope) ||
              list.find {|o2| o2.name == o.name && o2.scope == o.scope }
          end
        end
      end
    end
968991
def choice_default_serializer(self, obj):
        """"""
        if not obj:
            return None
        self.choice_default_add_related_pks(obj)
        return dict((
            ('id', obj.id),
            ('choice_text', obj.choice_text),
            self.field_to_json(
                'PK', 'question', model=Question, pk=obj.question_id),
            self.field_to_json(
                'PKList', 'voters', model=User, pks=obj._voter_pks)
        ))
1324151
def _subclass(self, parser):
        '''
         
        '''
        _set(self, '_sub', parser._create(memoryview(getattr(self, '_extra', b'')), self._target))
        try:
            object.__delattr__(self, '_extra')
        except:
            pass
877064
def pick(self, acr=None):
        

        if acr is None:
            # Anything else doesn't make sense
            return self.db.values()
        else:
            return self._pick_by_class_ref(acr)
1229664
def visit_class(rec, cls, op):
    # type: (Any, Iterable, Union[Callable[..., Any], partial[Any]]) -> None
    """"""

    if isinstance(rec, MutableMapping):
        if "class" in rec and rec.get("class") in cls:
            op(rec)
        for d in rec:
            visit_class(rec[d], cls, op)
    if isinstance(rec, MutableSequence):
        for d in rec:
            visit_class(d, cls, op)
794669
public static <T> T selectValue(T defaultValue, T... overrides) {
        for (T override : overrides) {
            if (override != null) {
                return override;
            }
        }
        return defaultValue;
    }