diff piecrust/sources/default.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 23052bf8a62b
children 4cc020ff2537
line wrap: on
line diff
--- a/piecrust/sources/default.py	Fri Nov 03 23:14:56 2017 -0700
+++ b/piecrust/sources/default.py	Sun Nov 19 14:29:17 2017 -0800
@@ -27,13 +27,10 @@
         self.default_auto_format = app.config.get('site/default_auto_format')
         self.supported_extensions = list(self.auto_formats)
 
-    def _createItemMetadata(self, path):
-        return self._doCreateItemMetadata(path)
-
     def _finalizeContent(self, parent_group, items, groups):
         SimpleAssetsSubDirMixin._removeAssetGroups(self, groups)
 
-    def _doCreateItemMetadata(self, path):
+    def _createItemMetadata(self, path):
         slug = self._makeSlug(path)
         metadata = {
             'route_params': {
@@ -69,7 +66,7 @@
         return [
             RouteParameter('slug', RouteParameter.TYPE_PATH)]
 
-    def findContent(self, route_params):
+    def findContentFromRoute(self, route_params):
         uri_path = route_params.get('slug', '')
         if not uri_path:
             uri_path = '_index'
@@ -84,14 +81,10 @@
             paths_to_check = [path]
         for path in paths_to_check:
             if os.path.isfile(path):
-                metadata = self._doCreateItemMetadata(path)
+                metadata = self._createItemMetadata(path)
                 return ContentItem(path, metadata)
         return None
 
-    def findContentFromPath(self, path):
-        metadata = self._doCreateItemMetadata(path)
-        return ContentItem(path, metadata)
-
     def setupPrepareParser(self, parser, app):
         parser.add_argument('slug', help='The slug for the new page.')
 
@@ -104,7 +97,7 @@
         if ext == '':
             path = '%s.%s' % (path, self.default_auto_format)
 
-        metadata = self._doCreateItemMetadata(path)
+        metadata = self._createItemMetadata(path)
         config = metadata.setdefault('config', {})
         config.update({'title': uri_to_title(
             os.path.basename(metadata['slug']))})