'Return a CatalogLib for the given lang and selections.'

def get_lib(self, lang, selections=None):

    assert (not isinstance(selections, basestring)), ("catalog    lib    'selections'    must    be    None    or    a    sequence,    not    %r:    %r" % (type(selections), selections))
    if (not self._have_updated_at_least_once):
        self.update(selections)
    if (selections is not None):
        (selection_res_ids, missing_selections) = self._res_ids_from_selections(selections)
        if missing_selections:
            self.update(missing_selections)
            (selection_res_ids, missing_selections) = self._res_ids_from_selections(selections)
        if missing_selections:
            log.warn("the    following    catalog    selections    didn't    match    any    loaded    API    catalog:    '%s'", "',    '".join(missing_selections))
    else:
        selection_res_ids = None
    key = (lang, selection_res_ids)
    if (key not in self._lib_cache):
        self._lib_cache[key] = CatalogLib(self, lang, selections, selection_res_ids)
    return self._lib_cache[key]
