Mercurial > piecrust2
comparison piecrust/main.py @ 989:8adc27285d93
bake: Big pass on bake performance.
- Reduce the amount of data passed between processes.
- Make inter-process data simple objects to make it easier to test with
alternatives to pickle.
- Make sources have the basic requirement to be able to find a content item
from an item spec (path).
- Make Hoedown the default Markdown formatter.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 19 Nov 2017 14:29:17 -0800 |
parents | 45ad976712ec |
children | c4cfbbeed72e |
comparison
equal
deleted
inserted
replaced
988:f83ae0a5d793 | 989:8adc27285d93 |
---|---|
17 from piecrust.plugins.base import PluginLoader | 17 from piecrust.plugins.base import PluginLoader |
18 | 18 |
19 | 19 |
20 logger = logging.getLogger(__name__) | 20 logger = logging.getLogger(__name__) |
21 | 21 |
22 _chef_start_time = time.perf_counter() | |
23 | |
22 | 24 |
23 class ColoredFormatter(logging.Formatter): | 25 class ColoredFormatter(logging.Formatter): |
24 COLORS = { | 26 COLORS = { |
25 'DEBUG': colorama.Fore.BLACK + colorama.Style.BRIGHT, | 27 'DEBUG': colorama.Fore.BLACK + colorama.Style.BRIGHT, |
26 'INFO': '', | 28 'INFO': '', |
244 return cache_key | 246 return cache_key |
245 | 247 |
246 | 248 |
247 def _run_chef(pre_args, argv): | 249 def _run_chef(pre_args, argv): |
248 # Setup the app. | 250 # Setup the app. |
249 start_time = time.perf_counter() | |
250 root = None | 251 root = None |
251 if pre_args.root: | 252 if pre_args.root: |
252 root = os.path.expanduser(pre_args.root) | 253 root = os.path.expanduser(pre_args.root) |
253 else: | 254 else: |
254 try: | 255 try: |
304 print_help_item(epilog, name, desc) | 305 print_help_item(epilog, name, desc) |
305 parser.epilog = epilog.getvalue() | 306 parser.epilog = epilog.getvalue() |
306 | 307 |
307 # Parse the command line. | 308 # Parse the command line. |
308 result = parser.parse_args(argv) | 309 result = parser.parse_args(argv) |
309 logger.debug(format_timed(start_time, 'initialized PieCrust', | 310 logger.debug(format_timed(_chef_start_time, 'initialized PieCrust', |
310 colored=False)) | 311 colored=False)) |
311 | 312 |
312 # Print the help if no command was specified. | 313 # Print the help if no command was specified. |
313 if not hasattr(result, 'func'): | 314 if not hasattr(result, 'func'): |
314 parser.print_help() | 315 parser.print_help() |
315 return 0 | 316 return 0 |
317 | |
318 # Add some timing information. | |
319 app.env.stats.registerTimer('ChefStartup') | |
320 app.env.stats.stepTimerSince('ChefStartup', _chef_start_time) | |
316 | 321 |
317 # Run the command! | 322 # Run the command! |
318 ctx = CommandContext(appfactory, app, parser, result) | 323 ctx = CommandContext(appfactory, app, parser, result) |
319 exit_code = result.func(ctx) | 324 exit_code = result.func(ctx) |
320 if exit_code is None: | 325 if exit_code is None: |