Return the first layer of a given class. If that layer is not present,
        then raise a KeyError.

        :param class_: class of the expected layer
        :param became: Allow transformed layers in results
348026
def get_layer(self, class_: Type[L], became: bool=True) -> L:
        

        try:
            return self._index[class_][0]
        except KeyError:
            if became:
                return self._transformed[class_][0]
            else:
                raise
922029
@SuppressWarnings("unchecked")
    private ClassesTransformer<T> getTyped(ClassesTransformer<? extends T> classesTransformer) {
        return (ClassesTransformer<T>) classesTransformer;
    }
596050
def getlayer(self, cls, nb=1, _track=None, _subclass=None, **flt):
        
        if _subclass is None:
            _subclass = self.match_subclass or None
        if _subclass:
            match = lambda cls1, cls2: issubclass(cls1, cls2)
        else:
            match = lambda cls1, cls2: cls1 == cls2
        if isinstance(cls, int):
            nb = cls + 1
            cls = None
        if isinstance(cls, str) and "." in cls:
            ccls, fld = cls.split(".", 1)
        else:
            ccls, fld = cls, None
        if cls is None or match(self.__class__, cls) \
           or ccls in [self.__class__.__name__, self._name]:
            if all(self.getfieldval(fldname) == fldvalue
                   for fldname, fldvalue in six.iteritems(flt)):
                if nb == 1:
                    if fld is None:
                        return self
                    else:
                        return self.getfieldval(fld)
                else:
                    nb -= 1
        for f in self.packetfields:
            fvalue_gen = self.getfieldval(f.name)
            if fvalue_gen is None:
                continue
            if not f.islist:
                fvalue_gen = SetGen(fvalue_gen, _iterpacket=0)
            for fvalue in fvalue_gen:
                if isinstance(fvalue, Packet):
                    track = []
                    ret = fvalue.getlayer(cls, nb=nb, _track=track,
                                          _subclass=_subclass, **flt)
                    if ret is not None:
                        return ret
                    nb = track[0]
        return self.payload.getlayer(cls, nb=nb, _track=_track,
                                     _subclass=_subclass, **flt)
526482
def GetClass(self, *args, **kwargs):
        

        cname = args[0] if args else kwargs['ClassName']
        try:
            cc = self.classes[self.default_namespace][cname]
        except KeyError:
            if self.conn is None:
                ce = CIMError(CIM_ERR_NOT_FOUND, cname)
                raise ce
            cc = self.conn.GetClass(*args, **kwargs)
            try:
                self.classes[self.default_namespace][cc.classname] = cc
            except KeyError:
                self.classes[self.default_namespace] = \
                    NocaseDict({cc.classname: cc})
        if 'LocalOnly' in kwargs and not kwargs['LocalOnly']:
            if cc.superclass:
                try:
                    del kwargs['ClassName']
                except KeyError:
                    pass
                if args:
                    args = args[1:]
                super_ = self.GetClass(cc.superclass, *args, **kwargs)
                for prop in super_.properties.values():
                    if prop.name not in cc.properties:
                        cc.properties[prop.name] = prop
                for meth in super_.methods.values():
                    if meth.name not in cc.methods:
                        cc.methods[meth.name] = meth
        return cc
700009
def get_classname(o):
    
    if inspect.isclass(o):
        target = o
    elif callable(o):
        target = o
    else:
        target = o.__class__
    try:
        return target.__qualname__
    except AttributeError:  # pragma: no cover
        return target.__name__
150971
def find_class_in_list(klass, lst):
    
    filtered = list(filter(lambda x: x.__class__ == klass, lst))
    if filtered:
        return filtered[0]
    return None
1151997
def get_layer(self):
        
        if self.layer:
            return
        try:
            self.layer = Layer.objects.get(slug=self.kwargs['slug'])
        except Layer.DoesNotExist:
            raise Http404(_('Layer not found'))
482269
def first(self, **kwargs):
        
        result = result = self._get(limit=1, **kwargs)
        if result:
            return result[0]
        else:
            raise self.source_class.DoesNotExist(repr(kwargs))
398489
def get_wrapping_class(node):
    

    klass = node.frame()
    while klass is not None and not isinstance(klass, ClassDef):
        if klass.parent is None:
            klass = None
        else:
            klass = klass.parent.frame()
    return klass
593752
def guess_payload_class(self, payload):
        

        under_layer = self.underlayer
        tzsp_header = None

        while under_layer:
            if isinstance(under_layer, TZSP):
                tzsp_header = under_layer
                break
            under_layer = under_layer.underlayer

        if tzsp_header:

            return tzsp_header.get_encapsulated_payload_class()
        else:
            raise TZSPStructureException('missing parent TZSP header')
1034874
def load_class(self, classname):
        

        module_list = self._get_module_list()

        for module in module_list:
            try:
                return import_class(classname, module.__name__)
            except (AttributeError, ImportError):
                pass

        raise ImportError("Class '{0}' could not be loaded.".format(classname))
1354515
def find_first_object(self, ObjectClass, **kwargs):
        
        filter = None
        for k, v in kwargs.items():
            cond = getattr(ObjectClass, k) == v
            filter = cond if filter is None else filter & cond

        return list(ObjectClass.scan(filter, limit=1))[0]
976609
def get_serializer_class(self, view, method_func):
        
        if hasattr(method_func, 'request_serializer'):
            return getattr(method_func, 'request_serializer')

        if hasattr(view, 'serializer_class'):
            return getattr(view, 'serializer_class')

        if hasattr(view, 'get_serializer_class'):
            return getattr(view, 'get_serializer_class')()

        return None
395222
def get_layer(self, name: str=None):
        
        if name is None:
            name = self.__last_layer_name

        return self.__layers[name]
541759
def earliest_class
      earliest = self.first
      self.each { |c| earliest = c if c.time < earliest.time }
      earliest
    end
222178
def getlayer(self, cls, nb=1, _track=None):
        """"""
        if type(cls) is int:
            nb = cls+1
            cls = None
        if type(cls) is str and "." in cls:
            ccls,fld = cls.split(".",1)
        else:
            ccls,fld = cls,None
        if cls is None or self.__class__ == cls or self.__class__.name == ccls:
            if nb == 1:
                if fld is None:
                    return self
                else:
                    return self.getfieldval(fld)
            else:
                nb -=1
        for f in self.packetfields:
            fvalue_gen = self.getfieldval(f.name)
            if fvalue_gen is None:
                continue
            if not f.islist:
                fvalue_gen = SetGen(fvalue_gen,_iterpacket=0)
            for fvalue in fvalue_gen:
                if isinstance(fvalue, Packet):
                    track=[]
                    ret = fvalue.getlayer(cls, nb, _track=track)
                    if ret is not None:
                        return ret
                    nb = track[0]
        return self.payload.getlayer(cls,nb,_track=_track)
1023252
def process_result(self, raw_result):
        
        if self.results_class and raw_result:
            if isinstance(raw_result, dict_type):
                return self.results_class(raw_result)
            elif isinstance(raw_result, collections.Iterable):
                return [self.results_class(result) for result in raw_result]

        return raw_result