def get_theme(slug): theme = None for theme_dir in settings.THEMES_DIRS: themes = ThemeStorage(location=theme_dir) directories, files = themes.listdir('./') for t in directories: if t == slug: theme = {'slug': t, 'path': themes.path(t)} break return theme
def __init__(self, apps=None, *args, **kwargs): self.locations = list(getattr(settings, 'THEMES_DIRS', [])) # Maps dir paths to an appropriate storage instance self.storages = SortedDict() for root in self.locations: filesystem_storage = ThemeStorage(location=root) self.storages[root] = filesystem_storage super(StaticFinder, self).__init__(*args, **kwargs)
def list_themes(): ''' Return the list of availables themes >>> list_themes() [{'path': u'~/hg/ionyweb3/ionyweb/contrib/themes/jungleland', 'slug': u'jungleland'}] ''' unique_slug = [] themes_list = [] for theme_dir in settings.THEMES_DIRS: themes = ThemeStorage(location=theme_dir) directories, files = themes.listdir('./') new_list = [] for t in directories: if t not in unique_slug: new_list.append({'slug': t, 'path': themes.path(t)}) unique_slug.append(t) themes_list += new_list return themes_list