Mercurial > piecrust2
diff piecrust/commands/builtin/publishing.py @ 879:58ae026b4c31
chef: Optimize startup time.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 15 Jun 2017 22:38:05 -0700 |
parents | 71a755512eb8 |
children | 13e8b50a2113 |
line wrap: on
line diff
--- a/piecrust/commands/builtin/publishing.py Thu Jun 15 22:16:34 2017 -0700 +++ b/piecrust/commands/builtin/publishing.py Thu Jun 15 22:38:05 2017 -0700 @@ -1,8 +1,5 @@ import logging -import urllib.parse from piecrust.commands.base import ChefCommand -from piecrust.pathutil import SiteNotFoundError -from piecrust.publishing.publisher import Publisher, find_publisher_name logger = logging.getLogger(__name__) @@ -18,13 +15,13 @@ def setupParser(self, parser, app): parser.add_argument( - '--log-publisher', - metavar='LOG_FILE', - help="Log the publisher's output to a given file.") + '--log-publisher', + metavar='LOG_FILE', + help="Log the publisher's output to a given file.") parser.add_argument( - '--preview', - action='store_true', - help="Only preview what the publisher would do.") + '--preview', + action='store_true', + help="Only preview what the publisher would do.") # Don't setup anything for a null app. if app.root_dir is None: @@ -33,8 +30,8 @@ subparsers = parser.add_subparsers() for pub in app.publishers: p = subparsers.add_parser( - pub.target, - help="Publish using target '%s'." % pub.target) + pub.target, + help="Publish using target '%s'." % pub.target) pub.setupPublishParser(p, app) p.set_defaults(sub_func=self._doPublish) p.set_defaults(target=pub.target) @@ -47,6 +44,8 @@ "https://bolt80.com/piecrust/en/latest/docs/publishing/") def checkedRun(self, ctx): + from piecrust.pathutil import SiteNotFoundError + if ctx.app.root_dir is None: raise SiteNotFoundError(theme=ctx.app.theme_site) @@ -56,12 +55,14 @@ ctx.args.sub_func(ctx) def _doPublish(self, ctx): + from piecrust.publishing.publisher import Publisher + pub = Publisher(ctx.app) pub.run( - ctx.args.target, - preview=ctx.args.preview, - extra_args=ctx.args, - log_file=ctx.args.log_publisher, - applied_config_variant=ctx.config_variant, - applied_config_values=ctx.config_values) + ctx.args.target, + preview=ctx.args.preview, + extra_args=ctx.args, + log_file=ctx.args.log_publisher, + applied_config_variant=ctx.config_variant, + applied_config_values=ctx.config_values)