Mercurial > piecrust2
comparison piecrust/themes/base.py @ 745:0b4eb0e37363
themes: Expand `~` paths, fix error message.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 05 Jun 2016 00:00:44 -0700 |
parents | 4285b2c9b872 |
children | 14cca285f73b |
comparison
equal
deleted
inserted
replaced
744:d8d2b504306a | 745:0b4eb0e37363 |
---|---|
33 | 33 |
34 # Get the list of directories in which themes are installed. | 34 # Get the list of directories in which themes are installed. |
35 dirs = [] | 35 dirs = [] |
36 themes_dirs = site_config.get('themes_dirs', []) | 36 themes_dirs = site_config.get('themes_dirs', []) |
37 if isinstance(themes_dirs, str): | 37 if isinstance(themes_dirs, str): |
38 dirs.append(os.path.join(self.root_dir, themes_dirs)) | 38 dirs.append(os.path.join(self.root_dir, |
39 os.path.expanduser(themes_dirs))) | |
39 else: | 40 else: |
40 dirs += [os.path.join(self.root_dir, p) for p in themes_dirs] | 41 dirs += [os.path.join(self.root_dir, os.path.expanduser(p)) |
42 for p in themes_dirs] | |
41 | 43 |
42 # Add the default `themes` directory. | 44 # Add the default `themes` directory. |
43 default_themes_dir = os.path.join(self.root_dir, THEMES_DIR) | 45 default_themes_dir = os.path.join(self.root_dir, THEMES_DIR) |
44 if os.path.isdir(default_themes_dir): | 46 if os.path.isdir(default_themes_dir): |
45 dirs.append(default_themes_dir) | 47 dirs.append(default_themes_dir) |
49 theme_dir = os.path.join(d, theme) | 51 theme_dir = os.path.join(d, theme) |
50 if os.path.isdir(theme_dir): | 52 if os.path.isdir(theme_dir): |
51 return theme_dir | 53 return theme_dir |
52 | 54 |
53 raise ThemeNotFoundError( | 55 raise ThemeNotFoundError( |
54 "Can't find theme '%s'. Looked in: %s", | 56 "Can't find theme '%s'. Looked in: %s" % |
55 (theme, ', '.join(dirs))) | 57 (theme, ', '.join(dirs))) |
56 | 58 |