Collect objects where :meth:`type_check` returns ``True`` from bundles.
        Bundle subclasses can override objects discovered in superclass bundles.
542340
def collect_from_bundle(self, bundle: Bundle) -> Dict[str, Any]:
        
        members = {}
        hierarchy = ([bundle] if not self.discover_from_bundle_superclasses
                     else bundle._iter_class_hierarchy())
        for bundle in hierarchy:
            module = self.import_bundle_module(bundle)
            if not module:
                continue
            members.update(self._collect_from_package(module))
        return members
702751
def got_a(self, _type):
        
        if _type not in self.modules:
            raise ValueError("No such module, %s" % _type)
        return (_type in self.insts_implementing and
                self.insts_implementing[_type])
269368
def get_object_by_type(self, *types):
        
        children = self.get_objects_by_type(*types)
        return children[0] if any(children) else None
840802
function(type, checks) {
		var result = false;
		var list = this._trackedtypes[type];
		if (!list) {
			list = this._trackedtypes[type] = [];
			result = true;
		} else {
			result = !this._haschecks(list, checks);
		}
		if (result && checks) {
			list.push(checks);
		}
		return result;
	}
117714
def findItems( self, cls ):
        
        return filter(lambda x: isinstance(x, cls), self.items())
771719
def should_exclude(type_or_instance, exclusion_list):
    
    if type_or_instance in exclusion_list: # Check class definition
        return True
    if type(type_or_instance) in exclusion_list: # Check instance type
        return True
    try:
        if type_or_instance.__class__ in exclusion_list: # Check instance class
            return True
    except:
        pass

    return False
633246
def determine_types(self):
        
        from nefertari.elasticsearch import ES
        collections = self.get_collections()
        resources = self.get_resources(collections)
        models = set([res.view.Model for res in resources])
        es_models = [mdl for mdl in models if mdl
                     and getattr(mdl, '_index_enabled', False)]
        types = [ES.src2type(mdl.__name__) for mdl in es_models]
        return types
332970
def _generate_legacy_type_checks(types=()):
    
    types = dict(types)

    def gen_type_check(pytypes):
        pytypes = _utils.flatten(pytypes)

        def type_check(checker, instance):
            if isinstance(instance, bool):
                if bool not in pytypes:
                    return False
            return isinstance(instance, pytypes)

        return type_check

    definitions = {}
    for typename, pytypes in iteritems(types):
        definitions[typename] = gen_type_check(pytypes)

    return definitions
586304
def collect(self, force=False):
        

        if force or not self.changes:
            self.changes = tuple(self.collect_impl())
        return self.changes
1138901
def _get_all(self, _type):
        
        if _type not in self.modules:
            raise ValueError("No such module, %s" % _type)
        if not self.insts_implementing.get(_type, None):
            raise ValueError("No instance implementing %s" % _type)
        return self.insts_implementing[_type]
1126645
def validate_type(self, type_):
        
        if type_ is not None and type_ not in self.types_set:
            raise ValueError('Invalid type for %s:%s' % (self.__class__, type_))
429287
def typechecked_class(cls, force = False, force_recursive = False):
    
    return _typechecked_class(cls, set(), force, force_recursive)
695317
def checkin_bundle(self, db_path, replace=True, cb=None):
        """"""
        from ambry.orm.exc import NotFoundError

        db = Database('sqlite:///{}'.format(db_path))
        db.open()

        if len(db.datasets) == 0:
            raise NotFoundError("Did not get a dataset in the {} bundle".format(db_path))


        ds = db.dataset(db.datasets[0].vid)  # There should only be one

        assert ds is not None
        assert ds._database

        try:
            b = self.bundle(ds.vid)
            self.logger.info(
                "Removing old bundle before checking in new one of same number: '{}'"
                .format(ds.vid))
            self.remove(b)
        except NotFoundError:
            pass

        try:
            self.dataset(ds.vid)  # Skip loading bundles we already have
        except NotFoundError:
            self.database.copy_dataset(ds, cb=cb)

        b = self.bundle(ds.vid)  # It had better exist now.
        # b.state = Bundle.STATES.INSTALLED
        b.commit()

        #self.search.index_library_datasets(tick)

        self.search.index_bundle(b)

        return b
83293
def _get_bases(type_):
        # type: (type) -> Tuple[type, type]
        
        try:

            class _(type_):  # type: ignore
                """Check if type_ is subclassable."""

            BaseClass = type_
        except TypeError:
            BaseClass = object

        class MetaClass(_ValidationMeta, BaseClass.__class__):  # type: ignore
            """Use the type_ meta and include base validation functionality."""

        return BaseClass, MetaClass
325128
def is_type(x, types, full=False):
    
    types = types if isinstance(types, tuple) else (types,)
    ins = isinstance(x, types)
    sub = False
    try:
        sub = issubclass(x, types)
    except Exception:
        pass
    res = ins or sub
    return res if not full else (res, ins)
1184780
def _check_base_classes(base_classes, check_for_type):
    
    return_value = False
    for base in base_classes:
        if base.__name__ == check_for_type:
            return_value = True
            break
        else:
            return_value = _check_base_classes(base.__bases__, check_for_type)
            if return_value is True:
                break

    return return_value
860904
def _collect_from_package(self, module,
                              type_checker: Optional[FunctionType] = None,
                              ) -> Dict[str, Any]:
        
        type_checker = type_checker or self.type_check
        members = dict(self._get_members(module, type_checker))

        if pkgutil.get_loader(module).is_package(module.__name__):
            for loader, name, is_pkg in pkgutil.walk_packages(module.__path__):
                child_module_name = f'{module.__package__}.{name}'
                child_module = importlib.import_module(child_module_name)
                for key, obj in self._get_members(child_module, type_checker):
                    if key not in members:
                        members[key] = obj

        return members