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 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