Mercurial > piecrust2
view piecrust/pathutil.py @ 338:938be93215cb
bake: Improve render context and bake record, fix incremental bake bugs.
* Used sources and taxonomies are now stored on a per-render-pass basis.
This fixes bugs where sources/taxonomies were used for one pass, but that
pass is skipped on a later bake because its result is cached.
* Bake records are now created for all pages even when they're not baked.
Record collapsing is gone except for taxonomy index pages.
* Bake records now also have sub-entries in order to store information about
each sub-page, since some sub-pages could use sources/taxonomies differently
than others, or be missing from the output. This lets PieCrust handle
clean/dirty states on a sub-page level.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 06 Apr 2015 19:59:54 -0700 |
parents | 9c074aec60a6 |
children | 3ceeca7bb71c |
line wrap: on
line source
import re import os import os.path import fnmatch re_terminal_path = re.compile(r'^(\w\:)?[/\\]$') class SiteNotFoundError(Exception): def __init__(self, root=None, msg=None): if not root: root = os.getcwd() full_msg = ("No PieCrust website in '%s' " "('config.yml' not found!)" % root) if msg: full_msg += ": " + msg else: full_msg += "." Exception.__init__(self, full_msg) def find_app_root(cwd=None): if cwd is None: cwd = os.getcwd() while not os.path.isfile(os.path.join(cwd, 'config.yml')): cwd = os.path.dirname(cwd) if not cwd or re_terminal_path.match(cwd): raise SiteNotFoundError(cwd) return cwd def multi_fnmatch_filter(names, patterns, modifier=None, inverse=True): res = [] for n in names: matches = False test_n = modifier(n) if modifier else n for p in patterns: if fnmatch.fnmatch(test_n, p): matches = True break if matches and not inverse: res.append(n) elif not matches and inverse: res.append(n) return res