changeset 84:b3ce11b2cf36

Don't complain about missing `pages` or `posts` directories by default.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 03 Sep 2014 17:26:38 -0700
parents ae90caf26224
children 3471ffa059b2
files piecrust/app.py piecrust/sources/base.py piecrust/sources/posts.py
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/app.py	Mon Sep 01 14:54:34 2014 -0700
+++ b/piecrust/app.py	Wed Sep 03 17:26:38 2014 -0700
@@ -182,7 +182,8 @@
             sourcesc = {}
             sourcesc['pages'] = {
                     'type': 'default',
-                    'data_endpoint': 'site/pages',
+                    'ignore_missing_dir': True,
+                    'data_endpoint': 'site.pages',
                     'item_name': 'page'}
             sitec['sources'] = sourcesc
 
@@ -216,6 +217,7 @@
                 sourcesc[blog_name] = {
                         'type': 'posts/%s' % posts_fs,
                         'fs_endpoint': endpoint,
+                        'ignore_missing_dir': True,
                         'data_type': 'blog',
                         'item_name': item_name,
                         'items_per_page': items_per_page,
--- a/piecrust/sources/base.py	Mon Sep 01 14:54:34 2014 -0700
+++ b/piecrust/sources/base.py	Wed Sep 03 17:26:38 2014 -0700
@@ -298,6 +298,8 @@
     def buildPageFactories(self):
         logger.debug("Scanning for pages in: %s" % self.fs_endpoint_path)
         if not os.path.isdir(self.fs_endpoint_path):
+            if self.ignore_missing_dir:
+                return
             raise InvalidFileSystemEndpointError(self.name, self.fs_endpoint_path)
 
         for dirpath, dirnames, filenames in os.walk(self.fs_endpoint_path):
--- a/piecrust/sources/posts.py	Mon Sep 01 14:54:34 2014 -0700
+++ b/piecrust/sources/posts.py	Wed Sep 03 17:26:38 2014 -0700
@@ -137,7 +137,10 @@
 
     def _checkFsEndpointPath(self):
         if not os.path.isdir(self.fs_endpoint_path):
+            if self.ignore_missing_dir:
+                return False
             raise InvalidFileSystemEndpointError(self.name, self.fs_endpoint_path)
+        return True
 
     def _makeFactory(self, path, slug, year, month, day):
         path = path.replace('\\', '/')
@@ -159,6 +162,8 @@
         super(FlatPostsSource, self).__init__(app, name, config)
 
     def buildPageFactories(self):
+        if not self._checkFsEndpointPath():
+            return
         logger.debug("Scanning for posts (flat) in: %s" % self.fs_endpoint_path)
         pattern = re.compile(r'(\d{4})-(\d{2})-(\d{2})_(.*)\.(\w+)$')
         _, __, filenames = next(os.walk(self.fs_endpoint_path))
@@ -185,6 +190,8 @@
         super(ShallowPostsSource, self).__init__(app, name, config)
 
     def buildPageFactories(self):
+        if not self._checkFsEndpointPath():
+            return
         logger.debug("Scanning for posts (shallow) in: %s" % self.fs_endpoint_path)
         year_pattern = re.compile(r'(\d{4})$')
         file_pattern = re.compile(r'(\d{2})-(\d{2})_(.*)\.(\w+)$')
@@ -222,6 +229,8 @@
         super(HierarchyPostsSource, self).__init__(app, name, config)
 
     def buildPageFactories(self):
+        if not self._checkFsEndpointPath():
+            return
         logger.debug("Scanning for posts (hierarchy) in: %s" % self.fs_endpoint_path)
         year_pattern = re.compile(r'(\d{4})$')
         month_pattern = re.compile(r'(\d{2})$')