diff piecrust/formatting/smartypantsformatter.py @ 850:370e74941d32

optimize: Only load some 3rd party packages when needed. This commit only optimizes the Markdown, SmartyPants, and Pystache wrappers.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 29 Apr 2017 21:27:33 -0700
parents fdb08d986384
children
line wrap: on
line diff
--- a/piecrust/formatting/smartypantsformatter.py	Thu Apr 27 20:55:07 2017 -0700
+++ b/piecrust/formatting/smartypantsformatter.py	Sat Apr 29 21:27:33 2017 -0700
@@ -1,4 +1,3 @@
-import smartypants
 from piecrust.formatting.base import Formatter, PRIORITY_LAST
 
 
@@ -10,13 +9,15 @@
         super(SmartyPantsFormatter, self).__init__()
         self.priority = PRIORITY_LAST
 
+        import smartypants
+        self._sp = smartypants.smartypants
+
     def initialize(self, app):
         super(SmartyPantsFormatter, self).initialize(app)
         self.enabled = (
-                app.config.get('smartypants/enable') or
-                app.config.get('smartypants/enabled'))
+            app.config.get('smartypants/enable') or
+            app.config.get('smartypants/enabled'))
 
     def render(self, format_name, txt):
         assert format_name == 'html'
-        return smartypants.smartypants(txt)
-
+        return self._sp(txt)