comparison piecrust/main.py @ 663:3ceeca7bb71c

themes: Add support for a `--theme` argument to `chef`.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 01 Mar 2016 22:27:28 -0800
parents 9dd2f68f243b
children 81d9c3a3a0b5
comparison
equal deleted inserted replaced
662:cbd5cdec0695 663:3ceeca7bb71c
38 res = color + res + colorama.Style.RESET_ALL 38 res = color + res + colorama.Style.RESET_ALL
39 return res 39 return res
40 40
41 41
42 class NullPieCrust: 42 class NullPieCrust:
43 def __init__(self): 43 def __init__(self, theme_site=False):
44 self.theme_site = theme_site
44 self.root_dir = None 45 self.root_dir = None
45 self.debug = False 46 self.debug = False
46 self.templates_dirs = [] 47 self.templates_dirs = []
47 self.theme_dir = None 48 self.theme_dir = None
48 self.cache_dir = None 49 self.cache_dir = None
49 self.config = PieCrustConfiguration() 50 self.config = PieCrustConfiguration()
50 self.plugin_loader = PluginLoader(self) 51 self.plugin_loader = PluginLoader(self)
51 self.env = None 52 self.env = None
53
54 def useSubCache(self, cache_name, cache_key):
55 pass
52 56
53 57
54 def main(): 58 def main():
55 if sys.platform == 'darwin': 59 if sys.platform == 'darwin':
56 # There's a bug on MacOSX that can cause Python to be confused 60 # There's a bug on MacOSX that can cause Python to be confused
82 version=('%(prog)s ' + APP_VERSION)) 86 version=('%(prog)s ' + APP_VERSION))
83 parser.add_argument( 87 parser.add_argument(
84 '--root', 88 '--root',
85 help="The root directory of the website.") 89 help="The root directory of the website.")
86 parser.add_argument( 90 parser.add_argument(
91 '--theme',
92 action='store_true',
93 help="Makes the current command apply to a theme website.")
94 parser.add_argument(
87 '--config', 95 '--config',
88 dest='config_variant', 96 dest='config_variant',
89 help="The configuration variant to use for this command.") 97 help="The configuration variant to use for this command.")
90 parser.add_argument( 98 parser.add_argument(
91 '--config-set', 99 '--config-set',
194 root = None 202 root = None
195 if pre_args.root: 203 if pre_args.root:
196 root = os.path.expanduser(pre_args.root) 204 root = os.path.expanduser(pre_args.root)
197 else: 205 else:
198 try: 206 try:
199 root = find_app_root() 207 root = find_app_root(theme=pre_args.theme)
200 except SiteNotFoundError: 208 except SiteNotFoundError:
201 root = None 209 root = None
202 210
203 if not root: 211 if not root:
204 app = NullPieCrust() 212 app = NullPieCrust(
213 theme_site=pre_args.theme)
205 else: 214 else:
206 app = PieCrust(root, cache=(not pre_args.no_cache), 215 app = PieCrust(
207 debug=pre_args.debug) 216 root,
217 theme_site=pre_args.theme,
218 cache=(not pre_args.no_cache),
219 debug=pre_args.debug)
208 220
209 # Build a hash for a custom cache directory. 221 # Build a hash for a custom cache directory.
210 cache_key = 'default' 222 cache_key = 'default'
211 223
212 # Handle custom configurations. 224 # Handle custom configurations.