Return a set of all slots for a given class and its parents
769696
def find_slots(cls):
    """"""

    slots = set()
    for c in cls.__mro__:
        cslots = getattr(c, "__slots__", tuple())

        if not cslots:
            continue
        elif isinstance(cslots, (bstr, ustr)):
            cslots = (cslots,)

        slots.update(cslots)

    return slots
927855
def get_class_list(cls) -> DOMTokenList:
        """"""
        cl = []
        cl.append(DOMTokenList(cls, cls.class_))
        if cls.inherit_class:
            for base_cls in cls.__bases__:
                if issubclass(base_cls, WdomElement):
                    cl.append(base_cls.get_class_list())
        # Reverse order so that parent's class comes to front  <- why?
        cl.reverse()
        return DOMTokenList(cls, *cl)
57490
def get_by_slot(self, parent_object, slot):
        
        placeholder = self.parent(parent_object).get(slot=slot)
        placeholder.parent = parent_object  # fill the reverse cache
        return placeholder
264551
public final Set<Attribute> getAttributes(final Class<?> _class)
    {
        final Set<Attribute> ret = new HashSet<>();
        for (final Attribute attr : getAttributes().values()) {
            if (attr.getAttributeType().getClassRepr().isAssignableFrom(_class)) {
                ret.add(attr);
            }
        }
        return ret;
    }
396005
def _filter_classes(cls_list, cls_type):
    """"""
    for cls in cls_list:
        if isinstance(cls, type) and issubclass(cls, cls_type):
            if cls_type == TempyPlace and cls._base_place:
                pass
            else:
                yield cls
1177911
def slots_class_sealer(fields, defaults):
    
    class __slots_meta__(type):
        def __new__(mcs, name, bases, namespace):
            if "__slots__" not in namespace:
                namespace["__slots__"] = fields
            return type.__new__(mcs, name, bases, namespace)

    class __slots_base__(_with_metaclass(__slots_meta__, object)):
        __slots__ = ()

        def __init__(self, *args, **kwargs):
            pass

    return class_sealer(fields, defaults, base=__slots_base__)
265616
def with_slots(cls):
    
    def _compare(self, other):
        for slot in self.__class__._slots_:
            attr = operator.attrgetter(slot)
            source = attr(self)
            target = attr(other)
            if isinstance(source, numpy.ndarray):
                eq = numpy.array_equal(source, target)
            elif hasattr(source, '_slots_'):
                source.assert_equal(target)
                eq = True
            else:
                eq = source == target
            yield slot, source, target, eq

    def __eq__(self, other):
        return all(eq for slot, source, target, eq in _compare(self, other))

    def __ne__(self, other):
        return not self.__eq__(other)

    def assert_equal(self, other, ignore=()):
        for slot, source, target, eq in _compare(self, other):
            if not eq and slot not in ignore:
                raise AssertionError('slot %s: %s is different from %s' %
                                     (slot, source, target))

    cls._slots_  # raise an AttributeError for missing slots
    cls.__eq__ = __eq__
    cls.__ne__ = __ne__
    cls.assert_equal = assert_equal
    return cls
262310
def parents(self) -> List["Collection"]:
        
        p = self.parent
        parents = []
        while p is not None:
            parents.append(p)
            p = p.parent
        return parents
710504
def find_all(self, cls):
        """"""
        final_results = []
        for db_result in read_by_indexes(cls.get_table_name(), []):
            obj = cls.from_data(db_result['value'])
            final_results.append(obj)

        return final_results
1005286
def cluster_get_keys_in_slots(self, slot, count, *, encoding):
        """"""
        return self.execute(b'CLUSTER', b'GETKEYSINSLOT', slot, count,
                            encoding=encoding)
414406
def get_object_members(self, want_all):
        """"""
        check, members = super().get_object_members(want_all)
        get_traits = self.object.class_own_traits if self.options.inherited_members \
                     else self.object.class_traits
        trait_members = []
        for name, trait in sorted(get_traits(config=True).items()):
            # put help in __doc__ where autodoc will look for it
            trait.__doc__ = trait.help
            trait_members.append((name, trait))
        return check, trait_members + members
316528
def _get_all_decendents(self, cls):
        """"""
        decendents = {}
        for sc in cls.__sub_classes__:
            decendents[sc.__name__] = sc
            decendents.update(self._get_all_decendents(sc))
        return decendents
1284309
def dir2(obj):
    
    attrs = set()

    if not hasattr(obj, '__bases__'):
        # obj is an instance
        if not hasattr(obj, '__class__'):
            # slots
            return sorted(get_attrs(obj))
        klass = obj.__class__
        attrs.update(get_attrs(klass))
    else:
        # obj is a class
        klass = obj

    for cls in klass.__bases__:
        attrs.update(get_attrs(cls))
        attrs.update(dir2(cls))
    attrs.update(get_attrs(obj))
    return list(attrs)
868826
def get_objects_of_class(cls):
        
        return list(o for o in gc.get_objects() if isinstance(o, cls))
31281
def get_suitable_vis_classes(obj):
    """"""

    ret = []
    for class_ in classes_vis():
        if isinstance(obj, class_.input_classes):
            ret.append(class_)
    return ret
1220126
def list_of(cls):
    
    return lambda l: isinstance(l, list) and all(isinstance(x, cls) for x in l)
1228066
def gen_references(self) -> str:
        
        rval = []
        for cls in self.schema.classes.values():
            pkeys = self.primary_keys_for(cls)
            for pk in pkeys:
                pk_slot = self.schema.slots[pk]
                classname = camelcase(cls.name) + camelcase(pk)
                if cls.is_a and getattr(self.schema.classes[cls.is_a], pk, None):
                    parent = self.range_type_name(pk_slot, cls.is_a)
                else:
                    parent = self.python_name_for(pk_slot.range)
                rval.append(f'class {classname}({parent}):\n\tpass')
        return '\n\n\n'.join(rval)