Finds members of a certain type in obj.

    :param obj: A model instance or class.
    :param member_type: The type of the menber we are trying to find.
    :rtype: A :class:`list` of ``member_type`` found in ``obj``
11110
def _get_members_of_type(obj, member_type):
    

    if not issubclass(type(obj), ModelBase):
        obj = obj.__class__

    key_hash = []
    for key in dir(obj):
        try:
            attr = getattr(obj, key)
        except AttributeError as e:
            try:
                attr = obj.__dict__[key]
            except KeyError:
                raise AttributeError(INTROSPECTION_ERROR % (e, obj, member_type))

        if type(attr) is member_type:
            key_hash.append((key, attr))

    return key_hash
891458
def find(cls, dtype):
        
        try:
            return cls._member_map_[dtype]
        except KeyError:
            try:
                dtype = numpy.dtype(dtype).type
            except TypeError:
                for ndstype in cls._member_map_.values():
                    if ndstype.value is dtype:
                        return ndstype
            else:
                for ndstype in cls._member_map_.values():
                    if ndstype.value and ndstype.numpy_dtype is dtype:
                        return ndstype
            raise ValueError('%s is not a valid %s' % (dtype, cls.__name__))
1086973
def find_objects(modules):
    
    return {
        subclass.__name__: subclass
        for subclass in chain(
            get_all_subclasses(Object),
            get_all_subclasses(ObjectSet),
        )
        if subclass.__module__ in modules
    }
494234
def find(cls, name):
        
        try:
            return cls._member_map_[name]
        except KeyError:
            for ctype in cls._member_map_.values():
                if ctype.name == name:
                    return ctype
            raise ValueError('%s is not a valid %s' % (name, cls.__name__))
382146
def is_of_types(obj, the_types):
    '''
    
    '''
    if not isinstance(obj, the_types):
        raise KittyException('object type (%s) is not one of (%s)' % (type(obj), the_types))
414806
def visitObjectMacro(self, ctx: jsgParser.ObjectExprContext):
        
        name = as_token(ctx)
        self._context.grammarelts[name] = JSGObjectExpr(self._context, ctx.membersDef(), name)
1120348
def pks_from_objects(self, objects):
        
        return {o.pk if isinstance(o, Model) else o for o in objects}
585810
def find_object(self, object_type):
        """"""
        node = self
        while node is not None:
            if isinstance(node.obj, object_type):
                return node.obj
            node = node.parent
1324589
def find_by_typename(self, typename):
        
        return self.find_by(lambda obj: type(obj).__name__ == typename)
421990
def obj_for(self, obj_or_name: Union[str, Element]) -> Optional[Union[str, Element]]:
        
        name = obj_or_name.name if isinstance(obj_or_name, Element) else obj_or_name
        return self.schema.classes[name] if name in self.schema.classes \
            else self.schema.slots[name] if name in self.schema.slots \
            else self.schema.types[name] if name in self.schema.types else name if name in builtin_names \
            else None
375457
private Iterable<? extends JSType> getTypeAlternatives(JSType type) {
    if (type.isUnionType()) {
      return type.getUnionMembers();
    } else {
      ObjectType objType = type.toMaybeObjectType();
      FunctionType constructor = objType != null ? objType.getConstructor() : null;
      if (constructor != null && constructor.isInterface()) {
        List<JSType> list = new ArrayList<>();
        for (FunctionType impl : constructor.getDirectSubTypes()) {
          list.add(impl.getInstanceType());
        }
        return list.isEmpty() ? null : list;
      } else {
        return null;
      }
    }
  }
61891
def class_subobjects(
        class_: Type) -> Generator[Tuple[str, Type, bool], None, None]:
    
    argspec = inspect.getfullargspec(class_.__init__)
    defaults = argspec.defaults if argspec.defaults else []
    num_optional = len(defaults)
    first_optional = len(argspec.args) - num_optional

    for i, attr_name in enumerate(argspec.args):
        if attr_name == 'self':
            continue
        if attr_name == 'yatiml_extra':
            continue
        attr_type = argspec.annotations.get(attr_name, Any)
        yield attr_name, attr_type, i < first_optional
183884
def get_page_objects_by_type(context, object_type):
    
    try:
        objects = context['page']['content'][object_type]
    except KeyError:
        raise template.TemplateSyntaxError('wrong content type: {0:>s}'.format(object_type))
    return objects
1125186
def find_all_by_type(account_type)
        raise AccountsListNotLoadedError unless loaded?
        @accounts.inject([]) do | list, account |
          list << account if account.type == account_type
          list
        end
      end
600467
def _members(self):
        
        return {
            key: value
            for key, value in self.__dict__.items()
            # NB: ignore internal SQLAlchemy state and nested relationships
            if not key.startswith("_") and not isinstance(value, Model)
        }
1052158
def package_org_types(self, obj_list):
        
        org_type_list = []
        for obj in obj_list:
            sane_obj = convert_ms_object(
                obj['Fields']['KeyValueOfstringanyType']
            )
            org = OrganizationType(sane_obj)
            org_type_list.append(org)
        return org_type_list
849149
private Membership findMembershipByUserGroupAndType(Session session, String userName, String groupId, String type)
      throws Exception
   {
      MembershipImpl membership = getFromCache(userName, groupId, type);
      if (membership != null)
      {
         return membership;
      }

      try
      {
         Node groupNode = utils.getGroupNode(session, groupId);

         Node refUserNode = groupNode.getNode(JCROrganizationServiceImpl.JOS_MEMBERSHIP).getNode(userName);
         Node refTypeNode =
            refUserNode.getNode(type.equals(MembershipTypeHandler.ANY_MEMBERSHIP_TYPE)
               ? JCROrganizationServiceImpl.JOS_MEMBERSHIP_TYPE_ANY : type);

         String id = utils.composeMembershipId(groupNode, refUserNode, refTypeNode);

         membership = new MembershipImpl();
         membership.setGroupId(groupId);
         membership.setUserName(userName);
         membership.setMembershipType(type);
         membership.setId(id);

         putInCache(membership);

         return membership;
      }
      catch (PathNotFoundException e)
      {
         return null;
      }
   }