# HG changeset patch # User Ludovic Chabant # Date 1409790398 25200 # Node ID b3ce11b2cf360d2b58e288ebc97938496fa43824 # Parent ae90caf2622466c1895ddd5e441fb1a9f3eb0f0e Don't complain about missing `pages` or `posts` directories by default. diff -r ae90caf26224 -r b3ce11b2cf36 piecrust/app.py --- 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, diff -r ae90caf26224 -r b3ce11b2cf36 piecrust/sources/base.py --- 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): diff -r ae90caf26224 -r b3ce11b2cf36 piecrust/sources/posts.py --- 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})$')