Form a music service data structure class from the class key

    Args:
        class_key (str): A concatenation of the base class (e.g. MediaMetadata)
            and the class name

    Returns:
        class: Subclass of MusicServiceItem
423230
def get_class(class_key):
    
    if class_key not in CLASSES:
        for basecls in (MediaMetadata, MediaCollection):
            if class_key.startswith(basecls.__name__):
                # So MediaMetadataTrack turns into MSTrack
                class_name = 'MS' + class_key.replace(basecls.__name__, '')
                if sys.version_info[0] == 2:
                    class_name = class_name.encode('ascii')
                CLASSES[class_key] = type(class_name, (basecls,), {})
                _LOG.info('Class %s created', CLASSES[class_key])
    return CLASSES[class_key]
162913
def key(self):
        
        return self.make_key(
            self._instance._name,
            self._instance.pk.get(),
            self.name,
        )
296187
def get_methods_class(self, class_name):
        
        l = []
        for i in self.classes.class_def:
            for j in i.get_methods():
                if class_name == j.get_class_name():
                    l.append(j)

        return l
16273
def class_from_string(name):
    '''
    
    '''
    module_name, class_name = name.rsplit('.', 1)
    __import__(module_name)
    module = sys.modules[module_name]
    return getattr(module, class_name)
705518
def get_order_key(self, **kwargs):
        
        # get the mapping enumeration class from Meta class
        mapping = self.mapping
        # use the first element in the enumeration as default order column
        order_column = kwargs.get('order[0][column]',
                                  [mapping.keys()[0]])[0]
        order_column = ensure(int, order_column, mapping.keys()[0])
        order = kwargs.get('order[0][dir]', ['asc'])[0]

        order_key = mapping.from_key(order_column).label
        # django orm '-' -> desc
        if order == 'desc':
            order_key = '-' + order_key
        return order_key
879718
def string_class(cls):
    
    if not PY3:
        if '__str__' not in cls.__dict__:
            raise TypeError('the given class has no __str__ method')
        cls.__unicode__, cls.__string__ = (
            cls.__str__, lambda self: self.__unicode__().encode('utf-8'))
    return cls
515587
def methods_for_class(classname)
      a = raw_data_relative.first.keys.select{|kl,_| kl == classname}.map{|_,meth| meth}.sort
      a.empty? ? nil : a
    end
931760
def class_name(self) -> str:
        
        if not self.api_name:  # empty string
            return self.api_name
        # end if
        return self.api_name[0].upper() + self.api_name[1:]
688827
def get_subscribed_services_names(cls):
        
        # This is very inefficient - loops within loops within loops, and
        # many network requests
        # Optimise it?
        accounts_for_service = Account.get_accounts_for_service
        service_data = cls._get_music_services_data().values()
        return [
            service['Name'] for service in service_data
            if len(
                accounts_for_service(service['ServiceType'])
            ) > 0
        ]
193082
def class_filter(classes, class_name):
    
    result_classes = classes
    if isinstance(class_name, list):
        if set(class_name) <= set(classes):
            result_classes = class_name
    return result_classes
1089251
def get_class(class_string):
    
    try:
        mod_name, class_name = get_mod_func(class_string)
        if class_name != '':
            cls = getattr(__import__(mod_name, {}, {}, ['']), class_name)
            return cls
    except (ImportError, AttributeError):
        pass
    raise ImportError('Failed to import %s' % class_string)
159506
def get_class(class_string):
    
    split_string = class_string.encode('ascii').split('.')
    import_path = '.'.join(split_string[:-1])
    class_name = split_string[-1]

    if class_name:
        try:
            if import_path:
                mod = __import__(import_path, globals(), {}, [class_name])
                cls = getattr(mod, class_name)
            else:
                cls = __import__(class_name, globals(), {})
            if cls:
                return cls
        except (ImportError, AttributeError):
            pass

    return None
107979
def str_to_class(class_name):
    
    mod_str, cls_str = class_name.rsplit('.', 1)
    mod = __import__(mod_str, globals(), locals(), [''])
    cls = getattr(mod, cls_str)
    return cls
105830
def response_class(self, cls):
        
        s = self._clone()
        s._response_class = cls
        return s
943056
def str_to_application_class(self, an_app_key):
        """"""
        try:
            app_class = str_to_python_object(self.apps[an_app_key])
        except KeyError:
            app_class = str_to_python_object(an_app_key)
        try:
            self.application_defaults = DotDict(
                app_class.get_application_defaults()
            )
        except AttributeError:
            # no get_application_defaults, skip this step
            pass
        return app_class
277105
def class_string(self, klass):
        ''''''
        if isinstance(klass, string_types):
            return klass
        return klass.__module__ + '.' + klass.__name__
1373594
def get_role_keys(cls, unit_key):
        
        stack = Role.objects.filter(unit_id=unit_key).values_list('key', flatten=True)
        for unit_key in cls.objects.filter(parent_id=unit_key).values_list('key', flatten=True):
            stack.extend(cls.get_role_keys(unit_key))
        return stack