diff piecrust/commands/builtin/plugins.py @ 879:58ae026b4c31

chef: Optimize startup time.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 15 Jun 2017 22:38:05 -0700
parents 3900169ac81b
children 2394fd689590
line wrap: on
line diff
--- a/piecrust/commands/builtin/plugins.py	Thu Jun 15 22:16:34 2017 -0700
+++ b/piecrust/commands/builtin/plugins.py	Thu Jun 15 22:38:05 2017 -0700
@@ -1,6 +1,5 @@
 import logging
 from piecrust.commands.base import ChefCommand
-from piecrust.pathutil import SiteNotFoundError
 
 
 logger = logging.getLogger(__name__)
@@ -20,17 +19,19 @@
 
         subparsers = parser.add_subparsers()
         p = subparsers.add_parser(
-                'list',
-                help="Lists the plugins installed in the current website.")
+            'list',
+            help="Lists the plugins installed in the current website.")
         p.add_argument(
-                '-a', '--all',
-                action='store_true',
-                help=("Also list all the available plugins for the "
-                      "current environment. The installed one will have an "
-                      "asterix (*)."))
+            '-a', '--all',
+            action='store_true',
+            help=("Also list all the available plugins for the "
+                  "current environment. The installed one will have an "
+                  "asterix (*)."))
         p.set_defaults(sub_func=self._listPlugins)
 
     def checkedRun(self, ctx):
+        from piecrust.pathutil import SiteNotFoundError
+
         if ctx.app.root_dir is None:
             raise SiteNotFoundError(theme=ctx.app.theme_site)
 
@@ -40,10 +41,11 @@
         ctx.args.sub_func(ctx)
 
     def _listPlugins(self, ctx):
+        import pip
+
         names = {}
         installed_suffix = ''
         if ctx.args.all:
-            import pip
             prefix = 'PieCrust-'
             installed_packages = pip.get_installed_distributions()
             for plugin in installed_packages: