Returns an ordered dictionary with the available GSIM classes
    keyed by class name
357235
def get_available_mfds():
    '''
    
    '''
    mfds = {}
    for fname in os.listdir(os.path.dirname(__file__)):
        if fname.endswith('.py'):
            modname, _ext = os.path.splitext(fname)
            mod = importlib.import_module(
                'openquake.hmtk.faults.mfd.' + modname)
            for cls in mod.__dict__.values():
                if inspect.isclass(cls) and issubclass(cls, BaseMFDfromSlip):
                    mfds[cls.__name__] = cls
    return dict((k, mfds[k]) for k in sorted(mfds))
1265512
def get_rlzs_by_gsim(oqparam):
    
    cinfo = source.CompositionInfo.fake(get_gsim_lt(oqparam))
    ra = cinfo.get_rlzs_assoc()
    dic = {}
    for rlzi, gsim_by_trt in enumerate(ra.gsim_by_trt):
        dic[gsim_by_trt['*']] = [rlzi]
    return dic
640100
def all_subclasses(cls):
    
    subclasses = cls.__subclasses__() 
    return subclasses + [g for s in subclasses for g in all_subclasses(s)]
1305604
def with_class(self, cls):
        
        rcls = []
        for key, value in self._classification.items():
            if value[0] == cls:
                rcls.append(key)
        return rcls
358645
def get_available_gsims(request):
    
    gsims = list(gsim.get_available_gsims())
    return HttpResponse(content=json.dumps(gsims), content_type=JSON)
476621
def _get_classes_to_inspect(self):
        
        return tuple(filter(lambda c:
                      SerializableMixIn._get_version(c, require=False) or
                      (SerializableMixIn._get_serialize_fields(c) or
                       SerializableMixIn._get_interpolation_map(c)),
                      self.__class__.__mro__))
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]
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
477539
def get_rlzs_by_gsim(self, trt_or_grp_id, sm_id=None):
        
        if isinstance(trt_or_grp_id, (int, U16, U32)):  # grp_id
            trt = self.csm_info.trt_by_grp[trt_or_grp_id]
            sm_id = self.csm_info.get_sm_by_grp()[trt_or_grp_id]
        else:  # assume TRT string
            trt = trt_or_grp_id
        acc = collections.defaultdict(list)
        if sm_id is None:  # full dictionary
            for rlz, gsim_by_trt in zip(self.realizations, self.gsim_by_trt):
                acc[gsim_by_trt[trt]].append(rlz.ordinal)
        else:  # dictionary for the selected source model
            for rlz in self.rlzs_by_smodel[sm_id]:
                gsim_by_trt = self.gsim_by_trt[rlz.ordinal]
                try:  # if there is a single TRT
                    [gsim] = gsim_by_trt.values()
                except ValueError:  # there is more than 1 TRT
                    gsim = gsim_by_trt[trt]
                acc[gsim].append(rlz.ordinal)
        return {gsim: numpy.array(acc[gsim], dtype=U16)
                for gsim in sorted(acc)}
1109437
def find_classes_in_module(module, clstypes):
    
    classes = []
    for item in dir(module):
        item = getattr(module, item)
        try:
            for cls in clstypes:
                if issubclass(item, cls) and item != cls:
                    classes.append(item)
        except Exception as e:
            pass
    return classes
1043964
def _genEmptyResults(self):
        

        allowedKeys = self._allowedKeys

        keysDict = OrderedDict()  # Note: list comprehension take 0 then 2 then 1 then 3 etc for some reason. we want strict order
        for k in allowedKeys:
            keysDict[k] = 0


        resultsByClass = keysDict

        return resultsByClass
73695
def as_dict(self):
        
        #TODO/FIXME: add selected information
        if self.hidden:
            rdict = {}
        else:
            def_selected = self.selected()
            comps = [
                {
                    'name': comp.name,
                    'default': comp.name in self.defaults,
                    'options': comp.get_ordered_options() if isinstance(comp, Optionable) else None
                }
                for comp in self
            ]
            rdict = {
                'name': self.name,
                'required': self.required,
                'multiple': self.multiple,
                'args': self.in_name,
                'returns': self.out_name,
                'components': comps
            }
        return rdict
383863
def dict(self):
        
        from collections import OrderedDict

        d = OrderedDict(
            [(p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ('data',)])

        if 'list' in self.data:
            d['bundle_count'] = len(self.data['list'])
        else:
            d['bundle_count'] = None

        if self.data:
            for k, v in self.data.items():
                d[k] = v

        return d
354360
def getschemas(cls):
        
        members = getmembers(cls, lambda member: isinstance(member, Schema))

        result = OrderedDict()

        for name, member in members:
            result[name] = member

        return result
314855
def get_ntgos_sorted(self, hdrgos):
        """"""
        go2nt = self.grprobj.go2nt
        return sorted([go2nt[go] for go in hdrgos if go in go2nt], key=self.fncsortnt)
1049047
def key_for_class
      word = self.class.name.split("::").last.to_s.dup
      word.gsub!(/::/, '/')
      word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
      word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
      word.tr!("-", "_")
      word.downcase!
      word.to_sym
    end
1102740
def keys(self):
        """"""

        keys = OrderedDict()

        def order_key(_):
            (k, v) = _
            cache_key = getattr(type(self), k)
            return cache_key.order

        items = [(k, getattr(type(self), k)) for k
            in dir(type(self))
        ]
        items = [(k, v) for (k, v)
            in items
            if isinstance(v, Key)
        ]

        for k, v in sorted(items, key=order_key):
            keys[k] = getattr(self, k)
        return keys