Mercurial > piecrust2
changeset 55:45828c4167ad
Processors can match on other things than just the extension.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 25 Aug 2014 21:40:25 -0700 |
parents | a46354306738 |
children | 2d617b889b00 |
files | piecrust/processing/base.py piecrust/processing/tree.py |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/processing/base.py Mon Aug 25 08:46:11 2014 -0700 +++ b/piecrust/processing/base.py Mon Aug 25 21:40:25 2014 -0700 @@ -36,7 +36,7 @@ def onPipelineEnd(self, pipeline): pass - def supportsExtension(self, ext): + def matches(self, filename): return False def getDependencies(self, path): @@ -56,7 +56,7 @@ super(CopyFileProcessor, self).__init__() self.priority = PRIORITY_LAST - def supportsExtension(self, ext): + def matches(self, filename): return True def getOutputFilenames(self, filename): @@ -74,8 +74,11 @@ super(SimpleFileProcessor, self).__init__() self.extensions = extensions or {} - def supportsExtension(self, ext): - return ext.lstrip('.') in self.extensions + def matches(self, filename): + for ext in self.extensions: + if filename.endswith('.' + ext): + return True + return False def getOutputFilenames(self, filename): basename, ext = os.path.splitext(filename)
--- a/piecrust/processing/tree.py Mon Aug 25 08:46:11 2014 -0700 +++ b/piecrust/processing/tree.py Mon Aug 25 21:40:25 2014 -0700 @@ -34,9 +34,9 @@ def getProcessor(self): if self._processor is None: - _, ext = os.path.splitext(self.path) + _, filename = os.path.split(self.path) for p in self.available_procs: - if p.supportsExtension(ext): + if p.matches(filename): self._processor = p self.available_procs.remove(p) break